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

📄 msgcom.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 3 页
字号:
     PrintHandler(log,&plinks->classArray[index]->handlers[i],CLIPS_TRUE);   return(cnt);  }#endif/* =========================================   *****************************************          INTERNALLY VISIBLE FUNCTIONS   =========================================   ***************************************** */#if ! RUN_TIME   /**********************************************************  NAME         : CreateSystemHandlers  DESCRIPTION  : Attachess the system message-handlers                 after a (clear)  INPUTS       : None  RETURNS      : Nothing useful  SIDE EFFECTS : System handlers created  NOTES        : Must be called after CreateSystemClasses() **********************************************************/static VOID CreateSystemHandlers()  {   NewSystemHandler(USER_TYPE_NAME,INIT_STRING,"init-slots",0);   NewSystemHandler(USER_TYPE_NAME,DELETE_STRING,"delete-instance",0);#if DEBUGGING_FUNCTIONS   NewSystemHandler(USER_TYPE_NAME,PRINT_STRING,"ppinstance",0);#endif   NewSystemHandler(USER_TYPE_NAME,DIRECT_MODIFY_STRING,"(direct-modify)",1);   NewSystemHandler(USER_TYPE_NAME,MSG_MODIFY_STRING,"(message-modify)",1);   NewSystemHandler(USER_TYPE_NAME,DIRECT_DUPLICATE_STRING,"(direct-duplicate)",2);   NewSystemHandler(USER_TYPE_NAME,MSG_DUPLICATE_STRING,"(message-duplicate)",2);  }#endif#if (! BLOAD_ONLY) && (! RUN_TIME)/************************************************************  NAME         : WildDeleteHandler  DESCRIPTION  : Deletes a handler from a class  INPUTS       : 1) Class address (Can be NULL)                 2) Message Handler Name (Can be NULL)                 3) Type name ("primary", etc.)  RETURNS      : 1 if successful, 0 otherwise  SIDE EFFECTS : Handler deleted if possible  NOTES        : None ************************************************************/static int WildDeleteHandler(cls,msym,tname)  DEFCLASS *cls;  SYMBOL_HN *msym;  char *tname;  {   int mtype;      if (msym == NULL)     msym = (SYMBOL_HN *) AddSymbol("*");   if (tname != NULL)     {      mtype = HandlerType("undefmessage-handler",tname);      if (mtype == MERROR)        return(0);     }   else     mtype = -1;   if (cls == NULL)     {      int success = 1;           for (cls = (DEFCLASS *) GetNextDefclass(NULL) ;           cls != NULL ;           cls = (DEFCLASS *) GetNextDefclass((VOID *) cls))        if (DeleteHandler(cls,msym,mtype,CLIPS_FALSE) == 0)          success = 0;      return(success);     }   return(DeleteHandler(cls,msym,mtype,CLIPS_TRUE));  }#endif#if DEBUGGING_FUNCTIONS/******************************************************************  NAME         : DefmessageHandlerWatchAccess  DESCRIPTION  : Parses a list of class names passed by                 AddWatchItem() and sets the traces accordingly  INPUTS       : 1) A code indicating which trace flag is to be set                    0 - Watch instance creation/deletion                    1 - Watch slot changes to instances                 2) The value to which to set the trace flags                 3) A list of expressions containing the names                    of the classes for which to set traces  RETURNS      : CLIPS_TRUE if all OK, CLIPS_FALSE otherwise  SIDE EFFECTS : Watch flags set in specified classes  NOTES        : Accessory function for AddWatchItem() ******************************************************************/#if IBM_TBC#pragma argsused#endifstatic BOOLEAN DefmessageHandlerWatchAccess(code,newState,argExprs)  int code,newState;  EXPRESSION *argExprs;  {#if MAC_MPW || MAC_MCW#pragma unused(code)#endif   return(DefmessageHandlerWatchSupport(newState ? "watch" : "unwatch",NULL,newState,                                        NULL,SetDefmessageHandlerWatch,argExprs));  }  /***********************************************************************  NAME         : DefclassWatchPrint  DESCRIPTION  : Parses a list of class names passed by                 AddWatchItem() and displays the traces accordingly  INPUTS       : 1) The logical name of the output                 2) A code indicating which trace flag is to be examined                    0 - Watch instance creation/deletion                    1 - Watch slot changes to instances                 3) A list of expressions containing the names                    of the classes for which to examine traces  RETURNS      : CLIPS_TRUE if all OK, CLIPS_FALSE otherwise  SIDE EFFECTS : Watch flags displayed for specified classes  NOTES        : Accessory function for AddWatchItem() ***********************************************************************/#if IBM_TBC#pragma argsused#endifstatic BOOLEAN DefmessageHandlerWatchPrint(log,code,argExprs)  char *log;  int code;  EXPRESSION *argExprs;  {#if MAC_MPW || MAC_MCW#pragma unused(code)#endif   return(DefmessageHandlerWatchSupport("list-watch-items",log,-1,                                        PrintHandlerWatchFlag,NULL,argExprs));  }/*******************************************************  NAME         : DefmessageHandlerWatchSupport  DESCRIPTION  : Sets or displays handlers specified  INPUTS       : 1) The calling function name                 2) The logical output name for displays                    (can be NULL)                 4) The new set state (can be -1)                 5) The print function (can be NULL)                 6) The trace function (can be NULL)                 7) The handlers expression list  RETURNS      : CLIPS_TRUE if all OK,                 CLIPS_FALSE otherwise  SIDE EFFECTS : Handler trace flags set or displayed  NOTES        : None *******************************************************/static BOOLEAN DefmessageHandlerWatchSupport(funcName,log,newState,printFunc,traceFunc,argExprs)  char *funcName,*log;  int newState;#if ANSI_COMPILER  VOID (*printFunc)(char *,VOID *,unsigned);  VOID (*traceFunc)(int,VOID *,unsigned);#else  VOID (*printFunc)();  VOID (*traceFunc)();#endif  EXPRESSION *argExprs;  {   struct defmodule *theModule;   VOID *theClass;   char *theHandlerStr;   int theType;   int argIndex = 2;   DATA_OBJECT tmpData;      /* ===============================      If no handlers are specified,      show the trace for all handlers      in all handlers      =============================== */   if (argExprs == NULL)     {      SaveCurrentModule();      theModule = (struct defmodule *) GetNextDefmodule(NULL);      while (theModule != NULL)        {         SetCurrentModule((VOID *) theModule);         if (traceFunc == NULL)           {            PrintCLIPS(log,GetDefmoduleName((VOID *) theModule));            PrintCLIPS(log,":\n");           }         theClass = GetNextDefclass(NULL);         while (theClass != NULL)            {             if (WatchClassHandlers(theClass,NULL,-1,log,newState,                                    CLIPS_TRUE,printFunc,traceFunc) == CLIPS_FALSE)                 return(CLIPS_FALSE);             theClass = GetNextDefclass(theClass);            }          theModule = (struct defmodule *) GetNextDefmodule((VOID *) theModule);         }      RestoreCurrentModule();      return(CLIPS_TRUE);     }        /* ================================================      Set or show the traces for the specified handler      ================================================ */   while (argExprs != NULL)     {      if (EvaluateExpression(argExprs,&tmpData))        return(CLIPS_FALSE);      if (tmpData.type != SYMBOL)        {         ExpectedTypeError1(funcName,argIndex,"class name");         return(CLIPS_FALSE);        }      theClass = (VOID *) LookupDefclassByMdlOrScope(DOToString(tmpData));      if (theClass == NULL)        {         ExpectedTypeError1(funcName,argIndex,"class name");         return(CLIPS_FALSE);        }      if (GetNextArgument(argExprs) != NULL)        {         argExprs = GetNextArgument(argExprs);         argIndex++;         if (EvaluateExpression(argExprs,&tmpData))           return(CLIPS_FALSE);         if (tmpData.type != SYMBOL)           {            ExpectedTypeError1(funcName,argIndex,"handler name");            return(CLIPS_FALSE);           }         theHandlerStr = DOToString(tmpData);         if (GetNextArgument(argExprs) != NULL)           {            argExprs = GetNextArgument(argExprs);            argIndex++;            if (EvaluateExpression(argExprs,&tmpData))              return(CLIPS_FALSE);            if (tmpData.type != SYMBOL)              {               ExpectedTypeError1(funcName,argIndex,"handler type");               return(CLIPS_FALSE);              }            if ((theType = HandlerType(funcName,DOToString(tmpData))) == MERROR)              return(CLIPS_FALSE);           }         else           theType = -1;        }      else        {         theHandlerStr = NULL;         theType = -1;        }      if (WatchClassHandlers(theClass,theHandlerStr,theType,log,                             newState,CLIPS_FALSE,printFunc,traceFunc) == CLIPS_FALSE)        {         ExpectedTypeError1(funcName,argIndex,"handler");         return(CLIPS_FALSE);        }      argIndex++;      argExprs = GetNextArgument(argExprs);     }   return(CLIPS_TRUE);  }/*******************************************************  NAME         : WatchClassHandlers  DESCRIPTION  : Sets or displays handlers specified  INPUTS       : 1) The class                 2) The handler name (or NULL wildcard)                 3) The handler type (or -1 wildcard)                 4) The logical output name for displays                    (can be NULL)                 5) The new set state (can be -1)                 6) The print function (can be NULL)                 7) The trace function (can be NULL)  RETURNS      : CLIPS_TRUE if all OK,                 CLIPS_FALSE otherwise  SIDE EFFECTS : Handler trace flags set or displayed  NOTES        : None *******************************************************/static BOOLEAN WatchClassHandlers(theClass,theHandlerStr,theType,                                  log,newState,indentp,printFunc,traceFunc)  char *log,*theHandlerStr;  VOID *theClass;  int theType,newState,indentp;#if ANSI_COMPILER  VOID (*printFunc)(char *,VOID *,unsigned);  VOID (*traceFunc)(int,VOID *,unsigned);#else  VOID (*printFunc)();  VOID (*traceFunc)();#endif  {   unsigned theHandler;   int found = CLIPS_FALSE;      theHandler = GetNextDefmessageHandler(theClass,0);   while (theHandler != 0)     {      if ((theType == -1) ? CLIPS_TRUE :          (theType == ((DEFCLASS *) theClass)->handlers[theHandler-1].type))        {         if ((theHandlerStr == NULL) ? CLIPS_TRUE :             (strcmp(theHandlerStr,GetDefmessageHandlerName(theClass,theHandler)) == 0))            {             if (traceFunc != NULL)               (*traceFunc)(newState,theClass,theHandler);             else               {                if (indentp)                  PrintCLIPS(log,"   ");                (*printFunc)(log,theClass,theHandler);               }             found = CLIPS_TRUE;            }        }      theHandler = GetNextDefmessageHandler(theClass,theHandler);     }   if ((theHandlerStr != NULL) && (theType != -1) && (found == CLIPS_FALSE))     return(CLIPS_FALSE);   return(CLIPS_TRUE);  }  /***************************************************  NAME         : PrintHandlerWatchFlag  DESCRIPTION  : Displays trace value for handler  INPUTS       : 1) The logical name of the output                 2) The class                 3) The handler index  RETURNS      : Nothing useful  SIDE EFFECTS : None  NOTES        : None ***************************************************/static VOID PrintHandlerWatchFlag(log,theClass,theHandler)  char *log;  VOID *theClass;  unsigned theHandler;  {   PrintCLIPS(log,GetDefclassName(theClass));   PrintCLIPS(log," ");   PrintCLIPS(log,GetDefmessageHandlerName(theClass,theHandler));   PrintCLIPS(log," ");   PrintCLIPS(log,GetDefmessageHandlerType(theClass,theHandler));   PrintCLIPS(log,GetDefmessageHandlerWatch(theClass,theHandler) ? " = on\n" : " = off\n");  }  #endif /* DEBUGGING_FUNCTIONS */  #endif/***************************************************  NAME         :   DESCRIPTION  :   INPUTS       :   RETURNS      :   SIDE EFFECTS :   NOTES        :  ***************************************************/

⌨️ 快捷键说明

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