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

Annotation of OpenXM/src/asir-doc/html_tools/gen_hh_new.c, Revision 1.2

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

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