/* $OpenXM: OpenXM/src/asir-doc/html_tools/gen_hh.c,v 1.2 2009/02/22 22:48:15 ohara Exp $ */ #include #include #include #include gen_hhp(out,n) char *out; int n; { int i; FILE *outf; outf = fopen(out,"w"); fprintf(outf,"[OPTIONS]\n"); fprintf(outf,"Compatibility=1.1 or later\n"); fprintf(outf,"Compiled file=asirhelp.chm\n"); fprintf(outf,"Contents file=asirhelp.hhc\n"); fprintf(outf,"Default topic=html\\man_toc.html\n"); fprintf(outf,"Display compile progress=No\n"); fprintf(outf,"Index file=asirhelp.hhk\n"); fprintf(outf,"Language=0x411 “ú–{Œê\n\n\n[FILES]\n"); fprintf(outf,"html\\man_toc.html\n"); for ( i = 1; i <= n; i++ ) fprintf(outf,"html\\man_%d.html\n",i); fprintf(outf,"\n[INFOTYPES]\n"); } conv_toc(in,out) char *in,*out; { char buf[BUFSIZ]; char *fname,*ptr,*ptr1; int c; FILE *inf,*outf; inf = fopen(in,"r"); outf = fopen(out,"w"); fprintf(outf,"\n"); fprintf(outf,"\n\n"); fprintf(outf,"\n"); fprintf(outf,"\n\n"); fprintf(outf,"\n"); fprintf(outf,"\n"); fprintf(outf,"\n
    \n"); while ( 1 ) { c = fgetc(inf); if ( c == EOF ) break; ungetc(c,inf); fgets(buf,BUFSIZ,inf); if ( !strncmp(buf,"Jump to:",strlen("Jump to:")) ) break; if ( fname = strstr(buf,"man_") ) { ptr = strchr(buf,'#'); *ptr = 0; ptr = strchr(ptr+1,'>'); ptr++; if ( *ptr == '<' ) ptr = strchr(ptr+1,'>')+1; ptr1 = strchr(ptr,'<'); *ptr1 = 0; fprintf(outf,"
  • \n"); fprintf(outf,"\n",ptr); fprintf(outf,"\n",fname); fprintf(outf,"\n"); } } fprintf(outf,"
\n\n"); } conv_index (in,out) char *in,*out; { char buf[BUFSIZ]; char *fname,*ptr,*ptr1; FILE *inf,*outf; inf = fopen(in,"r"); outf = fopen(out,"w"); fprintf(outf,"\n"); fprintf(outf,"\n\n"); fprintf(outf,"\n"); fprintf(outf,"\n\n"); fprintf(outf,"\n"); while ( 1 ) { fgets(buf,BUFSIZ,inf); if ( !strncmp(buf,"Jump to:",strlen("Jump to:")) ) break; } while ( 1 ) { fgets(buf,BUFSIZ,inf); if ( !strncmp(buf,"Jump to:",strlen("Jump to:")) ) break; if ( fname = strstr(buf,"man_") ) { ptr = strchr(buf,'#'); *ptr = 0; ptr = strchr(ptr+1,'>'); ptr++; if ( *ptr == '<' ) ptr = strchr(ptr+1,'>')+1; ptr1 = strchr(ptr,'<'); *ptr1 = 0; fprintf(outf,"
  • \n"); fprintf(outf,"\n",ptr); fprintf(outf,"\n",fname); fprintf(outf,"\n"); } } fprintf(outf,"\n"); } main(argc,argv) int argc; char **argv; { DIR *d; struct dirent *dent; int i,n,n1; char *ptr,*ptr1; char *indir,*outdir; char in[BUFSIZ],out[BUFSIZ],name[BUFSIZ]; indir = argv[1]; outdir = argv[2]; sprintf(in,"%s/man_toc.html",indir); sprintf(out,"%s/asirhelp.hhc",outdir); conv_toc(in,out); d = opendir(indir); n = 0; while ( dent = readdir(d) ) { strcpy(name,dent->d_name); ptr = strchr(name,'_'); if ( !ptr ) continue; ptr++; ptr1 = strchr(ptr,'.'); if ( !ptr1 ) continue; *ptr1 = 0; if ( !strcmp(ptr,"toc") ) continue; n1 = atoi(ptr); if ( n1 > n ) n = n1; } sprintf(in,"%s/man_%d.html",indir,n); sprintf(out,"%s/asirhelp.hhk",outdir); conv_index(in,out); sprintf(out,"%s/asirhelp.hhp",outdir); gen_hhp(out,n); exit(0); }