[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.4 and 1.5

version 1.4, 2000/08/22 05:04:27 version 1.5, 2000/11/10 08:28:53
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.3 2000/08/21 08:31:47 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.4 2000/08/22 05:04:27 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
 #if defined(THINK_C)  
 #include <string.h>  
 #include        <StandardFile.h>  
 #include        <Windows.h>  
 #include        <OSUtils.h>  
 #include        <ToolUtils.h>  
 #else  
 #if defined(VISUAL)  #if defined(VISUAL)
 #include <string.h>  #include <string.h>
 #include <fcntl.h>  #include <fcntl.h>
 #if defined(GO32)  
 #include <unistd.h>  
 #endif  
 #include <sys/stat.h>  #include <sys/stat.h>
 #else  #else /* VISUAL */
 #if defined(_PA_RISC1_1) || defined(SYSV) || defined(__SVR4)  #if defined(_PA_RISC1_1) || defined(SYSV) || defined(__SVR4)
 #include <unistd.h>  #include <unistd.h>
 #include <string.h>  #include <string.h>
Line 74 
Line 65 
 #include <sys/file.h>  #include <sys/file.h>
 #include <sys/stat.h>  #include <sys/stat.h>
 #endif  #endif
 #endif  
   
 #if defined(linux)  #if defined(linux)
 #include <unistd.h>  #include <unistd.h>
Line 92  char *ASIRLOADPATH[32];
Line 82  char *ASIRLOADPATH[32];
 void encrypt_file(char *,char *);  void encrypt_file(char *,char *);
 void decrypt_file(char *,char *);  void decrypt_file(char *,char *);
   
 #if defined(THINK_C)  
 void searchasirpath(char *,char **);  
 void loadasirfile(char *);  
   
 short initvol;  
   
 void initVol();  
 short getVol();  
 void setDir(short);  
 void resetDir();  
   
 void initVol() {  
         char buf[BUFSIZ];  
   
         GetVol((StringPtr)buf,&initvol);  
 }  
   
 short getVol() {  
         short vol;  
         char buf[BUFSIZ];  
   
         GetVol((StringPtr)buf,&vol);  
         return vol;  
 }  
   
 void setDir(short vol)  
 {  
         SetVol(0,vol);  
 }  
   
 void resetDir() {  
         SetVol(0,initvol);  
 }  
 #endif  
   
 #if defined(VISUAL)  #if defined(VISUAL)
 #define ENVDELIM ';'  #define ENVDELIM ';'
 #define MORE "more < "  #define MORE "more < "
Line 192  char **pathp;
Line 147  char **pathp;
         char **p;          char **p;
         char *q;          char *q;
         int l;          int l;
 #if !defined(THINK_C) && !defined(VISUAL)  #if !defined(VISUAL)
         struct stat sbuf;          struct stat sbuf;
   
         if ( (name[0] == '/') || ( name[0] == '.') || strchr(name,':')          if ( (name[0] == '/') || ( name[0] == '.') || strchr(name,':')
Line 219  char **pathp;
Line 174  char **pathp;
                 }                  }
                 *pathp = 0;                  *pathp = 0;
         }          }
 #elif defined(VISUAL)  #else
         if ( (name[0] == '/') || ( name[0] == '.') || strchr(name,':')          if ( (name[0] == '/') || ( name[0] == '.') || strchr(name,':')
                 || !ASIRLOADPATH[0] )                  || !ASIRLOADPATH[0] )
                 *pathp = name;                  *pathp = name;
Line 234  char **pathp;
Line 189  char **pathp;
                 }                  }
                 *pathp = 0;                  *pathp = 0;
         }          }
 #else  
         if ( (name[0] == '/') || ( name[0] == '.') || !ASIRLOADPATH[0] )  
                 *pathp = name;  
         else {  
                 for ( p = ASIRLOADPATH; *p; p++ ) {  
                         l = strlen(*p)+strlen(name)+2;  
                         q = (char *)ALLOCA(l); sprintf(q,"%s/%s",*p,name);  
                         *pathp = (char *)MALLOC(l); strcpy(*pathp,q);  
                         return;  
                 }  
                 *pathp = 0;  
         }  
 #endif  #endif
 }  }
   
 #if defined(THINK_C)  
 #define DELIM ':'  
 #elif defined(VISUAL)  
 #define DELIM '/'  #define DELIM '/'
 #endif  
   
 void Eungetc(int,FILE *);  void Eungetc(int,FILE *);
   
Line 263  char *name0;
Line 202  char *name0;
         FILE *in;          FILE *in;
         IN t;          IN t;
         extern char cppname[];          extern char cppname[];
 #if defined(THINK_C) || defined(VISUAL)  #if defined(VISUAL)
         char tname[BUFSIZ],dname[BUFSIZ],ibuf1[BUFSIZ],ibuf2[BUFSIZ];          char ibuf1[BUFSIZ],ibuf2[BUFSIZ];
         int ac;          int ac;
 #if defined(__MWERKS__)  
         char *av[64];  
 #else  
         char *av[BUFSIZ];          char *av[BUFSIZ];
 #endif  
         char *p,*c;          char *p,*c;
         FILE *fp;          FILE *fp;
         char name[BUFSIZ],tname0[BUFSIZ];          char dname[BUFSIZ],tname0[BUFSIZ];
           char *name,*tname;
         int encoded;          int encoded;
           static char prefix[BUFSIZ];
           int process_id();
           char CppExe[BUFSIZ];
           char nbuf[BUFSIZ],tnbuf[BUFSIZ];
           STRING rootdir;
   
 #if defined(VISUAL)          /* create the unique prefix */
           if ( !prefix[0] )
                   sprintf(prefix,"asir%d",process_id());
   
         fp = fopen(name0,"rb");          fp = fopen(name0,"rb");
         if ( getc(fp) == 0xff ) {          if ( getc(fp) == 0xff ) {
                 /* encoded file */                  /* encoded file */
                 fclose(fp);                  fclose(fp);
                 sprintf(name,"%s.$$$",name0);                  name = tempnam(NULL,prefix);
                 decrypt_file(name0,name);                  decrypt_file(name0,name);
                   /* the file 'name' created */
                 encoded = 1;                  encoded = 1;
         } else {          } else {
                 fclose(fp);                  fclose(fp);
                 strcpy(name,name0);                  name = name0;
                 encoded = 0;                  encoded = 0;
         }          }
 #else  
         strcpy(name,name0);  
 #endif  
   
         strcpy(dname,name);          strcpy(dname,name);
           av[0] = "cpp";
           sprintf(nbuf,"\"%s\"",name);
           av[1] = nbuf;
           tname = tempnam(NULL,prefix);
           sprintf(tnbuf,"\"%s\"",tname);
           av[2] = tnbuf;
           sprintf(ibuf1,"-I\"%s\"",asir_libdir);
           av[3] = ibuf1;
           av[4] = "-DWINDOWS";
   
           /* set the include directory */
         p = strrchr(dname,DELIM);          p = strrchr(dname,DELIM);
         av[0] = "cpp"; av[1] = name; av[2] = tname;  
         sprintf(ibuf1,"-I%s",asir_libdir); av[3] = ibuf1; av[4] = "-DWINDOWS";  
         if ( !p ) {          if ( !p ) {
                 sprintf(tname,"%s.___",name); av[5] = 0; ac = 5;                  av[5] = 0; ac = 5;
         } else {          } else {
                 *p++ = 0;                  *p = 0;
 #if defined(VISUAL)                  sprintf(ibuf2,"-I\"%s\"",dname);
                 if ( c = strchr(dname,':') ) {                  av[5] = ibuf2;
                         *c = 0;                  av[6] = 0; ac = 6;
                         sprintf(tname,"%s:%s%c%s.___",dname,c+1,DELIM,p);  
                         *c = ':';  
                 } else  
   
 #endif  
                 sprintf(tname,"%s%c%s.___",dname,DELIM,p);  
                 sprintf(ibuf2,"-I%s",dname); av[5] = ibuf2; av[6] = 0; ac = 6;  
         }          }
         cpp_main(ac,av);  //      cpp_main(ac,av);
           Pget_rootdir(&rootdir);
           sprintf(CppExe,"%s\\bin\\cpp.exe",BDY(rootdir));
           call_exe(CppExe,av);
   
           /* the file tname created */
         if ( encoded ) {          if ( encoded ) {
                 unlink(name);                  unlink(name); free(name);
                 strcpy(tname0,tname);  
                 sprintf(tname,"%s.###",tname0);                  strcpy(tname0,tname); free(tname);
                   tname = tempnam(NULL,prefix);
   
                 encrypt_file(tname0,tname);                  encrypt_file(tname0,tname);
                   /* the file tname created */
                 unlink(tname0);                  unlink(tname0);
   
                 in = fopen(tname,"rb");                  in = fopen(tname,"rb");
         } else          } else
                 in = fopen(tname,"r");                  in = fopen(tname,"r");
Line 327  char *name0;
Line 280  char *name0;
                 error("load : failed");                  error("load : failed");
         }          }
         t = (IN)MALLOC(sizeof(struct oIN));          t = (IN)MALLOC(sizeof(struct oIN));
         t->name = (char *)MALLOC(strlen(name)+1); strcpy(t->name,name);          t->name = (char *)MALLOC(strlen(name0)+1); strcpy(t->name,name0);
         t->tname = (char *)MALLOC(strlen(tname)+1); strcpy(t->tname,tname);          t->tname = (char *)MALLOC(strlen(tname)+1); strcpy(t->tname,tname); free(tname);
         t->encoded = encoded;          t->encoded = encoded;
 #if defined(THINK_C)  
         t->vol = getVol();  
 #endif  
 #else  #else
         char com[BUFSIZ];          char com[BUFSIZ];
   

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

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