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