Annotation of sbbs/sbbs3/scfg/makehelp.c, revision 1.1

1.1     ! root        1: /* MAKEHELP.C */
        !             2: 
        !             3: /* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */
        !             4: 
        !             5: /* Makes SCFG.HLP for Synchronet configuration program */
        !             6: 
        !             7: #include <stdio.h>
        !             8: #include <string.h>
        !             9: #include <fcntl.h>
        !            10: #include <sys/stat.h>
        !            11: #if defined(__unix__)
        !            12:        #include <unistd.h>             /* write */
        !            13:        #define O_BINARY 0
        !            14: #else
        !            15:        #include <io.h> /* open */
        !            16: #endif
        !            17: 
        !            18: int main(int argc, char **argv)
        !            19: {
        !            20:        char *dir=".";
        !            21:        char *files[]={
        !            22:                  "scfg.c"
        !            23:                                ,"scfgsys.c"
        !            24:                                ,"scfgmsg.c"
        !            25:                                ,"scfgsub.c"
        !            26:                                ,"scfgnode.c"
        !            27:                                ,"scfgchat.c"
        !            28:                                ,"scfgxfr1.c"
        !            29:                                ,"scfgxfr2.c"
        !            30:                                ,"scfgnet.c"
        !            31:                                ,"scfgxtrn.c"
        !            32:                                ,NULL };
        !            33:        char str[256],tmp[256];
        !            34:        int i,j,k,ixb;
        !            35:        unsigned short line;
        !            36:        long l;
        !            37:        FILE *stream,*out;
        !            38: 
        !            39:        if(argc>1)
        !            40:                dir=argv[1];
        !            41: 
        !            42:        sprintf(str,"%s/scfghelp.dat",dir);
        !            43:        if((out=fopen(str,"wb"))==NULL) {
        !            44:                fprintf(stderr,"!error opening %s\n",str);
        !            45:                return(-1); }
        !            46: 
        !            47:        sprintf(str,"%s/scfghelp.ixb",dir);
        !            48:        if((ixb=open(str,O_WRONLY|O_CREAT|O_BINARY,S_IWRITE|S_IREAD))==-1) {
        !            49:                fprintf(stderr,"!error opening %s\n",str);
        !            50:                return(-1); }
        !            51: 
        !            52:        for(i=0;files[i];i++) {
        !            53:                if((stream=fopen(files[i],"rb"))==NULL) {
        !            54:                        fprintf(stderr,"!error opening %s\r\n",files[i]);
        !            55:                        return(-3); }
        !            56:                printf("\r\nIndexing %s ...",files[i]);
        !            57:                line=0;
        !            58:                while(!feof(stream)) {
        !            59:                        if(!fgets(str,128,stream))
        !            60:                                break;
        !            61:                        line++;
        !            62:                        if(strstr(str,"SETHELP(WHERE);")) {
        !            63:                                /* printf("%s:%u\n",files[i],line); */
        !            64:                                l=ftell(out);
        !            65:                                write(ixb,files[i],12);
        !            66:                                write(ixb,&line,2);
        !            67:                                write(ixb,&l,4);
        !            68:                                fgets(str,128,stream);   /* skip start comment */
        !            69:                                line++;
        !            70:                                while(!feof(stream)) {
        !            71:                                        if(!fgets(str,128,stream))
        !            72:                                                break;
        !            73:                                        if(strchr(str,9)) { /* Tab expansion */
        !            74:                                                strcpy(tmp,str);
        !            75:                                                k=strlen(tmp);
        !            76:                                                for(j=l=0;j<k;j++) {
        !            77:                                                        if(tmp[j]==9) {
        !            78:                                                                str[l++]=32;
        !            79:                                                                while(l%4)
        !            80:                                                                        str[l++]=32; }
        !            81:                                                        else
        !            82:                                                                str[l++]=tmp[j]; }
        !            83:                                                str[l]=0; }
        !            84:                                        line++;
        !            85:                                        if(strstr(str,"*/"))    /* end comment */
        !            86:                                                break;
        !            87:                                        fputs(str,out); }
        !            88:                                fputc(0,out); } }
        !            89:                fclose(stream); }
        !            90:        fclose(out);
        !            91:        printf("\n");
        !            92:        return(0);
        !            93: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.