Sindbad~EG File Manager

Current Path : /usr/home/beeson/Otter-Lambda/yyy/automode/
Upload File :
Current File : /usr/home/beeson/Otter-Lambda/yyy/automode/errbuf.c

/* M. Beeson for Mathpert
10.31.95
last modified 7.23.98
1.25.06 made comment_buffer and error_buffer static 
3.17.06 removed include heap.h 
*/

#define AUTOMODE_DLL
#include <string.h>
#include "export.h"
#include "terms.h"
#include "proverdl.h"   /* permalloc */
#include "errbuf.h"

/*______________________________________________________________________*/
#define ERRBUFLENGTH 128
static int stopflag;

static char comment_buffer[DIM_COMMENT_BUFFER][ERRBUFLENGTH];
   /* for comments generated during an operator's execution to be printed
      out after it's successully executed */
static char error_buffer[DIM_COMMENT_BUFFER][ERRBUFLENGTH];
   /* for comments generated during an operator's execution to be printed
      out after it fails.  This is done by errmsg()  */


/* The following functions enable access to these buffers by operations
which need to leave error messages or comments */

MEXPORT_AUTOMODE void errbuf(int i, const char *msg)
   { if(!stopflag)
         strncpy(error_buffer[i],msg,ERRBUFLENGTH);
   }

MEXPORT_AUTOMODE void commentbuf(int i, const char *msg)
   { if(!stopflag)
         strncpy(comment_buffer[i],msg,ERRBUFLENGTH);
   }

/*_________________________________________________________________*/
/* To turn off the comment/error mechanisms temporarily */
MEXPORT_AUTOMODE int GetCommentStop(void)
   { return stopflag;
   }
MEXPORT_AUTOMODE void SetCommentStop(int n)
   { stopflag = n;
   }


/*_________________________________________________________________*/
MEXPORT_AUTOMODE char * get_error_buffer(int i)
{ if(i < DIM_COMMENT_BUFFER)
     return error_buffer[i];
  return "";
}
/*_________________________________________________________________*/
MEXPORT_AUTOMODE void clear_error_buffer(void)
{ memset(error_buffer, 0, ERRBUFLENGTH *DIM_COMMENT_BUFFER);
}
/*_________________________________________________________________*/
MEXPORT_AUTOMODE char * get_comment_buffer(int i)
{ if(i < DIM_COMMENT_BUFFER)
     return comment_buffer[i];
  return "";
}
/*_________________________________________________________________*/
MEXPORT_AUTOMODE void clear_comment_buffer(void)
{ memset(comment_buffer, 0, ERRBUFLENGTH *DIM_COMMENT_BUFFER);
}
/*_________________________________________________________________*/
MEXPORT_AUTOMODE unsigned char *get_permanent_comment(void)
/* produce a copy on the document heap of
the comment in comment_buffer, if it begins with an
exclamation point (used to indicate it should become part
of the solution rather than a temporary message).
Return NULL if there is no such comment.
*/
{ int i,n;
  unsigned char *ans;
  char buf[(ERRBUFLENGTH + 1) * DIM_COMMENT_BUFFER];
  if(comment_buffer[0][0] != '!')
     return NULL;
  strcpy(buf,comment_buffer[0]+1);
  for(i=1;i<DIM_COMMENT_BUFFER; i++)
     { if(comment_buffer[i][0] == '\0')
          break;
       strcat(buf, " ");
       strncat(buf,comment_buffer[i],ERRBUFLENGTH);
     }
  n = strlen(buf)+1;
  ans = callocate(n, sizeof(char));
  strcpy((char *)ans, buf);
  return ans;
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists