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

📄 symblbin.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 2 页
字号:
     {      for (integerPtr = integerArray[i];           integerPtr != NULL;           integerPtr = integerPtr->next)        {         if (integerPtr->neededInteger) numberOfUsedIntegers++;        }     }   /*==========================================================*/   /* Write out the number of integers and the integer values. */   /*==========================================================*/   GenWrite(&numberOfUsedIntegers,(unsigned long) sizeof(unsigned long int),fp);   for (i = 0 ; i < INTEGER_HASH_SIZE; i++)     {      for (integerPtr = integerArray[i];           integerPtr != NULL;           integerPtr = integerPtr->next)        {         if (integerPtr->neededInteger)           {            GenWrite(&integerPtr->contents,                     (unsigned long) sizeof(integerPtr->contents),fp);           }        }     }  }  /*****************************************************************//* WriteNeededBitMaps: Stores all of the bitmaps in the bitmap   *//*   table needed for this binary image in the binary save file. *//*****************************************************************/static VOID WriteNeededBitMaps(fp)  FILE *fp;  {   int i;   BITMAP_HN **bitMapArray;   BITMAP_HN *bitMapPtr;   unsigned long int numberOfUsedBitMaps = 0, size = 0;   char tempSize;   /*=================================*/   /* Get a copy of the bitmap table. */   /*=================================*/   bitMapArray = GetBitMapTable();   /*======================================================*/   /* Get the number of bitmaps and the total bitmap size. */   /*======================================================*/   for (i = 0; i < BITMAP_HASH_SIZE; i++)     {      for (bitMapPtr = bitMapArray[i];           bitMapPtr != NULL;           bitMapPtr = bitMapPtr->next)        {         if (bitMapPtr->neededBitMap)           {            numberOfUsedBitMaps++;            size += bitMapPtr->size + 1;           }        }     }        /*========================================*/   /* Write out the bitmaps and their sizes. */   /*========================================*/   GenWrite((VOID *) &numberOfUsedBitMaps,(unsigned long) sizeof(unsigned long int),fp);   GenWrite((VOID *) &size,(unsigned long) sizeof(unsigned long int),fp);   for (i = 0; i < BITMAP_HASH_SIZE; i++)     {      for (bitMapPtr = bitMapArray[i];           bitMapPtr != NULL;           bitMapPtr = bitMapPtr->next)        {         if (bitMapPtr->neededBitMap)           {            tempSize = bitMapPtr->size;            GenWrite((VOID *) &tempSize,(unsigned long) sizeof(char),fp);            GenWrite((VOID *) bitMapPtr->contents,(unsigned long) bitMapPtr->size,fp);           }        }     }  }  #endif /* BLOAD_AND_BSAVE || BSAVE_INSTANCES *//*********************************************//* ReadNeededAtomicValues: Read all symbols, *//*   floats, integers, and bitmaps needed by *//*   this binary image from the binary file. *//*********************************************/globle VOID ReadNeededAtomicValues()  {   ReadNeededSymbols();   ReadNeededFloats();   ReadNeededIntegers();   ReadNeededBitMaps();  }/*******************************************//* ReadNeededSymbols: Reads in the symbols *//*   used by the binary image.             *//*******************************************/static VOID ReadNeededSymbols()  {   char *symbolNames, *namePtr;   unsigned long space;   long i;   /*=================================================*/   /* Determine the number of symbol names to be read */   /* and space required for them.                    */   /*=================================================*/   GenRead((VOID *) &NumberOfSymbols,(unsigned long) sizeof(long int));   GenRead(&space,(unsigned long) sizeof(unsigned long int));   if (NumberOfSymbols == 0)     {      SymbolArray = NULL;      return;     }   /*=======================================*/   /* Allocate area for strings to be read. */   /*=======================================*/   symbolNames = (char *) gm3((long) space);   GenRead((VOID *) symbolNames,space);   /*================================================*/   /* Store the symbol pointers in the symbol array. */   /*================================================*/   SymbolArray = (SYMBOL_HN **)                 gm3((long) sizeof(SYMBOL_HN *) *  NumberOfSymbols);   namePtr = symbolNames;   for (i = 0; i < NumberOfSymbols; i++)     {      SymbolArray[i] = (SYMBOL_HN *) AddSymbol(namePtr);      namePtr += strlen(namePtr) + 1;     }   /*=======================*/   /* Free the name buffer. */   /*=======================*/   rm3((VOID *) symbolNames,(long) space);  }/*****************************************//* ReadNeededFloats: Reads in the floats *//*   used by the binary image.           *//*****************************************/static VOID ReadNeededFloats()  {   double HUGE_ADDR *floatValues;   long i;   /*============================================*/   /* Determine the number of floats to be read. */   /*============================================*/   GenRead(&NumberOfFloats,(unsigned long) sizeof(long int));   if (NumberOfFloats == 0)     {      FloatArray = NULL;      return;     }   /*===============================*/   /* Allocate area for the floats. */   /*===============================*/   floatValues = (double *) gm3((long) sizeof(double) * NumberOfFloats);   GenRead((VOID *) floatValues,(unsigned long) (sizeof(double) * NumberOfFloats));   /*======================================*/   /* Store the floats in the float array. */   /*======================================*/   FloatArray = (FLOAT_HN **)               gm3((long) sizeof(FLOAT_HN *) * NumberOfFloats);   for (i = 0; i < NumberOfFloats; i++)     { FloatArray[i] = (FLOAT_HN *) AddDouble(floatValues[i]); }   /*========================*/   /* Free the float buffer. */   /*========================*/   rm3((VOID *) floatValues,(long) (sizeof(double) * NumberOfFloats));  }/*********************************************//* ReadNeededIntegers: Reads in the integers *//*   used by the binary image.               *//*********************************************/static VOID ReadNeededIntegers()  {   long int HUGE_ADDR *integerValues;   long i;   /*==============================================*/   /* Determine the number of integers to be read. */   /*==============================================*/   GenRead(&NumberOfIntegers,(unsigned long) sizeof(unsigned long int));   if (NumberOfIntegers == 0)     {      IntegerArray = NULL;      return;     }        /*=================================*/   /* Allocate area for the integers. */   /*=================================*/   integerValues = (long *) gm3((long) (sizeof(long) * NumberOfIntegers));   GenRead((VOID *) integerValues,(unsigned long) (sizeof(long) * NumberOfIntegers));   /*==========================================*/   /* Store the integers in the integer array. */   /*==========================================*/   IntegerArray = (INTEGER_HN **)           gm3((long) (sizeof(INTEGER_HN *) * NumberOfIntegers));   for (i = 0; i < NumberOfIntegers; i++)     { IntegerArray[i] = (INTEGER_HN *) AddLong(integerValues[i]); }   /*==========================*/   /* Free the integer buffer. */   /*==========================*/   rm3((VOID *) integerValues,(long) (sizeof(long int) * NumberOfIntegers));  }  /*******************************************//* ReadNeededBitMaps: Reads in the bitmaps *//*   used by the binary image.             *//*******************************************/static VOID ReadNeededBitMaps()  {   char *bitMapStorage, *bitMapPtr;   unsigned long space;   long i;   /*=======================================*/   /* Determine the number of bitmaps to be */   /* read and space required for them.     */   /*=======================================*/   GenRead((VOID *) &NumberOfBitMaps,(unsigned long) sizeof(long int));   GenRead(&space,(unsigned long) sizeof(unsigned long int));   if (NumberOfBitMaps == 0)     {      BitMapArray = NULL;      return;     }        /*=======================================*/   /* Allocate area for bitmaps to be read. */   /*=======================================*/   bitMapStorage = (char *) gm3((long) space);   GenRead((VOID *) bitMapStorage,space);   /*================================================*/   /* Store the bitMap pointers in the bitmap array. */   /*================================================*/   BitMapArray = (BITMAP_HN **)                 gm3((long) sizeof(BITMAP_HN *) *  NumberOfBitMaps);   bitMapPtr = bitMapStorage;   for (i = 0; i < NumberOfBitMaps; i++)     {      BitMapArray[i] = (BITMAP_HN *) AddBitMap(bitMapPtr+1,(int) *bitMapPtr);      bitMapPtr += *bitMapPtr + 1;     }   /*=========================*/   /* Free the bitmap buffer. */   /*=========================*/   rm3((VOID *) bitMapStorage,(long) space);  }  /**********************************************************//* FreeAtomicValueStorage: Returns the memory allocated   *//*   for storing the pointers to atomic data values used  *//*   in refreshing expressions and other data structures. *//**********************************************************/globle VOID FreeAtomicValueStorage()  {   if (SymbolArray != NULL)     rm3((VOID *) SymbolArray,(long) sizeof(SYMBOL_HN *) * NumberOfSymbols);   if (FloatArray != NULL)     rm3((VOID *) FloatArray,(long) sizeof(FLOAT_HN *) * NumberOfFloats);   if (IntegerArray != NULL)     rm3((VOID *) IntegerArray,(long) sizeof(INTEGER_HN *) * NumberOfIntegers);   if (BitMapArray != NULL)     rm3((VOID *) BitMapArray,(long) sizeof(BITMAP_HN *) * NumberOfBitMaps);  }  #endif /* BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE || BLOAD_INSTANCES || BSAVE_INSTANCES */

⌨️ 快捷键说明

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