version 1.3, 2013/08/31 13:45:59 |
version 1.4, 2013/09/02 20:08:41 |
|
|
/* $OpenXM: OpenXM/src/asir-doc/html_tools/gen_hh.c,v 1.2 2009/02/22 22:48:15 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/asir-doc/html_tools/gen_hh.c,v 1.3 2013/08/31 13:45:59 ohara Exp $ */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
|
#include <windows.h> |
#include <windows.h> |
#endif |
#endif |
|
|
void gen_hhp(char *out, int n, char *htmldir) |
void gen_hhp(char *out, int n, char *indir, char *prefix_, char *help) |
{ |
{ |
int i; |
int i; |
FILE *outf; |
FILE *outf; |
Line 17 void gen_hhp(char *out, int n, char *htmldir) |
|
Line 17 void gen_hhp(char *out, int n, char *htmldir) |
|
outf = fopen(out,"w"); |
outf = fopen(out,"w"); |
fprintf(outf,"[OPTIONS]\n"); |
fprintf(outf,"[OPTIONS]\n"); |
fprintf(outf,"Compatibility=1.1 or later\n"); |
fprintf(outf,"Compatibility=1.1 or later\n"); |
fprintf(outf,"Compiled file=asirhelp.chm\n"); |
fprintf(outf,"Compiled file=%s.chm\n",help); |
fprintf(outf,"Contents file=asirhelp.hhc\n"); |
fprintf(outf,"Contents file=%s.hhc\n",help); |
fprintf(outf,"Default topic=%s\\man_toc.html\n",htmldir); |
fprintf(outf,"Default topic=%s\\%s_toc.html\n",indir,prefix_); |
fprintf(outf,"Display compile progress=No\n"); |
fprintf(outf,"Display compile progress=No\n"); |
fprintf(outf,"Index file=asirhelp.hhk\n"); |
fprintf(outf,"Index file=%s.hhk\n",help); |
fprintf(outf,"Language=0x411 日本語\n\n\n[FILES]\n"); |
fprintf(outf,"Language=0x411 日本語\n\n\n[FILES]\n"); |
|
|
fprintf(outf,"%s\\man_toc.html\n",htmldir); |
fprintf(outf,"%s\\%s_toc.html\n",indir,prefix_); |
for ( i = 1; i <= n; i++ ) |
for ( i = 1; i <= n; i++ ) |
fprintf(outf,"%s\\man_%d.html\n",htmldir,i); |
fprintf(outf,"%s\\%s_%d.html\n",indir,prefix_,i); |
|
|
fprintf(outf,"\n[INFOTYPES]\n"); |
fprintf(outf,"\n[INFOTYPES]\n"); |
} |
} |
|
|
void conv_toc(char *in,char *out, char *htmldir) |
void conv_toc(char *in, char *out, char *prefix_, char *indir) |
{ |
{ |
char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
char *fname,*ptr,*ptr1; |
char *fname,*ptr,*ptr1; |
Line 56 void conv_toc(char *in,char *out, char *htmldir) |
|
Line 56 void conv_toc(char *in,char *out, char *htmldir) |
|
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,"man_") ) { |
if ( fname = strstr(buf,prefix_) ) { |
ptr = strchr(buf,'#'); |
ptr = strchr(buf,'#'); |
*ptr = 0; |
*ptr = 0; |
ptr = strchr(ptr+1,'>'); |
ptr = strchr(ptr+1,'>'); |
Line 67 void conv_toc(char *in,char *out, char *htmldir) |
|
Line 67 void conv_toc(char *in,char *out, char *htmldir) |
|
*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=\"%s\\%s\">\n",htmldir,fname); |
fprintf(outf,"<param name=\"Local\" value=\"%s\\%s\">\n",indir,fname); |
fprintf(outf,"</OBJECT>\n"); |
fprintf(outf,"</OBJECT>\n"); |
} |
} |
} |
} |
fprintf(outf,"</UL>\n</BODY></HTML>\n"); |
fprintf(outf,"</UL>\n</BODY></HTML>\n"); |
} |
} |
|
|
void conv_index(char *in, char *out, char *htmldir) |
void conv_index(char *in, char *out, char *prefix_, char *indir) |
{ |
{ |
char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
char *fname,*ptr,*ptr1; |
char *fname,*ptr,*ptr1; |
Line 98 void conv_index(char *in, char *out, char *htmldir) |
|
Line 98 void conv_index(char *in, char *out, char *htmldir) |
|
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,"man_") ) { |
if ( fname = strstr(buf,prefix_) ) { |
ptr = strchr(buf,'#'); |
ptr = strchr(buf,'#'); |
*ptr = 0; |
*ptr = 0; |
ptr = strchr(ptr+1,'>'); |
ptr = strchr(ptr+1,'>'); |
Line 109 void conv_index(char *in, char *out, char *htmldir) |
|
Line 109 void conv_index(char *in, char *out, char *htmldir) |
|
*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=\"%s\\%s\">\n",htmldir,fname); |
fprintf(outf,"<param name=\"Local\" value=\"%s\\%s\">\n",indir,fname); |
fprintf(outf,"</OBJECT>\n"); |
fprintf(outf,"</OBJECT>\n"); |
} |
} |
} |
} |
Line 117 void conv_index(char *in, char *out, char *htmldir) |
|
Line 117 void conv_index(char *in, char *out, char *htmldir) |
|
} |
} |
|
|
#if !defined(_MSC_VER) |
#if !defined(_MSC_VER) |
int find_files(char *indir,char *prefix) |
int find_files(char *indir,char *base) |
{ |
{ |
DIR *d; |
DIR *d; |
struct dirent *dent; |
struct dirent *dent; |
int n=0,n1; |
int n=0,n1; |
char *ptr,*ptr1; |
char *ptr,*ptr1; |
char name[BUFSIZ]; |
char name[BUFSIZ]; |
int len=strlen(prefix); |
int len=strlen(base); |
d = opendir(indir); |
d = opendir(indir); |
if(!d) { |
if(!d) { |
exit(1); |
exit(1); |
Line 150 int find_files(char *indir,char *prefix) |
|
Line 150 int find_files(char *indir,char *prefix) |
|
return n; |
return n; |
} |
} |
#else |
#else |
int find_files(char *indir,char *prefix) |
int find_files(char *indir,char *base) |
{ |
{ |
HANDLE h; |
HANDLE h; |
WIN32_FIND_DATA fd; |
WIN32_FIND_DATA fd; |
Line 158 int find_files(char *indir,char *prefix) |
|
Line 158 int find_files(char *indir,char *prefix) |
|
char pattern[BUFSIZ]; |
char pattern[BUFSIZ]; |
char name[BUFSIZ]; |
char name[BUFSIZ]; |
int n=0,n1; |
int n=0,n1; |
int len=strlen(prefix); |
int len=strlen(base); |
sprintf(pattern, "%s\\%s*_*.*", indir, prefix); |
sprintf(pattern, "%s\\%s_*.*", indir, base); |
h = FindFirstFileEx(pattern, FindExInfoStandard, &fd, FindExSearchNameMatch, NULL, 0); |
h = FindFirstFileEx(pattern, FindExInfoStandard, &fd, FindExSearchNameMatch, NULL, 0); |
if(h == INVALID_HANDLE_VALUE) { |
if(h == INVALID_HANDLE_VALUE) { |
exit(1); |
exit(1); |
Line 184 int main(int argc, char *argv[]) |
|
Line 184 int main(int argc, char *argv[]) |
|
{ |
{ |
int n; |
int n; |
char *indir,*outdir; |
char *indir,*outdir; |
char in[BUFSIZ],out[BUFSIZ]; |
char in[BUFSIZ],out[BUFSIZ],prefix_[BUFSIZ]; |
char *htmldir="html"; |
char *prefix,*lang; |
|
char help[BUFSIZ],base[BUFSIZ]; |
|
|
indir = argv[1]; |
indir = argv[1]; |
outdir = argv[2]; |
outdir = argv[2]; |
if(argc>3) { |
prefix = indir; |
htmldir=argv[3]; |
if(argc>3) { |
} |
lang = argv[3]; |
|
sprintf(base,"%s-%s",prefix,lang); |
sprintf(in,"%s/man_toc.html",indir); |
}else { |
sprintf(out,"%s/asirhelp.hhc",outdir); |
sprintf(base,"%s", "man"); |
conv_toc(in,out,htmldir); |
} |
n = find_files(indir, ""); |
sprintf(help,"%shelp",prefix); |
|
sprintf(prefix_,"%s_", base); |
sprintf(in,"%s/man_%d.html",indir,n); |
sprintf(in,"%s/%s_toc.html",indir,base); |
sprintf(out,"%s/asirhelp.hhk",outdir); |
sprintf(out,"%s/%s.hhc",outdir,help); |
conv_index(in,out,htmldir); |
conv_toc(in,out,prefix_,indir); |
sprintf(out,"%s/asirhelp.hhp",outdir); |
n = find_files(indir, base); |
gen_hhp(out,n,htmldir); |
sprintf(in,"%s/%s_%d.html",indir,base,n); |
exit(0); |
sprintf(out,"%s/%s.hhk",outdir,help); |
|
conv_index(in,out,prefix_,indir); |
|
sprintf(out,"%s/%s.hhp",outdir,help); |
|
gen_hhp(out,n,indir,base,help); |
|
return 0; |
} |
} |