[BACK]Return to load.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / parse

Diff for /OpenXM_contrib2/asir2000/parse/load.c between version 1.6 and 1.12

version 1.6, 2001/08/20 09:03:27 version 1.12, 2004/03/05 08:34:43
Line 45 
Line 45 
  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,   * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.   * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
  *   *
  * $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.5 2000/11/10 08:28:53 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.11 2004/03/02 08:28:49 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
Line 74 
Line 74 
 #include <io.h>  #include <io.h>
 #endif  #endif
   
   #ifdef MALLOC
 #undef MALLOC  #undef MALLOC
 #define MALLOC(x) GC_malloc((x)+4)  #define MALLOC(x) GC_malloc((x)+4)
   #endif
   
 char *ASIRLOADPATH[32];  char *ASIRLOADPATH[32];
   
 void encrypt_file(char *,char *);  
 void decrypt_file(char *,char *);  
   
 #if defined(VISUAL)  #if defined(VISUAL)
 #define ENVDELIM ';'  #define ENVDELIM ';'
 #define MORE "more < "  #define MORE "more < "
Line 95  void decrypt_file(char *,char *);
Line 94  void decrypt_file(char *,char *);
 #endif  #endif
   
 char *getenv();  char *getenv();
   void Pget_rootdir();
   char *search_executable(char *name);
   
 extern char *asir_libdir;  extern char *asir_libdir;
 extern char *asir_pager;  extern char *asir_pager;
 extern int read_exec_file;  extern int read_exec_file;
 extern int main_parser;  extern int main_parser;
 extern jmp_buf exec_env;  extern JMP_BUF exec_env;
   
   char *search_executable(char *name)
   {
           char *c,*s,*ret;
           int len,nlen;
           char dir[BUFSIZ],path[BUFSIZ];
           struct stat buf;
   
           nlen = strlen(name);
           for ( s = (char *)getenv("PATH"); s; ) {
                   c = (char *)index(s,':');
                   len = c ? c-s : strlen(dir);
                   if ( len >= BUFSIZ ) continue;
                   strncpy(dir,s,len); dir[len] = 0;
                   if ( c ) s = c+1;
                   else s = 0;
                   if ( len+nlen+1 >= BUFSIZ ) continue;
                   sprintf(path,"%s/%s",dir,name);
                   if ( !stat(path,&buf) && !(buf.st_mode & S_IFDIR)
                           && !access(path,X_OK) ) {
                           len = strlen(path)+1;
                           ret = (char *)MALLOC(len);
                           strcpy(ret,path);
                           return ret;
                   }
           }
           return 0;
   }
   
 void env_init() {  void env_init() {
         char *e,*p,*q;          char *e,*p,*q;
         int i,l;          int i,l,japanese;
         char *getenv();          char *getenv();
         char *oxhome;          char *oxhome;
         char rootname[BUFSIZ];          char rootname[BUFSIZ];
Line 124  void env_init() {
Line 154  void env_init() {
                 }                  }
         }          }
         if ( !(asir_pager = getenv("PAGER")) ) {          if ( !(asir_pager = getenv("PAGER")) ) {
                 asir_pager = (char *)malloc(strlen(MORE)+1);                  japanese = 0;
                 strcpy(asir_pager,MORE);                  if ( (e = getenv("LANGUAGE")) &&
                           (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1;
                   else if ( (e = getenv("LC_ALL")) &&
                           (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1;
                   else if ( (e = getenv("LC_CTYPE")) &&
                           (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1;
                   else if ( (e = getenv("LANG")) &&
                           (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1;
                   if ( japanese )
                           asir_pager = search_executable("jless");
                   if ( !asir_pager ) {
                           /* default: more */
                           asir_pager = (char *)malloc(strlen(MORE)+1);
                           strcpy(asir_pager,MORE);
                   }
         }          }
         if ( e = getenv("ASIRLOADPATH" ) )          if ( e = getenv("ASIRLOADPATH" ) )
                 for ( i = 0; ; i++, e = p+1 ) {                  for ( i = 0; ; i++, e = p+1 ) {
Line 141  void env_init() {
Line 185  void env_init() {
         ASIRLOADPATH[i] = asir_libdir;          ASIRLOADPATH[i] = asir_libdir;
 }  }
   
 void searchasirpath(name,pathp)  void searchasirpath(char *name,char **pathp)
 char *name;  
 char **pathp;  
 {  {
         char **p;          char **p;
         char *q;          char *q;
Line 195  char **pathp;
Line 237  char **pathp;
   
 #define DELIM '/'  #define DELIM '/'
   
 void Eungetc(int,FILE *);  void loadasirfile(char *name0)
   
 void loadasirfile(name0)  
 char *name0;  
 {  {
         FILE *in;          FILE *in;
         IN t;          INFILE t;
         extern char cppname[];          extern char cppname[];
 #if defined(VISUAL)  #if defined(VISUAL)
         char ibuf1[BUFSIZ],ibuf2[BUFSIZ];          char ibuf1[BUFSIZ],ibuf2[BUFSIZ];
         int ac;          int ac;
         char *av[BUFSIZ];          char *av[BUFSIZ];
         char *p,*c;          char *p;
         FILE *fp;          FILE *fp;
         char dname[BUFSIZ],tname0[BUFSIZ];          char dname[BUFSIZ],tname0[BUFSIZ];
         char *name,*tname;          char *name,*tname;
Line 217  char *name0;
Line 256  char *name0;
         char CppExe[BUFSIZ];          char CppExe[BUFSIZ];
         char nbuf[BUFSIZ],tnbuf[BUFSIZ];          char nbuf[BUFSIZ],tnbuf[BUFSIZ];
         STRING rootdir;          STRING rootdir;
           void call_exe(char *,char **);
   
         /* create the unique prefix */          /* create the unique prefix */
         if ( !prefix[0] )          if ( !prefix[0] )
Line 280  char *name0;
Line 320  char *name0;
                 perror("fopen");                  perror("fopen");
                 error("load : failed");                  error("load : failed");
         }          }
         t = (IN)MALLOC(sizeof(struct oIN));          t = (INFILE)MALLOC(sizeof(struct oINFILE));
         t->name = (char *)MALLOC(strlen(name0)+1); strcpy(t->name,name0);          t->name = (char *)MALLOC(strlen(name0)+1); strcpy(t->name,name0);
         t->tname = (char *)MALLOC(strlen(tname)+1); strcpy(t->tname,tname); free(tname);          t->tname = (char *)MALLOC(strlen(tname)+1); strcpy(t->tname,tname); free(tname);
         t->encoded = encoded;          t->encoded = encoded;
Line 292  char *name0;
Line 332  char *name0;
                 perror("popen");                  perror("popen");
                 error("load : failed");                  error("load : failed");
         }          }
         t = (IN)MALLOC(sizeof(struct oIN));          t = (INFILE)MALLOC(sizeof(struct oINFILE));
         t->name = (char *)MALLOC(strlen(name0)+1); strcpy(t->name,name0);          t->name = (char *)MALLOC(strlen(name0)+1); strcpy(t->name,name0);
 #endif  #endif
         t->fp = in; t->ln = 1; t->next = asir_infile; asir_infile = t;          t->fp = in; t->ln = 1; t->next = asir_infile; asir_infile = t;
Line 302  char *name0;
Line 342  char *name0;
                 reallocarray((char **)&EPVS->va,(int *)&EPVS->asize,(int *)&EPVS->n,(int)sizeof(struct oPV));                  reallocarray((char **)&EPVS->va,(int *)&EPVS->asize,(int *)&EPVS->n,(int)sizeof(struct oPV));
 }  }
   
 void execasirfile(name)  void execasirfile(char *name)
 char *name;  
 {  {
         loadasirfile(name);          loadasirfile(name);
         read_exec_file = 1;          read_exec_file = 1;
Line 311  char *name;
Line 350  char *name;
         read_exec_file = 0;          read_exec_file = 0;
 }  }
   
 void load_and_execfile(name)  void load_and_execfile(char *name)
 char *name;  
 {  {
         FILE *fp;          FILE *fp;
         IN save_asir_infile;          INFILE save_asir_infile;
           int save_prresult;
           extern prresult;
   
         savepvs();          savepvs();
         save_asir_infile = asir_infile;          save_asir_infile = asir_infile;
           save_prresult = prresult;
         fp = fopen(name,"rb");          fp = fopen(name,"rb");
         input_init(fp,name);          input_init(fp,name);
         if ( !setjmp(exec_env) ) {          if ( !SETJMP(exec_env) ) {
                 /* XXX : information for asir_teriminate() */                  /* XXX : information for asir_teriminate() */
                 read_exec_file = 2;                  read_exec_file = 2;
                 read_eval_loop();                  read_eval_loop();
Line 330  char *name;
Line 371  char *name;
         fclose(fp);          fclose(fp);
         restorepvs();          restorepvs();
         asir_infile = save_asir_infile;          asir_infile = save_asir_infile;
           prresult = save_prresult;
 }  }
   
 static NODE objfile = 0;  static NODE objfile = 0;
   
 int loadfile(s)  int loadfile(char *s)
 char *s;  
 {  {
         FILE *in;          FILE *in;
   
Line 347  char *s;
Line 388  char *s;
                 return 0;                  return 0;
 }  }
   
 int loadfiles(node) NODE node; { return 0; }  int loadfiles(NODE node) { return 0; }
   
 static unsigned char encrypt_tab[128][2] = {  static unsigned char encrypt_tab[128][2] = {
 {137,40},{1,194},{133,79},{48,20},{254,76},{98,17},{110,233},{19,231},  {137,40},{1,194},{133,79},{48,20},{254,76},{98,17},{110,233},{19,231},
Line 397  unsigned char decrypt_char(unsigned char c)
Line 438  unsigned char decrypt_char(unsigned char c)
         return decrypt_tab[c];          return decrypt_tab[c];
 }  }
   
 void encrypt_file(in,out)  void encrypt_file(char *in,char *out)
 char *in,*out;  
 {  {
         FILE *infp,*outfp;          FILE *infp,*outfp;
         int c;          int c;
Line 409  char *in,*out;
Line 449  char *in,*out;
                 c = getc(infp);                  c = getc(infp);
                 if ( c == EOF )                  if ( c == EOF )
                         break;                          break;
                 putc(encrypt_char(c),outfp);                  putc(encrypt_char((unsigned char)c),outfp);
         }          }
         fclose(infp); fclose(outfp);          fclose(infp); fclose(outfp);
 }  }
   
 void decrypt_file(in,out)  void decrypt_file(char *in,char *out)
 char *in,*out;  
 {  {
         FILE *infp,*outfp;          FILE *infp,*outfp;
         int c;          int c;
Line 428  char *in,*out;
Line 467  char *in,*out;
                 c = getc(infp);                  c = getc(infp);
                 if ( c == EOF )                  if ( c == EOF )
                         break;                          break;
                 putc(decrypt_char(c),outfp);                  putc(decrypt_char((unsigned char)c),outfp);
         }          }
         fclose(infp); fclose(outfp);          fclose(infp); fclose(outfp);
 }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.12

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>