コード例 #1
0
ファイル: main.c プロジェクト: SOLARIC/world-opponent-network
void MyRoutingDataObjectWithLifespanCallback(WONRoutingDataObjectWithLifespan *theData, void *theUserParam)
{
	printf("DataObjectWithLifespan Callback: %s\n",(char*)theUserParam);
	printf("Lifespan: %d\n",theData->mLifespan);
	PrintDataObject(&theData->mObject);
	SetEvent(mEvent); printf("\n");
}
コード例 #2
0
ファイル: genrcexe.c プロジェクト: guitarpoet/php-clips
/***************************************************
  NAME         : DetermineRestrictionClass
  DESCRIPTION  : Finds the class of an argument in
                   the ProcParamArray
  INPUTS       : The argument data object
  RETURNS      : The class address, NULL if error
  SIDE EFFECTS : EvaluationError set on errors
  NOTES        : None
 ***************************************************/
static DEFCLASS *DetermineRestrictionClass(
  void *theEnv,
  DATA_OBJECT *dobj)
  {
   INSTANCE_TYPE *ins;
   DEFCLASS *cls;

   if (dobj->type == INSTANCE_NAME)
     {
      ins = FindInstanceBySymbol(theEnv,(SYMBOL_HN *) dobj->value);
      cls = (ins != NULL) ? ins->cls : NULL;
     }
   else if (dobj->type == INSTANCE_ADDRESS)
     {
      ins = (INSTANCE_TYPE *) dobj->value;
      cls = (ins->garbage == 0) ? ins->cls : NULL;
     }
   else
     return(DefclassData(theEnv)->PrimitiveClassMap[dobj->type]);
   if (cls == NULL)
     {
      EnvSetEvaluationError(theEnv,true);
      PrintErrorID(theEnv,"GENRCEXE",3,false);
      EnvPrintRouter(theEnv,WERROR,"Unable to determine class of ");
      PrintDataObject(theEnv,WERROR,dobj);
      EnvPrintRouter(theEnv,WERROR," in generic function ");
      EnvPrintRouter(theEnv,WERROR,EnvGetDefgenericName(theEnv,(void *) DefgenericData(theEnv)->CurrentGeneric));
      EnvPrintRouter(theEnv,WERROR,".\n");
     }
   return(cls);
  }
コード例 #3
0
ファイル: main.c プロジェクト: SOLARIC/world-opponent-network
void MyRoutingDataObjectModificationCallback(WONRoutingDataObjectModification *theData, void *theUserParam)
{
	printf("DataObjectModification Callback: %s\n",(char*)theUserParam);
	printf("IsInsert: %d\n",theData->mIsInsert);
	printf("Offset: %d\n",theData->mOffset);
	PrintDataObject(&theData->mObject);
	SetEvent(mEvent); printf("\n");
}
コード例 #4
0
ファイル: globlcom.c プロジェクト: femto/rbclips
static void PrintDefglobalValueForm(
  void *theEnv,
  char *logicalName,
  void *vTheGlobal)
  {
   struct defglobal *theGlobal = (struct defglobal *) vTheGlobal;

   EnvPrintRouter(theEnv,logicalName,"?*");
   EnvPrintRouter(theEnv,logicalName,ValueToString(theGlobal->header.name));
   EnvPrintRouter(theEnv,logicalName,"* = ");
   PrintDataObject(theEnv,logicalName,&theGlobal->current);
  }
コード例 #5
0
ファイル: main.c プロジェクト: SOLARIC/world-opponent-network
void MyRoutingReadDataObjectCallback(WONRoutingReadDataObjectResult *theObjects, void *theUserParam)
{
	unsigned int i;

	printf("ReadDataObject Callback: %s\n",(char*)theUserParam);
	printf("Status: %d\n",theObjects->mStatus);
	printf("Objects:\n\n");
	for(i=0; i<theObjects->mNumObjects; i++)
	{
		PrintDataObject(&theObjects->mObjects[i]);
		printf("\n");
	}
	SetEvent(mEvent); printf("\n");
}
コード例 #6
0
ファイル: globldef.c プロジェクト: femto/rbclips
globle void EnvGetDefglobalValueForm(
  void *theEnv,
  char *buffer,
  unsigned bufferLength,
  void *vTheGlobal)
  {
   struct defglobal *theGlobal = (struct defglobal *) vTheGlobal;

   OpenStringDestination(theEnv,"GlobalValueForm",buffer,bufferLength);
   EnvPrintRouter(theEnv,"GlobalValueForm","?*");
   EnvPrintRouter(theEnv,"GlobalValueForm",ValueToString(theGlobal->header.name));
   EnvPrintRouter(theEnv,"GlobalValueForm","* = ");
   PrintDataObject(theEnv,"GlobalValueForm",&theGlobal->current);
   CloseStringDestination(theEnv,"GlobalValueForm");
  }
コード例 #7
0
ファイル: globldef.c プロジェクト: femto/rbclips
globle void QSetDefglobalValue(
  void *theEnv,
  struct defglobal *theGlobal,
  DATA_OBJECT_PTR vPtr,
  int resetVar)
  {
   /*====================================================*/
   /* If the new value passed for the defglobal is NULL, */
   /* then reset the defglobal to the initial value it   */
   /* had when it was defined.                           */
   /*====================================================*/

   if (resetVar)
     {
      EvaluateExpression(theEnv,theGlobal->initial,vPtr);
      if (EvaluationData(theEnv)->EvaluationError)
        {
         vPtr->type = SYMBOL;
         vPtr->value = EnvFalseSymbol(theEnv);
        }
     }

   /*==========================================*/
   /* If globals are being watch, then display */
   /* the change to the global variable.       */
   /*==========================================*/

#if DEBUGGING_FUNCTIONS
   if (theGlobal->watch)
     {
      EnvPrintRouter(theEnv,WTRACE,":== ?*");
      EnvPrintRouter(theEnv,WTRACE,ValueToString(theGlobal->header.name));
      EnvPrintRouter(theEnv,WTRACE,"* ==> ");
      PrintDataObject(theEnv,WTRACE,vPtr);
      EnvPrintRouter(theEnv,WTRACE," <== ");
      PrintDataObject(theEnv,WTRACE,&theGlobal->current);
      EnvPrintRouter(theEnv,WTRACE,"\n");
     }
#endif

   /*==============================================*/
   /* Remove the old value of the global variable. */
   /*==============================================*/

   ValueDeinstall(theEnv,&theGlobal->current);
   if (theGlobal->current.type == MULTIFIELD)
     { ReturnMultifield(theEnv,(struct multifield *) theGlobal->current.value); }

   /*===========================================*/
   /* Set the new value of the global variable. */
   /*===========================================*/

   theGlobal->current.type = vPtr->type;
   if (vPtr->type != MULTIFIELD) theGlobal->current.value = vPtr->value;
   else DuplicateMultifield(theEnv,&theGlobal->current,vPtr);
   ValueInstall(theEnv,&theGlobal->current);

   /*===========================================*/
   /* Set the variable indicating that a change */
   /* has been made to a global variable.       */
   /*===========================================*/

   DefglobalData(theEnv)->ChangeToGlobals = TRUE;

   if ((EvaluationData(theEnv)->CurrentEvaluationDepth == 0) && (! CommandLineData(theEnv)->EvaluatingTopLevelCommand) &&
       (EvaluationData(theEnv)->CurrentExpression == NULL))
     { PeriodicCleanup(theEnv,TRUE,FALSE); }
  }
コード例 #8
0
ファイル: commline.c プロジェクト: guitarpoet/php-clips
bool RouteCommand(
  void *theEnv,
  const char *command,
  bool printResult)
  {
   DATA_OBJECT result;
   struct expr *top;
   const char *commandName;
   struct token theToken;
   int danglingConstructs;

   if (command == NULL)
     { return(0); }

   /*========================================*/
   /* Open a string input source and get the */
   /* first token from that source.          */
   /*========================================*/

   OpenStringSource(theEnv,"command",command,0);

   GetToken(theEnv,"command",&theToken);

   /*=====================*/
   /* Evaluate constants. */
   /*=====================*/

   if ((theToken.type == SYMBOL) || (theToken.type == STRING) ||
       (theToken.type == FLOAT) || (theToken.type == INTEGER) ||
       (theToken.type == INSTANCE_NAME))
     {
      CloseStringSource(theEnv,"command");
      if (printResult)
        {
         PrintAtom(theEnv,STDOUT,theToken.type,theToken.value);
         EnvPrintRouter(theEnv,STDOUT,"\n");
        }
      return(1);
     }

   /*=====================*/
   /* Evaluate variables. */
   /*=====================*/

   if ((theToken.type == GBL_VARIABLE) ||
       (theToken.type == SF_VARIABLE) ||
       (theToken.type == MF_VARIABLE))
     {
      CloseStringSource(theEnv,"command");
      top = GenConstant(theEnv,theToken.type,theToken.value);
      EvaluateExpression(theEnv,top,&result);
      rtn_struct(theEnv,expr,top);
      if (printResult)
        {
         PrintDataObject(theEnv,STDOUT,&result);
         EnvPrintRouter(theEnv,STDOUT,"\n");
        }
      return(1);
     }

   /*========================================================*/
   /* If the next token isn't the beginning left parenthesis */
   /* of a command or construct, then whatever was entered   */
   /* cannot be evaluated at the command prompt.             */
   /*========================================================*/

   if (theToken.type != LPAREN)
     {
      PrintErrorID(theEnv,"COMMLINE",1,false);
      EnvPrintRouter(theEnv,WERROR,"Expected a '(', constant, or variable\n");
      CloseStringSource(theEnv,"command");
      return(0);
     }

   /*===========================================================*/
   /* The next token must be a function name or construct type. */
   /*===========================================================*/

   GetToken(theEnv,"command",&theToken);
   if (theToken.type != SYMBOL)
     {
      PrintErrorID(theEnv,"COMMLINE",2,false);
      EnvPrintRouter(theEnv,WERROR,"Expected a command.\n");
      CloseStringSource(theEnv,"command");
      return(0);
     }

   commandName = ValueToString(theToken.value);

   /*======================*/
   /* Evaluate constructs. */
   /*======================*/

#if (! RUN_TIME) && (! BLOAD_ONLY)
   {
    int errorFlag;

    errorFlag = ParseConstruct(theEnv,commandName,"command");
    if (errorFlag != -1)
      {
       CloseStringSource(theEnv,"command");
       if (errorFlag == 1)
         {
          EnvPrintRouter(theEnv,WERROR,"\nERROR:\n");
          PrintInChunks(theEnv,WERROR,GetPPBuffer(theEnv));
          EnvPrintRouter(theEnv,WERROR,"\n");
         }
       DestroyPPBuffer(theEnv);
       if (errorFlag) return 0;
       else return 1;
      }
   }
#endif

   /*========================*/
   /* Parse a function call. */
   /*========================*/

   danglingConstructs = ConstructData(theEnv)->DanglingConstructs;
   CommandLineData(theEnv)->ParsingTopLevelCommand = true;
   top = Function2Parse(theEnv,"command",commandName);
   CommandLineData(theEnv)->ParsingTopLevelCommand = false;
   ClearParsedBindNames(theEnv);

   /*================================*/
   /* Close the string input source. */
   /*================================*/

   CloseStringSource(theEnv,"command");

   /*=========================*/
   /* Evaluate function call. */
   /*=========================*/

   if (top == NULL)
     {
      ConstructData(theEnv)->DanglingConstructs = danglingConstructs;
      return false;
     }
   
   ExpressionInstall(theEnv,top);
   
   CommandLineData(theEnv)->EvaluatingTopLevelCommand = true;
   CommandLineData(theEnv)->CurrentCommand = top;
   EvaluateExpression(theEnv,top,&result);
   CommandLineData(theEnv)->CurrentCommand = NULL;
   CommandLineData(theEnv)->EvaluatingTopLevelCommand = false;
   
   ExpressionDeinstall(theEnv,top);
   ReturnExpression(theEnv,top);
   ConstructData(theEnv)->DanglingConstructs = danglingConstructs;
   
   /*=================================================*/
   /* Print the return value of the function/command. */
   /*=================================================*/
   
   if ((result.type != RVOID) && printResult)
     {
      PrintDataObject(theEnv,STDOUT,&result);
      EnvPrintRouter(theEnv,STDOUT,"\n");
     }

   return true;
  }
