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

📄 dfinsbin.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 2 页
字号:
   BsaveExpression(((DEFINSTANCES *) theDefinstances)->mkinstance,(FILE *) userBuffer);  }/***********************************************************  NAME         : BsaveStorageDefinstances  DESCRIPTION  : Writes out number of each type of structure                   required for definstances                 Space required for counts (unsigned long)  INPUTS       : File pointer of binary file  RETURNS      : Nothing useful  SIDE EFFECTS : Binary file adjusted  NOTES        : None ***********************************************************/static VOID BsaveStorageDefinstances(fp)  FILE *fp;  {   unsigned long space;      space = sizeof(unsigned long) * 2;   GenWrite((VOID *) &space,(unsigned long) sizeof(unsigned long),fp);   GenWrite((VOID *) &ModuleCount,(unsigned long) sizeof(long),fp);   GenWrite((VOID *) &DefinstancesCount,(unsigned long) sizeof(long),fp);  }  /*************************************************************************************  NAME         : BsaveDefinstancesDriver  DESCRIPTION  : Writes out definstances in binary format                 Space required (unsigned long)                 All definstances (sizeof(DEFINSTANCES) * Number of definstances)  INPUTS       : File pointer of binary file  RETURNS      : Nothing useful  SIDE EFFECTS : Binary file adjusted  NOTES        : None *************************************************************************************/static VOID BsaveDefinstancesDriver(fp)  FILE *fp;  {   unsigned long space;   struct defmodule *theModule;   DEFINSTANCES_MODULE *theModuleItem;   BSAVE_DEFINSTANCES_MODULE dummy_mitem;   space = (unsigned long) ((sizeof(BSAVE_DEFINSTANCES_MODULE) * ModuleCount) +                            (sizeof(BSAVE_DEFINSTANCES) * DefinstancesCount));   GenWrite((VOID *) &space,(unsigned long) sizeof(unsigned long),fp);      /* =================================      Write out each definstances module      ================================= */   DefinstancesCount = 0L;   theModule = (struct defmodule *) GetNextDefmodule(NULL);   while (theModule != NULL)     {      theModuleItem = (DEFINSTANCES_MODULE *)                       GetModuleItem(theModule,FindModuleItem("definstances")->moduleIndex);      AssignBsaveDefmdlItemHdrVals(&dummy_mitem.header,&theModuleItem->header);      GenWrite((VOID *) &dummy_mitem,(unsigned long) sizeof(BSAVE_DEFINSTANCES_MODULE),fp);      theModule = (struct defmodule *) GetNextDefmodule((VOID *) theModule);     }        /* ==========================      Write out each definstances      ========================== */   DoForAllConstructs(BsaveDefinstances,DefinstancesModuleIndex,                      CLIPS_FALSE,(VOID *) fp);                         if (Bloaded())     {      RestoreBloadCount(&ModuleCount);      RestoreBloadCount(&DefinstancesCount);     }  }/***************************************************  NAME         : BsaveDefinstances  DESCRIPTION  : Bsaves a definstances  INPUTS       : 1) The definstances                 2) Output data file pointer  RETURNS      : Nothing useful  SIDE EFFECTS : Definstances saved  NOTES        : None ***************************************************/static VOID BsaveDefinstances(theDefinstances,userBuffer)  struct constructHeader *theDefinstances;  VOID *userBuffer;  {   DEFINSTANCES *dptr = (DEFINSTANCES *) theDefinstances;   BSAVE_DEFINSTANCES dummy_df;      AssignBsaveConstructHeaderVals(&dummy_df.header,&dptr->header);  if (dptr->mkinstance != NULL)     {      dummy_df.mkinstance = ExpressionCount;      ExpressionCount += ExpressionSize(dptr->mkinstance);     }   else    dummy_df.mkinstance = -1L;   GenWrite((VOID *) &dummy_df,(unsigned long) sizeof(BSAVE_DEFINSTANCES),(FILE *) userBuffer);  }#endif/***********************************************************************  NAME         : BloadStorageDefinstances  DESCRIPTION  : This routine space required for definstances                   structures and allocates space for them  INPUTS       : Nothing  RETURNS      : Nothing useful  SIDE EFFECTS : Arrays allocated and set  NOTES        : This routine makes no attempt to reset any pointers                   within the structures ***********************************************************************/static VOID BloadStorageDefinstances()  {   unsigned long space;   GenRead((VOID *) &space,(unsigned long) sizeof(unsigned long));   if (space == 0L)     return;   GenRead((VOID *) &ModuleCount,(unsigned long) sizeof(unsigned long));   GenRead((VOID *) &DefinstancesCount,(unsigned long) sizeof(unsigned long));   if (ModuleCount == 0L)     {      ModuleArray = NULL;      definstancesArray = NULL;      return;     }        space = (unsigned long) (ModuleCount * sizeof(DEFINSTANCES_MODULE));   ModuleArray = (DEFINSTANCES_MODULE HUGE_ADDR *) genlongalloc(space);   if (DefinstancesCount == 0L)     {      definstancesArray = NULL;      return;     }        space = (unsigned long) (DefinstancesCount * sizeof(DEFINSTANCES));   definstancesArray = (DEFINSTANCES HUGE_ADDR *) genlongalloc(space);  }/*********************************************************************  NAME         : BloadDefinstances  DESCRIPTION  : This routine reads definstances information from                   a binary file                 This routine moves through the definstances                   binary array updating pointers  INPUTS       : None  RETURNS      : Nothing useful  SIDE EFFECTS : Pointers reset from array indices  NOTES        : Assumes all loading is finished ********************************************************************/static VOID BloadDefinstances()  {   unsigned long space;      GenRead((VOID *) &space,(unsigned long) sizeof(unsigned long));   BloadandRefresh(ModuleCount,sizeof(BSAVE_DEFINSTANCES_MODULE),UpdateDefinstancesModule);   BloadandRefresh(DefinstancesCount,sizeof(BSAVE_DEFINSTANCES),UpdateDefinstances);  }/*******************************************************  NAME         : UpdateDefinstancesModule  DESCRIPTION  : Updates definstances module with binary                 load data - sets pointers from                 offset information  INPUTS       : 1) A pointer to the bloaded data                 2) The index of the binary array                    element to update  RETURNS      : Nothing useful  SIDE EFFECTS : Definstances moudle pointers updated  NOTES        : None *******************************************************/static VOID UpdateDefinstancesModule(buf,obji)  VOID *buf;  long obji;  {   BSAVE_DEFINSTANCES_MODULE *bdptr;      bdptr = (BSAVE_DEFINSTANCES_MODULE *) buf;   UpdateDefmoduleItemHeader(&bdptr->header,&ModuleArray[obji].header,                             (int) sizeof(DEFINSTANCES),(VOID *) definstancesArray);  }/***************************************************  NAME         : UpdateDefinstances  DESCRIPTION  : Updates definstances with binary                 load data - sets pointers from                 offset information  INPUTS       : 1) A pointer to the bloaded data                 2) The index of the binary array                    element to update  RETURNS      : Nothing useful  SIDE EFFECTS : Definstances pointers upadted  NOTES        : None ***************************************************/static VOID UpdateDefinstances(buf,obji)  VOID *buf;  long obji;  {   BSAVE_DEFINSTANCES *bdptr;   DEFINSTANCES *dfiptr;      bdptr = (BSAVE_DEFINSTANCES *) buf;   dfiptr = (DEFINSTANCES *) &definstancesArray[obji];      UpdateConstructHeader(&bdptr->header,&dfiptr->header,                         (int) sizeof(DEFINSTANCES_MODULE),(VOID *) ModuleArray,                         (int) sizeof(DEFINSTANCES),(VOID *) definstancesArray);   dfiptr->mkinstance = ExpressionPointer(bdptr->mkinstance);   dfiptr->busy = 0;  }/***************************************************************  NAME         : ClearDefinstancesBload  DESCRIPTION  : Release all binary-loaded definstances                   structure arrays                 Resets definstances list to NULL  INPUTS       : None  RETURNS      : Nothing useful  SIDE EFFECTS : Memory cleared  NOTES        : Definstances name symbol counts decremented ***************************************************************/static VOID ClearDefinstancesBload()  {   register long i;   unsigned long space;   space = (unsigned long) (sizeof(DEFINSTANCES_MODULE) * ModuleCount);   if (space == 0L)     return;   genlongfree((VOID *) ModuleArray,space);   ModuleArray = NULL;   ModuleCount = 0L;   for (i = 0L ; i < DefinstancesCount ; i++)     UnmarkConstructHeader(&definstancesArray[i].header);   space = (unsigned long) (sizeof(DEFINSTANCES) * DefinstancesCount);   if (space == 0L)     return;   genlongfree((VOID *) definstancesArray,space);   definstancesArray = NULL;   DefinstancesCount = 0L;  }#endif/***************************************************  NAME         :   DESCRIPTION  :   INPUTS       :   RETURNS      :   SIDE EFFECTS :   NOTES        :  ***************************************************/

⌨️ 快捷键说明

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