/*
Generates html files for help under
${OpenXM_HOME}/doc/cfep/html-ja_JP.utf8
cf. ~/.cfep/html-ja_JP.utf8
mdimport ${OpenXM_HOME}/doc/cfep/html-ja_JP.utf8
*/
#include
#include
#include
#include
#include
#include
char *extractFileName(char *s);
char *extractFolderName(char *s);
int translate(char *dir,char *outputdirTop);
int Sjis = 0;
main(int argc, char *argv[]) {
char com[1024];
char workdir[1024];
char oxhome[1024];
int i;
if (argc < 2) {
fprintf(stderr,"gendoc foldernameOfHtmlHelp ... \n");
if (Sjis) fprintf(stderr," output to ${OpenXM_HOME}/doc/cfep/html-ja_JP.sjis\n");
else fprintf(stderr," output to ${OpenXM_HOME}/doc/cfep/html-ja_JP.utf8\n");
fprintf(stderr,"nkf is used.\n");
fprintf(stderr,"Example: gendoc ~/OX4/OpenXM/src/asir-doc/html-jp\n");
exit(0);
}
setlocale(LC_ALL,"C");
/* if ja_JP.eucJP is set, 01 is added to each bytes of argv[i] on mac. cf. misc/argvtest* */
/* A strange things will happen when japanese file names are used. */
if (!getenv("OpenXM_HOME")) {
fprintf(stderr,"OpenXM_HOME is not set.\n"); exit(1);
}
strcpy(oxhome,getenv("OpenXM_HOME"));
if (Sjis) sprintf(workdir,"%s/doc/cfep/html-ja_JP.sjis",oxhome);
else sprintf(workdir,"%s/doc/cfep/html-ja_JP.utf8",oxhome);
sprintf(com,"mkdir -p %s",workdir);
system(com);
for (i=1; i/tmp/tmp-gendoc.txt",dir);
system(com);
fp = fopen("/tmp/tmp-gendoc.txt","r");
while (fgets(longFname,1000,fp)) {
for (i=0; i\n\n");
else fprintf(fp2,"\n\n");
fclose(fp2);
if (Sjis) sprintf(com,"nkf -s %s | sed -e 's///g' >>%s",longFname,oname);
else sprintf(com,"nkf -w %s | sed -e 's///g' >>%s",longFname,oname);
printf("%s\n",com);
system(com);
}
system("rm -f /tmp/tmp-gendoc.txt");
return 0;
}
char *extractFileName(char *s) {
int i,n,start;
char *ans;
start = 0;
n = strlen(s);
ans = (char *)malloc(n+10);
strcpy(ans,"tmp.html");
for (i=n-1; i>=0; i--) {
if (s[i] == '/') {
start = i+1;
break;
}
}
if (start < n) strcpy(ans,&(s[start]));
for (i=0; i=0; i--) {
if (s[i] == '/') {
i--; end = i;
for ( ; i>=0; i--) {
if (s[i] == '/') {
start = i+1;
break;
}
}
break;
}
}
if ((start>=0) && (end >=0)) strcpy(ans,&(s[start]));
ans[end-start+1] = 0;
for (i=0; i