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

Annotation of OpenXM_contrib2/asir2000/parse/load.c, Revision 1.16

1.3       noro        1: /*
                      2:  * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
                      3:  * All rights reserved.
                      4:  *
                      5:  * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
                      6:  * non-exclusive and royalty-free license to use, copy, modify and
                      7:  * redistribute, solely for non-commercial and non-profit purposes, the
                      8:  * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
                      9:  * conditions of this Agreement. For the avoidance of doubt, you acquire
                     10:  * only a limited right to use the SOFTWARE hereunder, and FLL or any
                     11:  * third party developer retains all rights, including but not limited to
                     12:  * copyrights, in and to the SOFTWARE.
                     13:  *
                     14:  * (1) FLL does not grant you a license in any way for commercial
                     15:  * purposes. You may use the SOFTWARE only for non-commercial and
                     16:  * non-profit purposes only, such as academic, research and internal
                     17:  * business use.
                     18:  * (2) The SOFTWARE is protected by the Copyright Law of Japan and
                     19:  * international copyright treaties. If you make copies of the SOFTWARE,
                     20:  * with or without modification, as permitted hereunder, you shall affix
                     21:  * to all such copies of the SOFTWARE the above copyright notice.
                     22:  * (3) An explicit reference to this SOFTWARE and its copyright owner
                     23:  * shall be made on your publication or presentation in any form of the
                     24:  * results obtained by use of the SOFTWARE.
                     25:  * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.4       noro       26:  * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.3       noro       27:  * for such modification or the source code of the modified part of the
                     28:  * SOFTWARE.
                     29:  *
                     30:  * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
                     31:  * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
                     32:  * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
                     33:  * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
                     34:  * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
                     35:  * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
                     36:  * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
                     37:  * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
                     38:  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
                     39:  * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
                     40:  * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
                     41:  * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
                     42:  * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
                     43:  * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
                     44:  * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
                     45:  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
                     46:  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
                     47:  *
1.16    ! takayama   48:  * $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.15 2005/03/24 12:46:45 takayama Exp $
1.3       noro       49: */
1.1       noro       50: #include "ca.h"
                     51: #include "parse.h"
1.5       noro       52:
1.1       noro       53: #if defined(VISUAL)
                     54: #include <string.h>
                     55: #include <fcntl.h>
                     56: #include <sys/stat.h>
1.5       noro       57: #else /* VISUAL */
1.1       noro       58: #if defined(_PA_RISC1_1) || defined(SYSV) || defined(__SVR4)
                     59: #include <unistd.h>
                     60: #include <string.h>
                     61: #else
                     62: #include <strings.h>
                     63: #endif
                     64: #include <sys/types.h>
                     65: #include <sys/file.h>
                     66: #include <sys/stat.h>
                     67: #endif
                     68:
                     69: #if defined(linux)
                     70: #include <unistd.h>
                     71: #endif
                     72:
                     73: #if defined(VISUAL)
                     74: #include <io.h>
                     75: #endif
                     76:
1.8       noro       77: #ifdef MALLOC
1.1       noro       78: #undef MALLOC
                     79: #define MALLOC(x) GC_malloc((x)+4)
1.8       noro       80: #endif
1.1       noro       81:
1.15      takayama   82: char **ASIRLOADPATH;
1.1       noro       83:
                     84: #if defined(VISUAL)
                     85: #define ENVDELIM ';'
                     86: #define MORE "more < "
                     87: #else
                     88: #define ENVDELIM ':'
                     89: #define MORE "more"
                     90: #endif
                     91:
                     92: #ifndef ASIR_LIBDIR
                     93: #define ASIR_LIBDIR "."
                     94: #endif
                     95:
                     96: char *getenv();
1.8       noro       97: void Pget_rootdir();
1.10      noro       98: char *search_executable(char *name);
1.8       noro       99:
1.1       noro      100: extern char *asir_libdir;
                    101: extern char *asir_pager;
                    102: extern int read_exec_file;
                    103: extern int main_parser;
