www.pudn.com > calc.rar > trial.c


/* trial.c */ 
 
#define _CRT_SECURE_NO_DEPRECATE 
#include  
#include  
#include  
#include  
#include  
 
#include "integer.h" 
#include "fun.h" 
#include "primes.h" 
#define MAXLEN 1000 /* Maximum length of line */ 
 
char *progname; 
jmp_buf begin; 
 
#ifdef DEBUG 
extern long int nettbytes; 
#endif 
 
int main(int argc, char ** argv) 
{ 
  char *ns; 
  char *command; 
  static char quit_str[] = "exit"; 
  static char help_str[] = "help"; 
  int quit; 
  char *cps,*cpe; 
  int tty; 
 
  INITMPIBANK(); 
#ifdef UNIX 
  setlinebuf(stdout); 
#endif 
#ifdef DEBUG 
  printf("before testing: nettbytes = %ld\n", nettbytes); 
#endif 
  tty = isatty(0); 
  progname = argv[0]; 
  init(); /*intall functions in symbol table */ 
  if( argc ==2) { 
    int i; 
    char dummy[4096]; 
    for(i=0;i <4095;i++)dummy[i]=0; 
    strcpy(dummy,argv[1]); 
    for(i=0;i "); 
        if (scanf("%999[^\n]", ns) == EOF)break;	/* exit on end of file */ 
          strcpy(command,ns); 
          Flush();  
          cps=ns; 
          while(1)	{ 
             cpe=cps; 
             while(*cpe && *cpe!=';') 
             cpe++; 
             *cpe='\n'; 
             *(cpe+1)='\0'; 
             if (strncmp(cps, quit_str, 4) == 0){quit=1;break;} 
             if (strncmp(cps, help_str, 4) == 0){quit=2;break;} 
             Parse(cps); 
             strcpy(ns,command); 
             if(!(*cpe)) break;  
             cps=cpe+1; 
             while(*cps && (*cps==' ' || *cps=='\n')) 
               cps++; 
               if(!(*cps)) break; 
             }  
            if(quit==1) break; 
            if(quit==2){readme();continue;} 
    } 
  clean_symtab(); 
  FREEMPIBANK(); 
#ifdef DEBUG 
    /*  FREEBANKI(); */ 
  printf("after testing: nettbytes = %ld\n", nettbytes); 
#endif 
  exit(0); /* return success */ 
} 
 
int execerror(char *s, char *t){ 
  warning(s, t); 
  longjmp(begin, 0); 
} 
 
void warning(char *s, char *t){ 
  if (t)fprintf(stderr, "%s ", t); 
  fprintf(stderr, "%s\n", s); 
}