=================================================================== RCS file: /home/cvs/OpenXM/src/asir-doc/html_tools/gen_hh.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -r1.2 -r1.3 --- OpenXM/src/asir-doc/html_tools/gen_hh.c 2009/02/22 22:48:15 1.2 +++ OpenXM/src/asir-doc/html_tools/gen_hh.c 2013/08/31 13:45:59 1.3 @@ -1,13 +1,15 @@ -/* $OpenXM$ */ +/* $OpenXM: OpenXM/src/asir-doc/html_tools/gen_hh.c,v 1.2 2009/02/22 22:48:15 ohara Exp $ */ #include #include #include +#if !defined(_MSC_VER) #include +#else +#include +#endif -gen_hhp(out,n) -char *out; -int n; +void gen_hhp(char *out, int n, char *htmldir) { int i; FILE *outf; @@ -17,20 +19,19 @@ int 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,"Default topic=%s\\man_toc.html\n",htmldir); 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"); + fprintf(outf,"%s\\man_toc.html\n",htmldir); for ( i = 1; i <= n; i++ ) - fprintf(outf,"html\\man_%d.html\n",i); + fprintf(outf,"%s\\man_%d.html\n",htmldir,i); fprintf(outf,"\n[INFOTYPES]\n"); } -conv_toc(in,out) -char *in,*out; +void conv_toc(char *in,char *out, char *htmldir) { char buf[BUFSIZ]; char *fname,*ptr,*ptr1; @@ -66,15 +67,14 @@ char *in,*out; *ptr1 = 0; fprintf(outf,"
  • \n"); fprintf(outf,"\n",ptr); - fprintf(outf,"\n",fname); + fprintf(outf,"\n",htmldir,fname); fprintf(outf,"\n"); } } fprintf(outf,"\n\n"); } -conv_index (in,out) -char *in,*out; +void conv_index(char *in, char *out, char *htmldir) { char buf[BUFSIZ]; char *fname,*ptr,*ptr1; @@ -109,34 +109,30 @@ char *in,*out; *ptr1 = 0; fprintf(outf,"
  • \n"); fprintf(outf,"\n",ptr); - fprintf(outf,"\n",fname); + fprintf(outf,"\n",htmldir,fname); fprintf(outf,"\n"); } } fprintf(outf,"\n"); } -main(argc,argv) -int argc; -char **argv; +#if !defined(_MSC_VER) +int find_files(char *indir,char *prefix) { DIR *d; struct dirent *dent; - int i,n,n1; + int n=0,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); + char name[BUFSIZ]; + int len=strlen(prefix); d = opendir(indir); - n = 0; + if(!d) { + exit(1); + } while ( dent = readdir(d) ) { strcpy(name,dent->d_name); - ptr = strchr(name,'_'); + ptr = name+len; + ptr = strchr(ptr,'_'); if ( !ptr ) continue; ptr++; @@ -150,10 +146,62 @@ char **argv; if ( n1 > n ) n = n1; } + closedir(d); + return n; +} +#else +int find_files(char *indir,char *prefix) +{ + HANDLE h; + WIN32_FIND_DATA fd; + char *ptr,*ptr1; + char pattern[BUFSIZ]; + char name[BUFSIZ]; + int n=0,n1; + int len=strlen(prefix); + sprintf(pattern, "%s\\%s*_*.*", indir, prefix); + h = FindFirstFileEx(pattern, FindExInfoStandard, &fd, FindExSearchNameMatch, NULL, 0); + if(h == INVALID_HANDLE_VALUE) { + exit(1); + } + do { + strcpy(name,fd.cFileName); + ptr = name+len; + ptr = strchr(ptr,'_') + 1; + ptr1 = strchr(ptr,'.'); + *ptr1 = 0; + if ( !strcmp(ptr,"toc") ) + continue; + n1 = atoi(ptr); + if ( n1 > n ) + n = n1; + } while(FindNextFile(h, &fd)); + return n; +} +#endif + +int main(int argc, char *argv[]) +{ + int n; + char *indir,*outdir; + char in[BUFSIZ],out[BUFSIZ]; + char *htmldir="html"; + + indir = argv[1]; + outdir = argv[2]; + if(argc>3) { + htmldir=argv[3]; + } + + sprintf(in,"%s/man_toc.html",indir); + sprintf(out,"%s/asirhelp.hhc",outdir); + conv_toc(in,out,htmldir); + n = find_files(indir, ""); + sprintf(in,"%s/man_%d.html",indir,n); sprintf(out,"%s/asirhelp.hhk",outdir); - conv_index(in,out); + conv_index(in,out,htmldir); sprintf(out,"%s/asirhelp.hhp",outdir); - gen_hhp(out,n); + gen_hhp(out,n,htmldir); exit(0); }