1.9       noro      104: extern JMP_BUF exec_env;
1.1       noro      105:
1.10      noro      106: char *search_executable(char *name)
                    107: {
                    108:        char *c,*s,*ret;
1.11      noro      109:        int len,nlen;
1.10      noro      110:        char dir[BUFSIZ],path[BUFSIZ];
                    111:        struct stat buf;
                    112:
1.11      noro      113:        nlen = strlen(name);
1.12      noro      114:        for ( s = (char *)getenv("PATH"); s; ) {
1.10      noro      115:                c = (char *)index(s,':');
1.13      noro      116:                len = c ? c-s : strlen(s);
1.11      noro      117:                if ( len >= BUFSIZ ) continue;
1.12      noro      118:                strncpy(dir,s,len); dir[len] = 0;
                    119:                if ( c ) s = c+1;
                    120:                else s = 0;
1.11      noro      121:                if ( len+nlen+1 >= BUFSIZ ) continue;
1.10      noro      122:                sprintf(path,"%s/%s",dir,name);
                    123:                if ( !stat(path,&buf) && !(buf.st_mode & S_IFDIR)
1.14      noro      124: #if !defined(VISUAL)
                    125:                        && !access(path,X_OK)
                    126: #endif
                    127:                 ) {
1.10      noro      128:                        len = strlen(path)+1;
                    129:                        ret = (char *)MALLOC(len);
                    130:                        strcpy(ret,path);
                    131:                        return ret;
                    132:                }
                    133:        }
                    134:        return 0;
                    135: }
                    136:
