⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dffctbin.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 2 页
字号:
  FILE *fp;  {   unsigned long int space;   struct deffacts *theDeffacts;   struct bsaveDeffacts newDeffacts;   struct defmodule *theModule;   struct bsaveDeffactsModule tempDeffactsModule;   struct deffactsModule *theModuleItem;      /*=========================================================*/   /* Write out the amount of space taken up by the deffacts  */   /* and deffactsModule data structures in the binary image. */   /*=========================================================*/      space = NumberOfDeffacts * sizeof(struct bsaveDeffacts) +           (NumberOfDeffactsModules * sizeof(struct bsaveDeffactsModule));   GenWrite(&space,(unsigned long) sizeof(unsigned long int),fp);      /*================================================*/   /* Write out each deffacts module data structure. */   /*================================================*/   NumberOfDeffacts = 0;   for (theModule = (struct defmodule *) GetNextDefmodule(NULL);        theModule != NULL;        theModule = (struct defmodule *) GetNextDefmodule(theModule))     {      SetCurrentModule((VOID *) theModule);            theModuleItem = (struct deffactsModule *) GetModuleItem(NULL,DeffactsModuleIndex);      AssignBsaveDefmdlItemHdrVals(&tempDeffactsModule.header,&theModuleItem->header);      GenWrite(&tempDeffactsModule,(unsigned long) sizeof(struct bsaveDeffactsModule),fp);     }        /*==========================*/   /* Write out each deffacts. */   /*==========================*/   for (theModule = (struct defmodule *) GetNextDefmodule(NULL);        theModule != NULL;        theModule = (struct defmodule *) GetNextDefmodule(theModule))     {      SetCurrentModule((VOID *) theModule);        for (theDeffacts = (struct deffacts *) GetNextDeffacts(NULL);           theDeffacts != NULL;           theDeffacts = (struct deffacts *) GetNextDeffacts(theDeffacts))        {         AssignBsaveConstructHeaderVals(&newDeffacts.header,&theDeffacts->header);         if (theDeffacts->assertList != NULL)           {            newDeffacts.assertList = ExpressionCount;            ExpressionCount += ExpressionSize(theDeffacts->assertList);           }         else           { newDeffacts.assertList = -1L; }         GenWrite(&newDeffacts,(unsigned long) sizeof(struct bsaveDeffacts),fp);        }     }      /*=============================================================*/   /* If a binary image was already loaded when the bsave command */   /* was issued, then restore the counts indicating the number   */   /* of deffacts and deffacts modules in the binary image (these */   /* were overwritten by the binary save).                       */   /*=============================================================*/   if (Bloaded())     {      RestoreBloadCount(&NumberOfDeffactsModules);      RestoreBloadCount(&NumberOfDeffacts);     }  }  #endif /* BLOAD_AND_BSAVE *//****************************************************//* BloadStorage: Allocates storage requirements for *//*   the deffacts used by this binary image.        *//****************************************************/static VOID BloadStorage()  {   unsigned long int space;   /*=====================================================*/   /* Determine the number of deffacts and deffactsModule */   /* data structures to be read.                         */   /*=====================================================*/   GenRead(&space,(unsigned long) sizeof(unsigned long int));   GenRead(&NumberOfDeffacts,(unsigned long) sizeof(long int));   GenRead(&NumberOfDeffactsModules,(unsigned long) sizeof(long int));      /*===================================*/   /* Allocate the space needed for the */   /* deffactsModule data structures.   */   /*===================================*/      if (NumberOfDeffactsModules == 0)     {      DeffactsArray = NULL;      ModuleArray = NULL;      return;     }        space = NumberOfDeffactsModules * sizeof(struct deffactsModule);   ModuleArray = (struct deffactsModule HUGE_ADDR *) genlongalloc(space);   /*===================================*/   /* Allocate the space needed for the */   /* deffacts data structures.         */   /*===================================*/      if (NumberOfDeffacts == 0)     {      DeffactsArray = NULL;      return;     }        space = (unsigned long) (NumberOfDeffacts * sizeof(struct deffacts));   DeffactsArray = (struct deffacts HUGE_ADDR *) genlongalloc(space);  }/*****************************************************//* BloadBinaryItem: Loads and refreshes the deffacts *//*   constructs used by this binary image.           *//*****************************************************/static VOID BloadBinaryItem()  {   unsigned long int space;   /*======================================================*/   /* Read in the amount of space used by the binary image */   /* (this is used to skip the construct in the event it  */   /* is not available in the version of CLIPS being run). */   /*======================================================*/      GenRead(&space,(unsigned long) sizeof(unsigned long int));      /*============================================*/   /* Read in the deffactsModule data structures */   /* and refresh the pointers.                  */   /*============================================*/      BloadandRefresh(NumberOfDeffactsModules,                   (unsigned) sizeof(struct bsaveDeffactsModule),                   UpdateDeffactsModule);                      /*======================================*/   /* Read in the deffacts data structures */   /* and refresh the pointers.            */   /*======================================*/                      BloadandRefresh(NumberOfDeffacts,                   (unsigned) sizeof(struct bsaveDeffacts),                   UpdateDeffacts);  }  /***************************************************//* UpdateDeffactsModule: Bload refresh routine for *//*   deffacts module data structures.              *//***************************************************/static VOID UpdateDeffactsModule(buf,obji)  VOID *buf;  long obji;  {   struct bsaveDeffactsModule *bdmPtr;      bdmPtr = (struct bsaveDeffactsModule *) buf;   UpdateDefmoduleItemHeader(&bdmPtr->header,&ModuleArray[obji].header,                             (int) sizeof(struct deffacts),(VOID *) DeffactsArray);  }/*********************************************//* UpdateDeffacts: Bload refresh routine for *//*   deffacts data structures.               *//*********************************************/static VOID UpdateDeffacts(buf,obji)  VOID *buf;  long obji;  {   struct bsaveDeffacts *bdp;      bdp = (struct bsaveDeffacts *) buf;   UpdateConstructHeader(&bdp->header,&DeffactsArray[obji].header,                         (int) sizeof(struct deffactsModule),(VOID *) ModuleArray,                         (int) sizeof(struct deffacts),(VOID *) DeffactsArray);   DeffactsArray[obji].assertList = ExpressionPointer(bdp->assertList);  }  /**************************************//* ClearBload: Deffacts clear routine *//*   when a binary load is in effect. *//**************************************/static VOID ClearBload()  {   long i;   unsigned long space;   /*=============================================*/   /* Decrement in use counters for atomic values */   /* contained in the construct headers.         */   /*=============================================*/      for (i = 0; i < NumberOfDeffacts; i++)     { UnmarkConstructHeader(&DeffactsArray[i].header); }   /*=============================================================*/   /* Deallocate the space used for the deffacts data structures. */   /*=============================================================*/      space = NumberOfDeffacts * sizeof(struct deffacts);   if (space != 0) genlongfree((VOID *) DeffactsArray,space);   /*====================================================================*/   /* Deallocate the space used for the deffacts module data structures. */   /*====================================================================*/      space =  NumberOfDeffactsModules * sizeof(struct deffactsModule);   if (space != 0) genlongfree((VOID *) ModuleArray,space);  }  /******************************************************//* BloadDeffactsModuleReference: Returns the deffacts *//*   module pointer for use with the bload function.  *//******************************************************/globle VOID *BloadDeffactsModuleReference(index)  int index;  {   return ((VOID *) &ModuleArray[index]);  }  #endif /* DEFFACTS_CONSTRUCT && (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -