예제 #1
0
파일: filecom.c 프로젝트: ricksladkey/CLIPS
globle void CloseAllBatchSources(
  void *theEnv)
  {   
   /*================================================*/
   /* Free the batch buffer if it contains anything. */
   /*================================================*/

   if (FileCommandData(theEnv)->BatchBuffer != NULL)
     {
      if (FileCommandData(theEnv)->BatchCurrentPosition > 0) EnvPrintRouter(theEnv,"stdout",(char *) FileCommandData(theEnv)->BatchBuffer);
      rm(theEnv,FileCommandData(theEnv)->BatchBuffer,FileCommandData(theEnv)->BatchMaximumPosition);
      FileCommandData(theEnv)->BatchBuffer = NULL;
      FileCommandData(theEnv)->BatchCurrentPosition = 0;
      FileCommandData(theEnv)->BatchMaximumPosition = 0;
     }

   /*==========================*/
   /* Delete the batch router. */
   /*==========================*/

   EnvDeleteRouter(theEnv,"batch");

   /*=====================================*/
   /* Close each of the open batch files. */
   /*=====================================*/

   while (RemoveBatch(theEnv))
     { /* Do Nothing */ }
  }
예제 #2
0
globle intBool EnvDribbleOff(
    void *theEnv)
{
    int rv = 0;

    /*================================================*/
    /* Call the dribble status function. This is used */
    /* by some of the machine specific interfaces to  */
    /* do things such as changing the wording of menu */
    /* items from "Turn Dribble On..." to             */
    /* "Turn Dribble Off..."                          */
    /*================================================*/

    if (FileCommandData(theEnv)->DribbleStatusFunction != NULL)
    {
        (*FileCommandData(theEnv)->DribbleStatusFunction)(theEnv,FALSE);
    }

    /*=======================================*/
    /* Close the dribble file and deactivate */
    /* the dribble router.                   */
    /*=======================================*/

    if (FileCommandData(theEnv)->DribbleFP != NULL)
    {
        if (FileCommandData(theEnv)->DribbleCurrentPosition > 0)
        {
            fprintf(FileCommandData(theEnv)->DribbleFP,"%s",FileCommandData(theEnv)->DribbleBuffer);
        }
        EnvDeleteRouter(theEnv,(char*)"dribble");
        if (GenClose(theEnv,FileCommandData(theEnv)->DribbleFP) == 0) rv = 1;
    }
    else
    {
        rv = 1;
    }

    FileCommandData(theEnv)->DribbleFP = NULL;

    /*============================================*/
    /* Free the space used by the dribble buffer. */
    /*============================================*/

    if (FileCommandData(theEnv)->DribbleBuffer != NULL)
    {
        rm(theEnv,FileCommandData(theEnv)->DribbleBuffer,FileCommandData(theEnv)->DribbleMaximumPosition);
        FileCommandData(theEnv)->DribbleBuffer = NULL;
    }

    FileCommandData(theEnv)->DribbleCurrentPosition = 0;
    FileCommandData(theEnv)->DribbleMaximumPosition = 0;

    /*============================================*/
    /* Return TRUE if the dribble file was closed */
    /* without error, otherwise return FALSE.     */
    /*============================================*/

    return(rv);
}
예제 #3
0
파일: xclips.c 프로젝트: RenRenJuan/DACLIPS
/*******************************************************************************
          Name:        XclipsExit
          Description: exit CLIPS in case of abnormal exit 
          Arguments:   num - unused
          Returns:       
*******************************************************************************/
int XclipsExit(
  void *theEnv,
  int num)
  {
   EnvDribbleOff(theEnv);
   EnvDeleteRouter(theEnv,"wclips");
   XtDestroyApplicationContext(app_con);
   ReleaseLogTable();
   exit(0);
  }
예제 #4
0
static void DeactivateErrorCapture(
  void *theEnv)
  {   
   if (ParseFunctionData(theEnv)->ErrorString != NULL)
     {
      rm(theEnv,ParseFunctionData(theEnv)->ErrorString,ParseFunctionData(theEnv)->ErrorMaximumPosition);
      ParseFunctionData(theEnv)->ErrorString = NULL;
     }

   if (ParseFunctionData(theEnv)->WarningString != NULL)
     {
      rm(theEnv,ParseFunctionData(theEnv)->WarningString,ParseFunctionData(theEnv)->WarningMaximumPosition);
      ParseFunctionData(theEnv)->WarningString = NULL;
     }

   ParseFunctionData(theEnv)->ErrorCurrentPosition = 0;
   ParseFunctionData(theEnv)->ErrorMaximumPosition = 0;
   ParseFunctionData(theEnv)->WarningCurrentPosition = 0;
   ParseFunctionData(theEnv)->WarningMaximumPosition = 0;

   EnvDeleteRouter(theEnv,"error-capture");
  }
예제 #5
0
파일: filecom.c 프로젝트: ricksladkey/CLIPS
globle int LLGetcBatch(
  void *theEnv,
  char *logicalName,
  int returnOnEOF)
  {
   int rv = EOF, flag = 1;

   /*=================================================*/
   /* Get a character until a valid character appears */
   /* or no more batch files are left.                */
   /*=================================================*/

   while ((rv == EOF) && (flag == 1))
     {
      if (FileCommandData(theEnv)->BatchType == FILE_BATCH)
        { rv = getc((FILE *) FileCommandData(theEnv)->BatchSource); } 
      else
        { rv = EnvGetcRouter(theEnv,(char *) FileCommandData(theEnv)->BatchSource); }

      if (rv == EOF)
        {
         if (FileCommandData(theEnv)->BatchCurrentPosition > 0) EnvPrintRouter(theEnv,"stdout",(char *) FileCommandData(theEnv)->BatchBuffer);
         flag = RemoveBatch(theEnv);
        }
     }

   /*=========================================================*/
   /* If the character retrieved is an end-of-file character, */
   /* then there are no batch files with character input      */
   /* remaining. Remove the batch router.                     */
   /*=========================================================*/

   if (rv == EOF)
     {
      if (FileCommandData(theEnv)->BatchCurrentPosition > 0) EnvPrintRouter(theEnv,"stdout",(char *) FileCommandData(theEnv)->BatchBuffer);
      EnvDeleteRouter(theEnv,"batch");
      RemoveBatch(theEnv);
      if (returnOnEOF == TRUE)
        { return (EOF); }
      else
        { return(EnvGetcRouter(theEnv,logicalName)); }
     }

   /*========================================*/
   /* Add the character to the batch buffer. */
   /*========================================*/

   FileCommandData(theEnv)->BatchBuffer = ExpandStringWithChar(theEnv,(char) rv,FileCommandData(theEnv)->BatchBuffer,&FileCommandData(theEnv)->BatchCurrentPosition,
                                      &FileCommandData(theEnv)->BatchMaximumPosition,FileCommandData(theEnv)->BatchMaximumPosition+BUFFER_SIZE);

   /*======================================*/
   /* If a carriage return is encountered, */
   /* then flush the batch buffer.         */
   /*======================================*/

   if ((char) rv == '\n')
     {
      EnvPrintRouter(theEnv,"stdout",(char *) FileCommandData(theEnv)->BatchBuffer);
      FileCommandData(theEnv)->BatchCurrentPosition = 0;
      if ((FileCommandData(theEnv)->BatchBuffer != NULL) && (FileCommandData(theEnv)->BatchMaximumPosition > BUFFER_SIZE))
        {
         rm(theEnv,FileCommandData(theEnv)->BatchBuffer,FileCommandData(theEnv)->BatchMaximumPosition);
         FileCommandData(theEnv)->BatchMaximumPosition = 0;
         FileCommandData(theEnv)->BatchBuffer = NULL;
        }
     }

   /*=====================================================*/
   /* Return the character retrieved from the batch file. */
   /*=====================================================*/

   return(rv);
  }