1.1       noro      137: void env_init() {
                    138:        char *e,*p,*q;
1.10      noro      139:        int i,l,japanese;
1.1       noro      140:        char *getenv();
                    141:        char *oxhome;
                    142:        char rootname[BUFSIZ];
                    143:
                    144:        if ( !(asir_libdir = getenv("ASIR_LIBDIR")) ) {
                    145:                if ( oxhome = getenv("OpenXM_HOME") ) {
                    146:                        asir_libdir = (char *)malloc(strlen(oxhome)+strlen("/lib/asir")+1);
                    147:                        sprintf(asir_libdir,"%s/lib/asir",oxhome);
                    148:                } else {
                    149: #if defined(VISUAL)
                    150:                        get_rootdir(rootname,sizeof(rootname));
                    151:                        asir_libdir = (char *)malloc(strlen(rootname)+strlen("/lib")+1);
                    152:                        sprintf(asir_libdir,"%s/lib",rootname);
                    153: #else
                    154:                        asir_libdir = (char *)malloc(strlen(ASIR_LIBDIR)+1);
                    155:                        strcpy(asir_libdir,ASIR_LIBDIR);
                    156: #endif
                    157:                }
                    158:        }
                    159:        if ( !(asir_pager = getenv("PAGER")) ) {
1.10      noro      160:                japanese = 0;
1.11      noro      161:                if ( (e = getenv("LANGUAGE")) &&
                    162:                        (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1;
                    163:                else if ( (e = getenv("LC_ALL")) &&
                    164:                        (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1;
                    165:                else if ( (e = getenv("LC_CTYPE")) &&
                    166:                        (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1;
                    167:                else if ( (e = getenv("LANG")) &&
                    168:                        (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1;
1.10      noro      169:                if ( japanese )
                    170:                        asir_pager = search_executable("jless");
                    171:                if ( !asir_pager ) {
                    172:                        /* default: more */
                    173:                        asir_pager = (char *)malloc(strlen(MORE)+1);
                    174:                        strcpy(asir_pager,MORE);
                    175:                }
1.1       noro      176:        }
1.15      takayama  177:        if ( e = getenv("ASIRLOADPATH" ) ) {
                    178:                for ( i = 0; ; i++, e = p+1 ) {
                    179:                        p = (char *)index(e,ENVDELIM);
                    180:                        if ( !p )
                    181:                                break;
                    182:                }
1.16    ! takayama  183:                i += 3;
1.15      takayama  184:         ASIRLOADPATH=(char **)MALLOC(sizeof(char *)*i);
                    185:                for ( l = 0; l<i; l++) ASIRLOADPATH[l] = NULL;
                    186:                e = getenv("ASIRLOADPATH");
1.1       noro      187:                for ( i = 0; ; i++, e = p+1 ) {
                    188:                        p = (char *)index(e,ENVDELIM);
                    189:                        l = p ? p-e : strlen(e); q = (char *)MALLOC(l+1);
                    190:                        if ( l ) {
                    191:                                strncpy(q,e,l); q[l] = 0; ASIRLOADPATH[i] = q;
                    192:                        }
                    193:                        if ( !p )
                    194:                                break;
                    195:                }
1.16    ! takayama  196:     }else{
        !           197:          ASIRLOADPATH=(char **)MALLOC(sizeof(char *)*3);
        !           198:          ASIRLOADPATH[0] = NULL;
1.15      takayama  199:     }
1.1       noro      200:        for ( i = 0; ASIRLOADPATH[i]; i++ );
1.16    ! takayama  201:        ASIRLOADPATH[i++] = asir_libdir;
        !           202:        ASIRLOADPATH[i] = NULL;
1.1       noro      203: }
                    204:
1.8       noro      205: void searchasirpath(char *name,char **pathp)
1.1       noro      206: {
                    207:        char **p;
                    208:        char *q;
                    209:        int l;
1.5       noro      210: #if !defined(VISUAL)
1.1       noro      211:        struct stat sbuf;
                    212:
                    213:        if ( (name[0] == '/') || ( name[0] == '.') || strchr(name,':')
                    214:                || !ASIRLOADPATH[0] ) {
                    215:                if ( access(name,R_OK) >= 0 ) {
                    216:                        stat(name,&sbuf);
                    217:                        if ( (sbuf.st_mode & S_IFMT) != S_IFDIR )
                    218:                                *pathp = name;
                    219:                        else
                    220:                                *pathp = 0;
                    221:                } else
                    222:                        *pathp = 0;
                    223:        } else {
                    224:                for ( p = ASIRLOADPATH; *p; p++ ) {
                    225:                        l = strlen(*p)+strlen(name)+2;
                    226:                        q = (char *)ALLOCA(l); sprintf(q,"%s/%s",*p,name);
                    227:                        if ( access(q,R_OK) >= 0 ) {
                    228:                                stat(q,&sbuf);
                    229:                                if ( (sbuf.st_mode & S_IFMT) != S_IFDIR ) {
                    230:                                        *pathp = (char *)MALLOC(l); strcpy(*pathp,q);
                    231:                                        return;
                    232:                                }
                    233:                        }
                    234:                }
                    235:                *pathp = 0;
                    236:        }
1.5       noro      237: #else
1.1       noro      238:        if ( (name[0] == '/') || ( name[0] == '.') || strchr(name,':')
                    239:                || !ASIRLOADPATH[0] )
                    240:                *pathp = name;
                    241:        else {
                    242:                for ( p = ASIRLOADPATH; *p; p++ ) {
                    243:                        l = strlen(*p)+strlen(name)+2;
                    244:                        q = (char *)ALLOCA(l); sprintf(q,"%s/%s",*p,name);
                    245:                        if ( access(q,04) >= 0 ) {
                    246:                                *pathp = (char *)MALLOC(l); strcpy(*pathp,q);
                    247:                                return;
                    248:                        }
                    249:                }
                    250:                *pathp = 0;
                    251:        }
                    252: #endif
                    253: }
                    254:
                    255: #define DELIM '/'
                    256:
1.8       noro      257: void loadasirfile(char *name0)
1.1       noro      258: {
                    259:        FILE *in;
1.8       noro      260:        INFILE t;
1.1       noro      261:        extern char cppname[];
1.5       noro      262: #if defined(VISUAL)
                    263:        char ibuf1[BUFSIZ],ibuf2[BUFSIZ];
1.1       noro      264:        int ac;
                    265:        char *av[BUFSIZ];
1.8       noro      266:        char *p;
1.1       noro      267:        FILE *fp;
1.5       noro      268:        char dname[BUFSIZ],tname0[BUFSIZ];
                    269:        char *name,*tname;
1.1       noro      270:        int encoded;
1.5       noro      271:        static char prefix[BUFSIZ];
                    272:        int process_id();
                    273:        char CppExe[BUFSIZ];
                    274:        char nbuf[BUFSIZ],tnbuf[BUFSIZ];
                    275:        STRING rootdir;
1.8       noro      276:        void call_exe(char *,char **);
1.5       noro      277:
                    278:        /* create the unique prefix */
                    279:        if ( !prefix[0] )
                    280:                sprintf(prefix,"asir%d",process_id());
1.1       noro      281:
                    282:        fp = fopen(name0,"rb");
                    283:        if ( getc(fp) == 0xff ) {
                    284:                /* encoded file */
                    285:                fclose(fp);
1.5       noro      286:                name = tempnam(NULL,prefix);
1.1       noro      287:                decrypt_file(name0,name);
1.5       noro      288:                /* the file 'name' created */
1.1       noro      289:                encoded = 1;
                    290:        } else {
                    291:                fclose(fp);
1.5       noro      292:                name = name0;
1.1       noro      293:                encoded = 0;
                    294:        }
                    295:
                    296:        strcpy(dname,name);
1.5       noro      297:        av[0] = "cpp";
                    298:        sprintf(nbuf,"\"%s\"",name);
                    299:        av[1] = nbuf;
                    300:        tname = tempnam(NULL,prefix);
                    301:        sprintf(tnbuf,"\"%s\"",tname);
                    302:        av[2] = tnbuf;
                    303:        sprintf(ibuf1,"-I\"%s\"",asir_libdir);
                    304:        av[3] = ibuf1;
                    305:        av[4] = "-DWINDOWS";
                    306:
                    307:        /* set the include directory */
1.1       noro      308:        p = strrchr(dname,DELIM);
                    309:        if ( !p ) {
1.5       noro      310:                av[5] = 0; ac = 5;
1.1       noro      311:        } else {
1.5       noro      312:                *p = 0;
                    313:                sprintf(ibuf2,"-I\"%s\"",dname);
                    314:                av[5] = ibuf2;
                    315:                av[6] = 0; ac = 6;
                    316:        }
                    317: //     cpp_main(ac,av);
                    318:        Pget_rootdir(&rootdir);
                    319:        sprintf(CppExe,"%s\\bin\\cpp.exe",BDY(rootdir));
                    320:        call_exe(CppExe,av);
1.1       noro      321:
1.5       noro      322:        /* the file tname created */
1.1       noro      323:        if ( encoded ) {
1.5       noro      324:                unlink(name); free(name);
                    325:
                    326:                strcpy(tname0,tname); free(tname);
                    327:                tname = tempnam(NULL,prefix);
                    328:
1.1       noro      329:                encrypt_file(tname0,tname);
1.5       noro      330:                /* the file tname created */
1.1       noro      331:                unlink(tname0);
1.5       noro      332:
1.1       noro      333:                in = fopen(tname,"rb");
                    334:        } else
                    335:                in = fopen(tname,"r");
                    336:        if ( !in ) {
                    337:                perror("fopen");
                    338:                error("load : failed");
                    339:        }
1.8       noro      340:        t = (INFILE)MALLOC(sizeof(struct oINFILE));
1.5       noro      341:        t->name = (char *)MALLOC(strlen(name0)+1); strcpy(t->name,name0);
                    342:        t->tname = (char *)MALLOC(strlen(tname)+1); strcpy(t->tname,tname); free(tname);
1.1       noro      343:        t->encoded = encoded;
                    344: #else
                    345:        char com[BUFSIZ];
                    346:
                    347:        sprintf(com,"%s -I%s %s",cppname,asir_libdir,name0); in = popen(com,"r");
                    348:        if ( !in ) {
                    349:                perror("popen");
                    350:                error("load : failed");
                    351:        }
1.8       noro      352:        t = (INFILE)MALLOC(sizeof(struct oINFILE));
1.1       noro      353:        t->name = (char *)MALLOC(strlen(name0)+1); strcpy(t->name,name0);
                    354: #endif
                    355:        t->fp = in; t->ln = 1; t->next = asir_infile; asir_infile = t;
                    356:        main_parser = 1; /* XXX */
                    357:        Eungetc(afternl(),asir_infile->fp);
                    358:        if ( !EPVS->va )
                    359:                reallocarray((char **)&EPVS->va,(int *)&EPVS->asize,(int *)&EPVS->n,(int)sizeof(struct oPV));
                    360: }
                    361:
1.8       noro      362: void execasirfile(char *name)
1.1       noro      363: {
                    364:        loadasirfile(name);
                    365:        read_exec_file = 1;
                    366:        read_eval_loop();
                    367:        read_exec_file = 0;
1.6       noro      368: }
                    369:
1.8       noro      370: void load_and_execfile(char *name)
1.6       noro      371: {
                    372:        FILE *fp;
1.8       noro      373:        INFILE save_asir_infile;
1.7       noro      374:        int save_prresult;
                    375:        extern prresult;
1.6       noro      376:
                    377:        savepvs();
                    378:        save_asir_infile = asir_infile;
1.7       noro      379:        save_prresult = prresult;
1.6       noro      380:        fp = fopen(name,"rb");
                    381:        input_init(fp,name);
1.9       noro      382:        if ( !SETJMP(exec_env) ) {
1.6       noro      383:                /* XXX : information for asir_teriminate() */
                    384:                read_exec_file = 2;
                    385:                read_eval_loop();
                    386:                read_exec_file = 0;
                    387:        }
                    388:        fclose(fp);
                    389:        restorepvs();
                    390:        asir_infile = save_asir_infile;
1.7       noro      391:        prresult = save_prresult;
1.1       noro      392: }
                    393:
                    394: static NODE objfile = 0;
                    395:
1.8       noro      396: int loadfile(char *s)
1.1       noro      397: {
                    398:        FILE *in;
                    399:
                    400:        if ( in = fopen(s,"r") ) {
                    401:                fclose(in);
                    402:                loadasirfile(s);
                    403:                return 1;
                    404:        } else
                    405:                return 0;
                    406: }
                    407:
1.8       noro      408: int loadfiles(NODE node) { return 0; }
1.1       noro      409:
                    410: static unsigned char encrypt_tab[128][2] = {
                    411: {137,40},{1,194},{133,79},{48,20},{254,76},{98,17},{110,233},{19,231},
                    412: {55,223},{75,65},{178,151},{85,222},{201,46},{51,243},{235,61},{106,113},
                    413: {116,121},{24,205},{146,244},{89,234},{163,173},{140,162},{188,45},{195,132},
                    414: {202,94},{236,87},{2,127},{253,47},{211,138},{58,252},{142,190},{77,209},
                    415: {16,53},{200,220},{99,165},{28,59},{78,0},{208,248},{50,229},{217,39},
                    416: {112,15},{18,60},{108,175},{10,67},{23,176},{49,245},{160,27},{171,219},
                    417: {105,144},{122,172},{255,114},{226,100},{70,117},{197,11},{180,36},{136,101},
                    418: {238,212},{125,120},{103,199},{38,119},{7,206},{181,228},{62,3},{30,185},
                    419: {154,63},{247,81},{187,80},{225,56},{210,221},{37,135},{155,52},{54,153},
                    420: {84,246},{166,90},{124,167},{41,184},{145,204},{147,198},{25,21},{72,97},
                    421: {66,128},{95,139},{93,42},{224,43},{35,143},{111,13},{82,249},{12,148},
                    422: {32,152},{186,168},{177,115},{216,251},{5,131},{123,170},{149,161},{213,203},
                    423: {126,150},{88,158},{74,169},{159,182},{156,26},{34,104},{8,91},{207,183},
                    424: {9,64},{83,241},{134,102},{69,33},{179,237},{129,250},{14,71},{230,4},
                    425: {218,6},{189,68},{193,22},{57,174},{215,214},{130,92},{240,31},{118,239},
                    426: {109,192},{232,196},{86,107},{96,141},{157,227},{164,242},{44,191},{29,73}
                    427: };
                    428:
                    429: static unsigned char decrypt_tab[] = {
                    430: 36,1,26,62,111,92,112,60,102,104,43,53,87,85,110,40,
                    431: 32,5,41,7,3,78,114,44,17,78,100,46,35,127,63,118,
                    432: 88,107,101,84,54,69,59,39,0,75,82,83,126,22,12,27,
                    433: 3,45,38,13,70,32,71,8,67,115,29,35,41,14,62,64,
                    434: 104,9,80,43,113,107,52,110,79,127,98,9,4,31,36,2,
                    435: 66,65,86,105,72,11,122,25,97,19,73,102,117,82,24,81,
                    436: 123,79,5,34,51,55,106,58,101,48,15,122,42,120,6,85,
                    437: 40,15,50,90,16,52,119,59,57,16,49,93,74,57,96,26,
                    438: 80,109,117,92,23,2,106,69,55,0,28,81,21,123,30,84,
                    439: 48,76,18,77,87,94,96,10,88,71,64,70,100,124,97,99,
                    440: 46,94,21,20,125,34,73,74,89,98,93,47,49,20,115,42,
                    441: 44,90,10,108,54,61,99,103,75,63,89,66,22,113,30,126,
                    442: 120,114,1,23,121,53,77,58,33,12,24,95,76,17,60,103,
                    443: 37,31,68,28,56,95,116,116,91,39,112,47,33,68,11,8,
                    444: 83,67,51,124,61,38,111,7,121,6,19,14,25,108,56,119,
                    445: 118,105,125,13,18,45,72,65,37,86,109,91,29,27,4,50
                    446: };
                    447:
                    448: unsigned char encrypt_char(unsigned char c)
                    449: {
                    450:        return encrypt_tab[c][mt_genrand()&1];
                    451: }
                    452:
                    453: unsigned char decrypt_char(unsigned char c)
                    454: {
                    455:        return decrypt_tab[c];
                    456: }
                    457:
1.8       noro      458: void encrypt_file(char *in,char *out)
1.1       noro      459: {
                    460:        FILE *infp,*outfp;
                    461:        int c;
                    462:
                    463:        infp = fopen(in,"r");
                    464:        outfp = fopen(out,"wb");
                    465:        while ( 1 ) {
                    466:                c = getc(infp);
                    467:                if ( c == EOF )
                    468:                        break;
1.8       noro      469:                putc(encrypt_char((unsigned char)c),outfp);
1.1       noro      470:        }
                    471:        fclose(infp); fclose(outfp);
                    472: }
                    473:
1.8       noro      474: void decrypt_file(char *in,char *out)
1.1       noro      475: {
                    476:        FILE *infp,*outfp;
                    477:        int c;
                    478:
                    479:        infp = fopen(in,"rb");
                    480:        outfp = fopen(out,"w");
                    481:        /* skip the magic number (=0xff) */
                    482:        getc(infp);
                    483:        while ( 1 ) {
                    484:                c = getc(infp);
                    485:                if ( c == EOF )
                    486:                        break;
1.8       noro      487:                putc(decrypt_char((unsigned char)c),outfp);
1.1       noro      488:        }
                    489:        fclose(infp); fclose(outfp);
                    490: }

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