コード例 #9
0
ファイル: tmpltutl.c プロジェクト: ahmed-masud/FuzzyCLIPS
globle void CheckTemplateFact(
  struct fact *theFact)
  {
   struct field *sublist;
   int i;
   struct deftemplate *theDeftemplate;
   struct templateSlot *slotPtr;
   DATA_OBJECT theData;
   char thePlace[20];
   int rv;

   if (! GetDynamicConstraintChecking()) return;

   sublist = theFact->theProposition.theFields;

   /*========================================================*/
   /* If the deftemplate corresponding to the first field of */
   /* of the fact cannot be found, then the fact cannot be   */
   /* checked against the deftemplate format.                */
   /*========================================================*/

   theDeftemplate = theFact->whichDeftemplate;
   if (theDeftemplate == NULL) return;
   if (theDeftemplate->implied) return;

   /*=============================================*/
   /* Check each of the slots of the deftemplate. */
   /*=============================================*/

   i = 0;
   for (slotPtr = theDeftemplate->slotList;
        slotPtr != NULL;
        slotPtr = slotPtr->next)
     {
      /*================================================*/
      /* Store the slot value in the appropriate format */
      /* for a call to the constraint checking routine. */
      /*================================================*/

      if (slotPtr->multislot == FALSE)
        {
         theData.type = sublist[i].type;
         theData.value = sublist[i].value;
         i++;
        }
      else
        {
         theData.type = MULTIFIELD;
         theData.value = (void *) sublist[i].value;
         theData.begin = 0;
         theData.end = ((struct multifield *) sublist[i].value)->multifieldLength-1;
         i++;
        }

      /*=============================================*/
      /* Call the constraint checking routine to see */
      /* if a constraint violation occurred.         */
      /*=============================================*/

      rv = ConstraintCheckDataObject(&theData,slotPtr->constraints);
      if (rv != NO_VIOLATION)
        {
         sprintf(thePlace,"fact f-%-5ld ",theFact->factIndex);

         PrintErrorID("CSTRNCHK",1,TRUE);
         PrintRouter(WERROR,"Slot value ");
         PrintDataObject(WERROR,&theData);
         PrintRouter(WERROR," ");
         ConstraintViolationErrorMessage(NULL,thePlace,FALSE,0,slotPtr->slotName,
                                         0,rv,slotPtr->constraints,TRUE);
         SetHaltExecution(TRUE);
         return;
        }
     }

   return;
  }
