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

📄 globlbin.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 2 页
字号:
   /*******************************************************/   /*      "C" Language Integrated Production System      */   /*                                                     */   /*             CLIPS Version 6.05  04/09/97            */   /*                                                     */   /*            DEFGLOBAL BSAVE/BLOAD MODULE             */   /*******************************************************//*************************************************************//* Purpose: Implements the binary save/load feature for the  *//*    defglobal construct.                                   *//*                                                           *//* Principal Programmer(s):                                  *//*      Gary D. Riley                                        *//*                                                           *//* Contributing Programmer(s):                               *//*      Brian L. Donnell                                     *//*                                                           *//* Revision History:                                         *//*                                                           *//*************************************************************/#define _GLOBLBIN_SOURCE_#include "setup.h"#if DEFGLOBAL_CONSTRUCT && (BLOAD || BLOAD_AND_BSAVE || BLOAD_ONLY) && (! RUN_TIME)#include <stdio.h>#define _CLIPS_STDIO_#include "clipsmem.h"#include "multifld.h"#include "globldef.h"#include "bload.h"#include "bsave.h"#include "moduldef.h"#include "globlbsc.h"#include "globlbin.h"  /***************************************//* LOCAL INTERNAL FUNCTION DEFINITIONS *//***************************************/#if ANSI_COMPILER#if BLOAD_AND_BSAVE   static VOID                    BsaveFind(void);   static VOID                    BsaveStorage(FILE *);   static VOID                    BsaveBinaryItem(FILE *);#endif   static VOID                    BloadStorageDefglobals(void);   static VOID                    BloadBinaryItem(void);   static VOID                    UpdateDefglobalModule(VOID *,long);   static VOID                    UpdateDefglobal(VOID *,long);   static VOID                    ClearBload(void);#else#if BLOAD_AND_BSAVE   static VOID                    BsaveFind();   static VOID                    BsaveStorage();   static VOID                    BsaveBinaryItem();#endif   static VOID                    BloadStorageDefglobals();   static VOID                    BloadBinaryItem();   static VOID                    UpdateDefglobalModule();   static VOID                    UpdateDefglobal();   static VOID                    ClearBload();#endif/****************************************//* GLOBAL INTERNAL VARIABLE DEFINITIONS *//****************************************/   globle struct defglobal HUGE_ADDR       *DefglobalArray = NULL;   /***************************************//* LOCAL INTERNAL VARIABLE DEFINITIONS *//***************************************/      static long                              NumberOfDefglobals = 0;   static struct defglobalModule HUGE_ADDR *ModuleArray;   static long                              NumberOfDefglobalModules;/*********************************************//* DefglobalBinarySetup: Installs the binary *//*   save/load feature for the defglobals.   *//*********************************************/globle VOID DefglobalBinarySetup()  {#if (BLOAD_AND_BSAVE || BLOAD)   AddAfterBloadFunction("defglobal",ResetDefglobals,50);#endif#if BLOAD_AND_BSAVE   AddBinaryItem("defglobal",0,BsaveFind,NULL,                             BsaveStorage,BsaveBinaryItem,                             BloadStorageDefglobals,BloadBinaryItem,                             ClearBload);#endif#if (BLOAD || BLOAD_ONLY)   AddBinaryItem("defglobal",0,NULL,NULL,NULL,NULL,                             BloadStorageDefglobals,BloadBinaryItem,                             ClearBload);#endif  }#if BLOAD_AND_BSAVE/****************************************************//* BsaveFind:  Counts the number of data structures *//*   which must be saved in the binary image for    *//*   the defglobals in the current environment.     *//****************************************************/static VOID BsaveFind()  {   struct defglobal *defglobalPtr;   struct defmodule *theModule;      /*=======================================================*/   /* If a binary image is already loaded, then temporarily */   /* save the count values since these will be overwritten */   /* in the process of saving the binary image.            */   /*=======================================================*/   if (Bloaded())     {      SaveBloadCount(NumberOfDefglobalModules);      SaveBloadCount(NumberOfDefglobals);     }        /*============================================*/   /* Set the count of defglobals and defglobals */   /* module data structures to zero.            */   /*============================================*/      NumberOfDefglobals = 0;   NumberOfDefglobalModules = 0;       for (theModule = (struct defmodule *) GetNextDefmodule(NULL);        theModule != NULL;        theModule = (struct defmodule *) GetNextDefmodule(theModule))     {      /*================================================*/      /* Set the current module to the module being     */      /* examined and increment the number of defglobal */      /* modules encountered.                           */      /*================================================*/      SetCurrentModule((VOID *) theModule);      NumberOfDefglobalModules++;               /*====================================================*/      /* Loop through each defglobal in the current module. */      /*====================================================*/        for (defglobalPtr = (struct defglobal *) GetNextDefglobal(NULL);           defglobalPtr != NULL;           defglobalPtr = (struct defglobal *) GetNextDefglobal(defglobalPtr))        {             /*======================================================*/         /* Initialize the construct header for the binary save. */         /*======================================================*/         MarkConstructHeaderNeededItems(&defglobalPtr->header,NumberOfDefglobals++);        }     }  }/*****************************************************//* BsaveStorage: Writes out storage requirements for *//*   all defglobal structures to the binary file     *//*****************************************************/static VOID BsaveStorage(fp)  FILE *fp;  {   unsigned long space;      /*===========================================================*/   /* Only two data structures are saved as part of a defglobal */   /* binary image: the defglobal data structure and the        */   /* defglobalModule data structure.                           */   /*===========================================================*/   space = sizeof(long) * 2;   GenWrite(&space,(unsigned long) sizeof(unsigned long int),fp);   GenWrite(&NumberOfDefglobals,(unsigned long) sizeof(long int),fp);   GenWrite(&NumberOfDefglobalModules,(unsigned long) sizeof(long int),fp);  }/*********************************************//* BsaveBinaryItem: Writes out all defglobal *//*   structures to the binary file           *//*********************************************/static VOID BsaveBinaryItem(fp)  FILE *fp;  {   unsigned long int space;   struct defglobal *theDefglobal;   struct bsaveDefglobal newDefglobal;   struct defmodule *theModule;   struct bsaveDefglobalModule tempDefglobalModule;   struct defglobalModule *theModuleItem;      /*==========================================================*/   /* Write out the amount of space taken up by the defglobal  */   /* and defglobalModule data structures in the binary image. */   /*==========================================================*/   space = NumberOfDefglobals * sizeof(struct bsaveDefglobal) +           (NumberOfDefglobalModules * sizeof(struct bsaveDefglobalModule));   GenWrite(&space,(unsigned long) sizeof(unsigned long int),fp);      /*=================================================*/   /* Write out each defglobal module data structure. */   /*=================================================*/   NumberOfDefglobals = 0;   for (theModule = (struct defmodule *) GetNextDefmodule(NULL);        theModule != NULL;        theModule = (struct defmodule *) GetNextDefmodule(theModule))     {      SetCurrentModule((VOID *) theModule);

⌨️ 快捷键说明

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