[BACK]Return to gen_hh.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-doc / html_tools

Annotation of OpenXM/src/asir-doc/html_tools/gen_hh.c, Revision 1.1

1.1     ! noro        1: #include <stdio.h>
        !             2: #include <string.h>
        !             3: #include <dirent.h>
        !             4:
        !             5: gen_hhp(out,n)
        !             6: char *out;
        !             7: int n;
        !             8: {
        !             9:        int i;
        !            10:        FILE *outf;
        !            11:
        !            12:        outf = fopen(out,"w");
        !            13:        fprintf(outf,"[OPTIONS]\n");
        !            14:        fprintf(outf,"Compatibility=1.1 or later\n");
        !            15:        fprintf(outf,"Compiled file=asirhelp.chm\n");
        !            16:        fprintf(outf,"Contents file=asirhelp.hhc\n");
        !            17:        fprintf(outf,"Default topic=html\\man_toc.html\n");
        !            18:        fprintf(outf,"Display compile progress=No\n");
        !            19:        fprintf(outf,"Index file=asirhelp.hhk\n");
        !            20:        fprintf(outf,"Language=0x411 “ú–{Œê\n\n\n[FILES]\n");
        !            21:
        !            22:        fprintf(outf,"html\\man_toc.html\n");
        !            23:        for ( i = 1; i <= n; i++ )
        !            24:                fprintf(outf,"html\\man_%d.html\n",i);
        !            25:
        !            26:        fprintf(outf,"\n[INFOTYPES]\n");
        !            27: }
        !            28:
        !            29: conv_toc(in,out)
        !            30: char *in,*out;
        !            31: {
        !            32:        char buf[BUFSIZ];
        !            33:        char *fname,*ptr,*ptr1;
        !            34:        int c;
        !            35:        FILE *inf,*outf;
        !            36:
        !            37:        inf = fopen(in,"r");
        !            38:        outf = fopen(out,"w");
        !            39:        fprintf(outf,"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n");
        !            40:        fprintf(outf,"<HTML>\n<HEAD>\n");
        !            41:        fprintf(outf,"<meta name=\"GENERATOR\" content=\"Microsoft&reg; HTML Help Workshop 4.1\">\n");
        !            42:        fprintf(outf,"<!-- Sitemap 1.0 -->\n</HEAD><BODY>\n");
        !            43:        fprintf(outf,"<OBJECT type=\"text/site properties\">\n");
        !            44:        fprintf(outf,"<param name=\"ImageType\" value=\"Folder\">\n");
        !            45:        fprintf(outf,"</OBJECT>\n<UL>\n");
        !            46:
        !            47:        while ( 1 ) {
        !            48:                c = fgetc(inf);
        !            49:                if ( c == EOF )
        !            50:                        break;
        !            51:                ungetc(c,inf);
        !            52:                fgets(buf,BUFSIZ,inf);
        !            53:                if ( !strncmp(buf,"Jump to:",strlen("Jump to:")) )
        !            54:                        break;
        !            55:                if ( fname = strstr(buf,"man_") ) {
        !            56:                        ptr = strchr(buf,'#');
        !            57:                        *ptr = 0;
        !            58:                        ptr = strchr(ptr+1,'>');
        !            59:                        ptr++;
        !            60:                        if ( *ptr == '<' )
        !            61:                                ptr = strchr(ptr+1,'>')+1;
        !            62:                        ptr1 = strchr(ptr,'<');
        !            63:                        *ptr1 = 0;
        !            64:                        fprintf(outf,"<LI><OBJECT type=\"text/sitemap\">\n");
        !            65:                        fprintf(outf,"<param name=\"Name\" value=\"%s\">\n",ptr);
        !            66:                        fprintf(outf,"<param name=\"Local\" value=\"html\\%s\">\n",fname);
        !            67:                        fprintf(outf,"</OBJECT>\n");
        !            68:                }
        !            69:        }
        !            70:        fprintf(outf,"</UL>\n</BODY></HTML>\n");
        !            71: }
        !            72:
        !            73: conv_index (in,out)
        !            74: char *in,*out;
        !            75: {
        !            76:        char buf[BUFSIZ];
        !            77:        char *fname,*ptr,*ptr1;
        !            78:        FILE *inf,*outf;
        !            79:
        !            80:        inf = fopen(in,"r");
        !            81:        outf = fopen(out,"w");
        !            82:
        !            83:        fprintf(outf,"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n");
        !            84:        fprintf(outf,"<HTML>\n<HEAD>\n");
        !            85:        fprintf(outf,"<meta name=\"GENERATOR\" content=\"Microsoft&reg; HTML Help Workshop 4.1\">\n");
        !            86:        fprintf(outf,"<!-- Sitemap 1.0 -->\n</HEAD><BODY>\n");
        !            87:        fprintf(outf,"</HEAD><BODY>\n");
        !            88:
        !            89:        while ( 1 ) {
        !            90:                fgets(buf,BUFSIZ,inf);
        !            91:                if ( !strncmp(buf,"Jump to:",strlen("Jump to:")) )
        !            92:                        break;
        !            93:        }
        !            94:        while ( 1 ) {
        !            95:                fgets(buf,BUFSIZ,inf);
        !            96:                if ( !strncmp(buf,"Jump to:",strlen("Jump to:")) )
        !            97:                        break;
        !            98:                if ( fname = strstr(buf,"man_") ) {
        !            99:                        ptr = strchr(buf,'#');
        !           100:                        *ptr = 0;
        !           101:                        ptr = strchr(ptr+1,'>');
        !           102:                        ptr++;
        !           103:                        if ( *ptr == '<' )
        !           104:                                ptr = strchr(ptr+1,'>')+1;
        !           105:                        ptr1 = strchr(ptr,'<');
        !           106:                        *ptr1 = 0;
        !           107:                        fprintf(outf,"<LI><OBJECT type=\"text/sitemap\">\n");
        !           108:                        fprintf(outf,"<param name=\"Name\" value=\"%s\">\n",ptr);
        !           109:                        fprintf(outf,"<param name=\"Local\" value=\"html\\%s\">\n",fname);
        !           110:                        fprintf(outf,"</OBJECT>\n");
        !           111:                }
        !           112:        }
        !           113:        fprintf(outf,"</BODY></HTML>\n");
        !           114: }
        !           115:
        !           116: main(argc,argv)
        !           117: int argc;
        !           118: char **argv;
        !           119: {
        !           120:        DIR *d;
        !           121:        struct dirent *dent;
        !           122:        int i,n,n1;
        !           123:        char *ptr,*ptr1;
        !           124:        char *indir,*outdir;
        !           125:        char in[BUFSIZ],out[BUFSIZ],name[BUFSIZ];
        !           126:
        !           127:        indir = argv[1];
        !           128:        outdir = argv[2];
        !           129:        sprintf(in,"%s/man_toc.html",indir);
        !           130:        sprintf(out,"%s/asirhelp.hhc",outdir);
        !           131:        conv_toc(in,out);
        !           132:        d = opendir(indir);
        !           133:        n = 0;
        !           134:        while ( dent = readdir(d) ) {
        !           135:                strcpy(name,dent->d_name);
        !           136:                ptr = strchr(name,'_');
        !           137:                if ( !ptr )
        !           138:                        continue;
        !           139:                ptr++;
        !           140:                ptr1 = strchr(ptr,'.');
        !           141:                if ( !ptr1 )
        !           142:                        continue;
        !           143:                *ptr1 = 0;
        !           144:                if ( !strcmp(ptr,"toc") )
        !           145:                        continue;
        !           146:                n1 = atoi(ptr);
        !           147:                if ( n1 > n )
        !           148:                        n = n1;
        !           149:        }
        !           150:        sprintf(in,"%s/man_%d.html",indir,n);
        !           151:        sprintf(out,"%s/asirhelp.hhk",outdir);
        !           152:        conv_index(in,out);
        !           153:        sprintf(out,"%s/asirhelp.hhp",outdir);
        !           154:        gen_hhp(out,n);
        !           155:        exit(0);
        !           156: }

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