コード例 #10
0
ファイル: main.c プロジェクト: SOLARIC/world-opponent-network
void MyRoutingDataObjectCallback(WONRoutingDataObject *theData, void *theUserParam)
{
	printf("DataObject Callback: %s\n",(char*)theUserParam);
	PrintDataObject(theData);
	SetEvent(mEvent); printf("\n");
}
コード例 #11
0
ファイル: clipsdde.c プロジェクト: atrniv/CLIPS
HDDEDATA CALLBACK DDECallBack(  
  UINT uType,
  UINT uFmt,
  HCONV hconv,
  HSZ hsz1,
  HSZ hsz2,
  HDDEDATA hData,
  DWORD dwData1,
  DWORD dwData2)
  {  
#if MAC_MCW || WIN_MCW || MAC_XCD
#pragma unused(hconv)
#pragma unused(dwData1)
#pragma unused(dwData2)
#endif

   extern HSZ hszService; 
   extern char CompleteString[255];
   DWORD size;
   HWND hWnd;
   char *TheData;
   char *Data;
   char *theString;
   void *theEnv = GetCurrentEnvironment();
   
   /* 
   char theBuffer[100];
   DWORD cb; 
   PSTR pszTopicName; 
   */
      
   switch (uType)
     {  
      case XTYP_ADVDATA:
      case XTYP_POKE:
        return ((HDDEDATA) DDE_FNOTPROCESSED);
        
      case XTYP_ADVREQ:
      case XTYP_WILDCONNECT:
        return ((HDDEDATA) NULL);
        
      case XTYP_ADVSTART:
      case XTYP_ADVSTOP:
      case XTYP_CONNECT_CONFIRM:
      case XTYP_DISCONNECT:
      case XTYP_ERROR:
      case XTYP_REGISTER:
      case XTYP_UNREGISTER:
      case XTYP_XACT_COMPLETE:
        return ((HDDEDATA) FALSE);
        
      case XTYP_MONITOR:
        return ((HDDEDATA) TRUE);
                        
      case XTYP_CONNECT:
/*
        cb = DdeQueryString(idInst,hsz1,(LPSTR) NULL, 0,CP_WINANSI) + 1; 
        pszTopicName = (PSTR) LocalAlloc(LPTR, (UINT) cb); 
        DdeQueryString(idInst,hsz1, pszTopicName,cb,CP_WINANSI); 
        
        cb = DdeQueryString(idInst,hsz2,(LPSTR) NULL, 0,CP_WINANSI) + 1; 
        pszTopicName = (PSTR) LocalAlloc(LPTR, (UINT) cb); 
        DdeQueryString(idInst,hsz2, pszTopicName,cb,CP_WINANSI); 
*/
        DDE_RV.type = RVOID;
        if (hsz2 != hszService)
          { return ((HDDEDATA) FALSE); }
          
        return((HDDEDATA) TRUE);
        
      /*--------------------------------------------------+
      | Get completed command and return result to client |
      +--------------------------------------------------*/
      
      case XTYP_REQUEST:

        if (uFmt != CF_TEXT)
          { return(NULL); }
        
        /* sprintf(theBuffer,"XTYP_REQUEST uFmt = %d\n",(int) uFmt);
        PrintRouter(WDISPLAY,theBuffer); */
       
        hData = NULL;

        if (hsz1 == hszCommand)
          {
           theString = DataObjectToString(GetCurrentEnvironment(),&DDE_RV);

           hData = DdeCreateDataHandle (idInst,
                                        (unsigned char *) theString,
                                        strlen(theString)+1,
                                        0L, hsz2,CF_TEXT,0);
          }
          
        return (hData);
      
      case XTYP_EXECUTE:
        SetFocus(DialogWindow);

        if (CommandLineData(GetCurrentEnvironment())->EvaluatingTopLevelCommand || 
            BatchActive(GetCurrentEnvironment()) )
          { return ((HDDEDATA) DDE_FBUSY  ); }

        Data = (char *) DdeAccessData ( hData, NULL);
        size = strlen((char *) Data) + 1;

        TheData = (char *) genalloc ( GetCurrentEnvironment(),(unsigned) size );
        DdeGetData ( hData, (LPBYTE)TheData, size, 0L );
        
        EnvPrintRouter(theEnv,WPROMPT,TheData);
        EnvPrintRouter(theEnv,WPROMPT,"\n");
        
        EnvEval(theEnv,TheData,&DDE_RV);
        
        if (DDE_RV.type != RVOID)
          {
           PrintDataObject(GetCurrentEnvironment(),"stdout",&DDE_RV);
           EnvPrintRouter(theEnv,"stdout","\n");
          }
        
        PrintPrompt(theEnv);
        
        DdeUnaccessData(hData);
       
        hWnd = FindWindow("ClipsEditWClass", NULL);
        SetFocus (hWnd);
        return ((HDDEDATA) DDE_FACK);

   }
   
   return ( (HDDEDATA) TRUE );
}