version 1.1, 2002/08/13 09:43:33 |
version 1.5, 2013/08/31 13:45:59 |
|
|
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
#if !defined(_MSC_VER) |
#include <dirent.h> |
#include <dirent.h> |
|
#else |
|
#include <windows.h> |
|
#endif |
|
|
gen_hhp(out,n,prefix,lang) |
void gen_hhp(char *out, int n, char *prefix, char *lang, char *htmldir) |
char *out; |
|
int n; |
|
char *prefix,*lang; |
|
{ |
{ |
int i; |
int i; |
FILE *outf; |
FILE *outf; |
Line 15 char *prefix,*lang; |
|
Line 17 char *prefix,*lang; |
|
fprintf(outf,"Compatibility=1.1 or later\n"); |
fprintf(outf,"Compatibility=1.1 or later\n"); |
fprintf(outf,"Compiled file=%shelp-%s.chm\n",prefix,lang); |
fprintf(outf,"Compiled file=%shelp-%s.chm\n",prefix,lang); |
fprintf(outf,"Contents file=%shelp-%s.hhc\n",prefix,lang); |
fprintf(outf,"Contents file=%shelp-%s.hhc\n",prefix,lang); |
fprintf(outf,"Default topic=html\\%s-%s_toc.html\n",prefix,lang); |
fprintf(outf,"Default topic=%s\\%s-%s_toc.html\n",htmldir,prefix,lang); |
fprintf(outf,"Display compile progress=No\n"); |
fprintf(outf,"Display compile progress=No\n"); |
fprintf(outf,"Index file=%shelp-%s.hhk\n",prefix,lang); |
fprintf(outf,"Index file=%shelp-%s.hhk\n",prefix,lang); |
fprintf(outf,"Language=0x411 日本語\n\n\n[FILES]\n"); |
fprintf(outf,"Language=0x411 日本語\n\n\n[FILES]\n"); |
|
|
fprintf(outf,"html\\%s-%s_toc.html\n",prefix); |
fprintf(outf,"%s\\%s-%s_toc.html\n",htmldir,prefix,lang); |
for ( i = 1; i <= n; i++ ) |
for ( i = 1; i <= n; i++ ) |
fprintf(outf,"html\\%s-%s_%d.html\n",prefix,lang,i); |
fprintf(outf,"%s\\%s-%s_%d.html\n",htmldir,prefix,lang,i); |
|
|
fprintf(outf,"\n[INFOTYPES]\n"); |
fprintf(outf,"\n[INFOTYPES]\n"); |
} |
} |
|
|
conv_toc(in,out,prefix_) |
void conv_toc(char *in, char *out, char *prefix_, char *htmldir) |
char *in,*out,*prefix_; |
|
{ |
{ |
char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
char *fname,*ptr,*ptr1; |
char *fname,*ptr,*ptr1; |
Line 64 char *in,*out,*prefix_; |
|
Line 65 char *in,*out,*prefix_; |
|
*ptr1 = 0; |
*ptr1 = 0; |
fprintf(outf,"<LI><OBJECT type=\"text/sitemap\">\n"); |
fprintf(outf,"<LI><OBJECT type=\"text/sitemap\">\n"); |
fprintf(outf,"<param name=\"Name\" value=\"%s\">\n",ptr); |
fprintf(outf,"<param name=\"Name\" value=\"%s\">\n",ptr); |
fprintf(outf,"<param name=\"Local\" value=\"html\\%s\">\n",fname); |
fprintf(outf,"<param name=\"Local\" value=\"%s\\%s\">\n",htmldir,fname); |
fprintf(outf,"</OBJECT>\n"); |
fprintf(outf,"</OBJECT>\n"); |
} |
} |
} |
} |
fprintf(outf,"</UL>\n</BODY></HTML>\n"); |
fprintf(outf,"</UL>\n</BODY></HTML>\n"); |
} |
} |
|
|
conv_index (in,out,prefix_) |
void conv_index (char *in, char *out, char *prefix_, char *htmldir) |
char *in,*out,*prefix_; |
|
{ |
{ |
char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
char *fname,*ptr,*ptr1; |
char *fname,*ptr,*ptr1; |
Line 96 char *in,*out,*prefix_; |
|
Line 96 char *in,*out,*prefix_; |
|
fgets(buf,BUFSIZ,inf); |
fgets(buf,BUFSIZ,inf); |
if ( !strncmp(buf,"Jump to:",strlen("Jump to:")) ) |
if ( !strncmp(buf,"Jump to:",strlen("Jump to:")) ) |
break; |
break; |
if ( fname = strstr(buf,"prefix_") ) { |
if ( fname = strstr(buf,prefix_) ) { |
ptr = strchr(buf,'#'); |
ptr = strchr(buf,'#'); |
*ptr = 0; |
*ptr = 0; |
ptr = strchr(ptr+1,'>'); |
ptr = strchr(ptr+1,'>'); |
Line 107 char *in,*out,*prefix_; |
|
Line 107 char *in,*out,*prefix_; |
|
*ptr1 = 0; |
*ptr1 = 0; |
fprintf(outf,"<LI><OBJECT type=\"text/sitemap\">\n"); |
fprintf(outf,"<LI><OBJECT type=\"text/sitemap\">\n"); |
fprintf(outf,"<param name=\"Name\" value=\"%s\">\n",ptr); |
fprintf(outf,"<param name=\"Name\" value=\"%s\">\n",ptr); |
fprintf(outf,"<param name=\"Local\" value=\"html\\%s\">\n",fname); |
fprintf(outf,"<param name=\"Local\" value=\"%s\\%s\">\n",htmldir,fname); |
fprintf(outf,"</OBJECT>\n"); |
fprintf(outf,"</OBJECT>\n"); |
} |
} |
} |
} |
fprintf(outf,"</BODY></HTML>\n"); |
fprintf(outf,"</BODY></HTML>\n"); |
} |
} |
|
|
main(argc,argv) |
#if !defined(_MSC_VER) |
int argc; |
int find_files(char *indir,char *prefix) |
char **argv; |
|
{ |
{ |
DIR *d; |
DIR *d; |
struct dirent *dent; |
struct dirent *dent; |
int i,n,n1; |
int n=0,n1; |
char *ptr,*ptr1; |
char *ptr,*ptr1; |
char *indir,*outdir; |
char name[BUFSIZ]; |
char in[BUFSIZ],out[BUFSIZ],name[BUFSIZ],prefix_[BUFSIZ]; |
int len=strlen(prefix); |
char *prefix,*lang; |
|
|
|
indir = argv[1]; |
|
outdir = argv[2]; |
|
prefix = argv[3]; |
|
lang = argv[4]; |
|
sprintf(in,"%s/%s-%s_toc.html",indir,prefix,lang); |
|
sprintf(out,"%s/%shelp-%s.hhc",outdir,prefix,lang); |
|
sprintf(prefix_,"%s-%s_",prefix,lang); |
|
conv_toc(in,out,prefix_); |
|
d = opendir(indir); |
d = opendir(indir); |
n = 0; |
if(!d) { |
|
exit(1); |
|
} |
while ( dent = readdir(d) ) { |
while ( dent = readdir(d) ) { |
strcpy(name,dent->d_name); |
strcpy(name,dent->d_name); |
ptr = strchr(name,'_'); |
ptr = name+len; |
|
ptr = strchr(ptr,'_'); |
if ( !ptr ) |
if ( !ptr ) |
continue; |
continue; |
ptr++; |
ptr++; |
|
|
if ( n1 > n ) |
if ( n1 > n ) |
n = n1; |
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],prefix_[BUFSIZ]; |
|
char *prefix,*lang; |
|
char *htmldir = "html"; |
|
|
|
indir = argv[1]; |
|
outdir = argv[2]; |
|
prefix = argv[3]; |
|
lang = argv[4]; |
|
if(argc>5) { |
|
htmldir = argv[5]; |
|
} |
|
sprintf(in,"%s/%s-%s_toc.html",indir,prefix,lang); |
|
sprintf(out,"%s/%shelp-%s.hhc",outdir,prefix,lang); |
|
sprintf(prefix_,"%s-%s_",prefix,lang); |
|
conv_toc(in,out,prefix_,htmldir); |
|
n = find_files(indir,prefix); |
sprintf(in,"%s/%s-%s_%d.html",indir,prefix,lang,n); |
sprintf(in,"%s/%s-%s_%d.html",indir,prefix,lang,n); |
sprintf(out,"%s/%shelp-%s.hhk",outdir,prefix,lang); |
sprintf(out,"%s/%shelp-%s.hhk",outdir,prefix,lang); |
conv_index(in,out,prefix_); |
conv_index(in,out,prefix_,htmldir); |
sprintf(out,"%s/%shelp-%s.hhp",outdir,prefix,lang); |
sprintf(out,"%s/%shelp-%s.hhp",outdir,prefix,lang); |
gen_hhp(out,n,prefix,lang); |
gen_hhp(out,n,prefix,lang,htmldir); |
exit(0); |
return 0; |
} |
} |