/* Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* This is an internal program,
* used to index modules for search engine. */
#include "../wims.h"
#include "../Lib/basicstr.c"
#define MAX_LANGS MAX_LANGUAGES
#define MAX_MODULES 65536
char *moduledir= "public_html/modules";
char *sheetdir= "public_html/bases/sheet";
char *dicdir= "public_html/bases";
char *outdir= "public_html/bases/site2";
char *maindic= "sys/words";
char *groupdic= "sys/wgrp/wgrp";
char *suffixdic= "sys/suffix";
char *ignoredic= "sys/indignore";
char *conffile= "log/wims.conf";
char *mlistbase= "list";
char lang[MAX_LANGS][4]={
"en","fr","cn","es","it","nl","si","ca","pt"
};
#define DEFAULT_LANGCNT 6
char allang[MAX_LANGS][4]={
"en","fr","cn","es","it","nl","tw","de","si","ca","pt"
};
#define allangcnt 8
char ignore[MAX_LANGS][MAX_LINELEN+1];
char mlistfile[MAX_LANGS][256];
int langcnt;
FILE *langf, *titf, *descf, *weightf, *robotf, *indf, *listf, *addrf, *serialf, *authorf, *versionf;
struct cat {
char *name;
char typ;
} cat[]={
{"all_types", 'A'},
{"exercise", 'X'},
{"oef", 'O'},
{"tool", 'T'},
{"recreation", 'R'},
{"reference", 'Y'},
{"document", 'D'},
{"popup", 'P'},
{"datamodule", 'M'}
};
#define catno (sizeof(cat)/sizeof(cat[0]))
struct mod {
char *name;
unsigned char langs[MAX_LANGS];
int counts[MAX_LANGS];
int langcnt;
} mod[MAX_MODULES];
int modcnt;
char *mlist;
void *xmalloc(size_t n)
{
void *p;
if(p==NULL) {
}
return p;
}
char *acctab="çéèêëúùûüáàâäãóòôöõíìïîñýÇÉÈÊËÚÙÛÜÁÀÂÃÄÓÒÔÖÕÍÌÏÎÑÝ",
*deatab="ceeeeuuuuaaaaaoooooiiiinyCEEEEUUUUAAAAAOOOOOIIIINY";
/* fold accented letters to unaccented */
void deaccent(char *p)
{
char *sp;
char *v;
for(sp=p;*sp;sp++) {
if(*sp
<0 && (v
=strchr(acctab
,*sp
))!=NULL
)
*sp=*(deatab+(v-acctab));
}
}
/* translate everything non-alphanumeric into space */
void towords(char *p)
{
char *pp;
for(pp
=p
;*pp
;pp
++) if(!isalnum(*pp
) && strchr("&$+*",*pp
)==0) *pp
=' ';
}
/* Points to the end of the word */
char *find_word_end(char *p)
{
int i;
for(i
=0;!isspace(*p
) && *p
!=0 && i
<MAX_LINELEN
; p
++,i
++);
return p;
}
/* Strips leading spaces */
char *find_word_start(char *p)
{
int i;
for(i
=0; isspace(*p
) && i
<MAX_LINELEN
; p
++,i
++);
return p;
}
/* Find first occurrence of word */
char *wordchr(char *p, char *w)
{
char *r;
return r;
}
/* find a variable in a string (math expression).
* Returns the pointer or NULL. */
char *varchr(char *p, char *v)
{
(!isalnum(*(pp
+n
)) || *(pp
+n
)==0)) break;
}
return pp;
}
/* strip trailing spaces; return string end. */
char *strip_trailing_spaces(char *p)
{
char *pp;
if(*p==0) return p;
return pp;
}
char *find_tag_end(char *p)
{
char *pp;
pp=p; if(*pp=='<') pp++;
for(; *pp && *pp!='>'; pp++) {
if(*pp=='<') {
pp=find_tag_end(pp)-1; continue;
}
if(*pp=='"') {
if(pp
==NULL
) return p
+strlen(p
); else continue;
}
if(*pp=='\'') {
if(pp
==NULL
) return p
+strlen(p
); else continue;
}
}
if(*pp=='>') pp++; return pp;
}
char *find_tag(char *p, char *tag)
{
char *pp;
int len;
for(pp
=strchr(p
,'<'); pp
!=NULL
&& *pp
; pp
=strchr(pp
+1,'<')) {
if(strncasecmp
(pp
+1,tag
,len
)==0 && !isalnum(*(pp
+1+len
))) return pp
;
}
}
/* remove all html tags */
void detag(char *p)
{
char *pp, *p2;
p2=find_tag_end(pp);
if(*p2==0) {*pp=0; return; }
ovlstrcpy(pp,p2);
}
}
/* modify a string. Bufferlen must be ast least MAX_LINELEN */
void string_modify(char *start, char *bad_beg, char *bad_end, char *good,...)
{
char buf[MAX_LINELEN+1];
va_list vp;
vsnprintf
(buf
,sizeof(buf
),good
,vp
); va_end(vp
);
if(strlen(start
)-(bad_end
-bad_beg
)+strlen(buf
)>=MAX_LINELEN
)
return;
ovlstrcpy(bad_beg,buf);
}
void _getdef(char buf[], char *name, char value[])
{
char *p1, *p2, *p3;
value[0]=0;
p2
=find_word_start
(p1
+strlen(name
));
if((p1
>buf
&& !isspace(*(p1
-1))) || *p2
!='=') continue;
p3
=p1
; while(p3
>buf
&& isspace(*(p3
-1)) && *(p3
-1)!='\n') p3
--;
if(p3>buf && *(p3-1)!='\n') continue;
p2=find_word_start(p2+1);
if(p3!=NULL && p3-p2<MAX_LINELEN) value[p3-p2]=0;
strip_trailing_spaces(value);
break;
}
}
/* Get variable definition from a file.
* Result stored in buffer value of length MAX_LINELEN. */
void getdef(char *fname, char *name, char value[])
{
FILE *f;
char *buf;
int l;
value[0]=0;
f
=fopen(fname
,"r"); if(f
==NULL
) return;
buf
=xmalloc
(l
+256); l
=fread(buf
,1,l
,f
);
if(l<=0) return; else buf[l]=0;
_getdef(buf,name,value);
}
#include "translator_.c"
char *mdicbuf, *gdicbuf;
char gentry[sizeof(entry)], mentry[sizeof(entry)];
int gentrycount, mentrycount;
/* Preparation of data */
void prep(void)
{
char buf[MAX_LINELEN+1];
char *p1,*p2,*s,*old;
int i,l,thislang,t;
FILE *f;
s
=getenv("modind_outdir"); if(s
!=NULL
&& *s
!=0) outdir
=s
;
s
=getenv("modind_sheetdir"); if(s
!=NULL
&& *s
!=0) sheetdir
=s
;
snprintf(buf
,sizeof(buf
),"%s/addr",outdir
);
snprintf(buf
,sizeof(buf
),"%s/serial",outdir
);
modcnt=langcnt=0;
getdef(conffile,"site_languages",buf);
for(p1
=buf
;*p1
;p1
++) if(!isalnum(*p1
)) *p1
=' ';
for(p1=find_word_start(buf); *p1 && langcnt<MAX_LANGS; p1=find_word_start(p2)) {
p2=find_word_end(p1);
memmove(lang
[langcnt
],p1
,2); lang
[langcnt
++][2]=0;
}
if(langcnt==0) { /* default languages */
langcnt=DEFAULT_LANGCNT;
}
l
=strlen(s
); if(l
<0 || l
>100*MAX_LINELEN
) exit(1);
mlist=xmalloc(l+16); ovlstrcpy(mlist,s); old="";
for(i=0;i<langcnt;i++) {
snprintf(buf
,sizeof(buf
),"%s/%s.%s",dicdir
,ignoredic
,lang
[i
]);
f
=fopen(buf
,"r"); if(f
==NULL
) continue;
if(l<0 || l>=MAX_LINELEN) l=0;
ignore[i][l]=0;
}
for(t=0, p1=find_word_start(mlist);
*p1 && modcnt<MAX_MODULES;
p1=find_word_start(p2), t++) {
p2=find_word_end(p1);
l=p2-p1; if(*p2) *p2++=0;
thislang=-1;
if(l>3 && p1[l-3]=='.') {
for(i=0;i<langcnt;i++) if(strcasecmp(lang[i],p1+l-2)==0) break;
if(i<langcnt) {p1[l-3]=0; thislang=i;}
else { /* unknown language, not referenced */
continue;
}
}
if(modcnt
>0 && strcmp(old
,p1
)==0 && thislang
>=0) {
if(mod[modcnt-1].langcnt<langcnt) {
mod[modcnt-1].langs[mod[modcnt-1].langcnt]=thislang;
mod[modcnt-1].counts[mod[modcnt-1].langcnt]=t;
(mod[modcnt-1].langcnt)++;
}
}
else {
mod[modcnt].name=old=p1;
if(thislang>=0) {
mod[modcnt].langs[0]=thislang;
mod[modcnt].langcnt=1;
}
else mod[modcnt].langcnt=0;
mod[modcnt].counts[0]=t;
modcnt++;
}
}
snprintf(buf
,sizeof(buf
),"%s/language",outdir
);
snprintf(buf
,sizeof(buf
),"%s/title",outdir
);
snprintf(buf
,sizeof(buf
),"%s/description",outdir
);
snprintf(buf
,sizeof(buf
),"%s/author",outdir
);
snprintf(buf
,sizeof(buf
),"%s/version",outdir
);
snprintf(buf
,sizeof(buf
),"%s/lists/robot.phtml",outdir
);
if(!robotf || !versionf || !authorf || !descf || !titf || !descf) {
fprintf(stderr
,"modind: error creating output files.\n");
}
}
void sprep(void)
{
char *p1,*p2,*s;
int i,l,thislang;
modcnt=0;
s
=getenv("slist"); if(s
==NULL
) return;
l
=strlen(s
); if(l
<0 || l
>100*MAX_LINELEN
) return;
mlist=xmalloc(l+16); ovlstrcpy(mlist,s);
for(p1=find_word_start(mlist); *p1 && modcnt<MAX_MODULES; p1=find_word_start(p2)) {
p2=find_word_end(p1);
l=p2-p1; if(*p2) *p2++=0;
for(i=0;i<langcnt;i++) if(strncasecmp(lang[i],p1,2)==0) break;
if(i<langcnt) thislang=i; else continue;
mod[modcnt].name=p1;
mod[modcnt].langs[0]=thislang;
mod[modcnt].langcnt=1;
modcnt++;
}
}
void clean(void)
{
}
char *sheetindex[]={
"title", "description",
"duration", "severity",
"level", "domain",
"keywords", "reserved1", "reserved2", "remark"
};
#define SHEETINDEX_NO (sizeof(sheetindex)/sizeof(sheetindex[0]))
char sindbuf[SHEETINDEX_NO][MAX_LINELEN+1];
enum{s_title, s_description,
s_duration, s_severity,
s_level, s_domain,
s_keywords, s_reserved1, s_reserved2,
s_remark
};
char *modindex[]={
"title", "description",
"author", "address", "copyright",
"version", "wims_version", "language",
"category", "level", "domain", "keywords",
"require"
};
#define MODINDEX_NO (sizeof(modindex)/sizeof(modindex[0]))
char indbuf[MODINDEX_NO][MAX_LINELEN+1];
enum{i_title, i_description,
i_author,i_address,i_copyright,
i_version,i_wims_version,i_language,
i_category,i_level,i_domain,i_keywords,
i_require
};
char *module_special_file[]={
"intro","help","about"
};
#define MODSPEC_NO (sizeof(module_special_file)/sizeof(module_special_file[0]))
char module_language[4];
/* read and treat module's INDEX file */
int module_index(const char *name)
{
char *p, fbuf[MAX_LINELEN+1], ibuf[MAX_LINELEN+1];
FILE *indf;
int i,l;
snprintf(fbuf
,sizeof(fbuf
),"%s/%s/INDEX",moduledir
,name
);
indf
=fopen(fbuf
,"r"); if(indf
==NULL
) return -1;
if(l>0 && l<MAX_LINELEN) ibuf[l]=0; else return -1;
for(i=0;i<MODINDEX_NO;i++) {
_getdef(ibuf,modindex[i],indbuf[i]);
/* compatibility precaution */
if(indbuf[i][0]==':') indbuf[i][0]='.';
}
p=find_word_start(indbuf[i_language]);
memmove(module_language
,p
,2); module_language
[2]=0;
}
else ovlstrcpy(module_language,"en");
return 0;
}
int sheet_index(int serial)
{
char *p1, *p2, fbuf[MAX_LINELEN+1], ibuf[MAX_LINELEN+1];
FILE *indf;
int i,l;
snprintf(fbuf
,sizeof(fbuf
),"%s/%s.def",sheetdir
,mod
[serial
].
name);
indf
=fopen(fbuf
,"r"); if(indf
==NULL
) return -1;
if(l>0 && l<MAX_LINELEN) ibuf[l]=0; else return -1;
for(i=0;i<SHEETINDEX_NO;i++) sindbuf[i][0]=0;
for(i=0,p1=find_word_start(ibuf);
i<SHEETINDEX_NO-1 && *p1!=':' && *p1!=0;
i++,p1=p2) {
if(p2
!=NULL
) *p2
++=0; else p2
=p1
+strlen(p1
);
p1=find_word_start(p1); strip_trailing_spaces(p1);
snprintf(sindbuf
[i
],MAX_LINELEN
,"%s",p1
);
}
else *p2=0;
p1=find_word_start(p1); strip_trailing_spaces(p1);
for(p2=p1;*p2;p2++) if(*p2=='\n') *p2=' ';
ovlstrcpy(sindbuf[s_remark],p1);
return 0;
}
unsigned char categories[16];
char taken[MAX_LINELEN+1];
int catcnt, takenlen, tweight;
void appenditem(char *word, int lind, int serial, int weight, char *l)
{
char nbuf[MAX_LINELEN+1], buf[MAX_LINELEN+1];
int i, ll;
char *p;
FILE *f;
wordchr(taken,word)!=NULL ||
wordchr(ignore[lind],word)!=NULL ||
takenlen>=MAX_LINELEN-ll-16)
return;
for(p
=word
;*p
;p
++) if(!isalnum(*p
) && *p
!=' ') return;
taken[takenlen++]=' '; taken[takenlen++]=' ';
ovlstrcpy(taken+takenlen,word);
takenlen+=ll; tweight+=weight;
snprintf(buf
,sizeof(buf
),"%s:%d?%d\n",word
,serial
,weight
);
for(i=0;i<catcnt;i++) {
outdir,categories[i],lang[lind]);
}
}
void onemodule(const char *name, int serial, int lind)
{
int i;
unsigned char trlist[]={
i_title,i_description,i_category,i_domain,i_keywords,
i_require,i_author
};
#define trcnt (sizeof(trlist)/sizeof(trlist[0]))
char *p1, *p2, *pp, buf[MAX_LINELEN+1], lbuf[16];
FILE *f;
if(module_index(name)) return;
towords(indbuf[i_category]);
for(i=catcnt=0;i<catno && catcnt<16;i++) {
if(wordchr(indbuf[i_category],cat[i].name)!=NULL)
categories[catcnt++]=cat[i].typ;
}
if(catcnt==0) return;
if(categories[0]!=cat[0].typ)
categories[catcnt++]=cat[0].typ;
for(i=0;i<catcnt;i++) {
snprintf(buf
,sizeof(buf
),"%s/lists/%c.%s",
outdir,categories[i],lang[lind]);
}
fprintf(langf
,"%d:%s\n",serial
,module_language
);
fprintf(titf
,"%d:%s\n",serial
,indbuf
[i_title
]);
fprintf(descf
,"%d:%s\n",serial
,indbuf
[i_description
]);
fprintf(authorf
,"%d:%s\n",serial
,indbuf
[i_author
]);
fprintf(versionf
,"%d:%s\n",serial
,indbuf
[i_version
]);
snprintf(buf
,sizeof(buf
),"%s",indbuf
[i_description
]);
string_modify(buf,pp,pp+1,",");
if(strcmp(module_language
,lang
[lind
])==0)
fprintf(robotf
,"%s ,%s,%s,%s,%s\n",name
,module_language
,name
,
indbuf[i_title], buf);
entrycount=mentrycount; dicbuf=mdicbuf;
memmove(entry
,mentry
,mentrycount
*sizeof(entry
[0]));
unknown_type=unk_leave;
for(i=0;i<trcnt;i++) {
detag(indbuf[trlist[i]]);
deaccent(indbuf[trlist[i]]);
singlespace(indbuf[trlist[i]]);
suffix_translate(indbuf[trlist[i]]);
translate(indbuf[trlist[i]]);
}
taken[0]=0; takenlen=tweight=0;
ovlstrcpy(buf,indbuf[i_title]); towords(buf);
for(p1=find_word_start(buf);*p1;
p1=find_word_start(p2)) {
p2=find_word_end(p1); if(*p2) *p2++=0;
appenditem(p1,lind,serial,4,module_language);
}
snprintf(buf
,sizeof(buf
),"%s %s %s %s %s",
indbuf[i_description],indbuf[i_keywords],
indbuf[i_domain],indbuf[i_require],indbuf[i_author]);
towords(buf);
for(p1=find_word_start(buf);*p1;
p1=find_word_start(p2)) {
p2=find_word_end(p1); if(*p2) *p2++=0;
appenditem(p1,lind,serial,2,module_language);
}
entrycount=gentrycount; dicbuf=gdicbuf;
memmove(entry
,gentry
,gentrycount
*sizeof(entry
[0]));
unknown_type=unk_delete;
ovlstrcpy(buf,indbuf[i_title]); translate(buf);
for(p1=find_word_start(buf); *p1;
p1=find_word_start(p2)) {
if(p2
!=NULL
) *p2
++=0; else p2
=p1
+strlen(p1
);
appenditem(p1,lind,serial,4,module_language);
}
indbuf[i_description],indbuf[i_keywords],
indbuf[i_domain]);
translate(buf);
for(p1=find_word_start(buf); *p1;
p1=find_word_start(p2)) {
if(p2
!=NULL
) *p2
++=0; else p2
=p1
+strlen(p1
);
appenditem(p1,lind,serial,2,module_language);
}
snprintf(buf
,sizeof(buf
),"%s",indbuf
[i_level
]);
ovlstrcpy(lbuf,"level");
for(p1
=buf
; *p1
; p1
++) if(!isalnum(*p1
)) *p1
=' ';
for(p1=find_word_start(buf); *p1;
p1=find_word_start(p2)) {
p2=find_word_end(p1);
if(p2
!=NULL
) *p2
++=0; else p2
=p1
+strlen(p1
);
(!isdigit(*(p1
+1)) && *(p1
+1)!=0) ||
(*(p1+1)!=0 && *(p1+2)!=0))
continue;
ovlstrcpy
(lbuf
+strlen("level"),p1
);
appenditem(lbuf,lind,serial,2,module_language);
}
fprintf(weightf
,"%d:%d\n",serial
,tweight
);
}
void modules(void)
{
int i,j,k,d;
char namebuf[MAX_LINELEN+1];
char mdic[MAX_LINELEN+1], sdic[MAX_LINELEN+1], gdic[MAX_LINELEN+1];
for(j=0;j<langcnt;j++) {
snprintf(namebuf
,sizeof(namebuf
),"%s/weight.%s",outdir
,lang
[j
]);
weightf
=fopen(namebuf
,"w");
snprintf(mdic
,sizeof(mdic
),"%s/%s.%s",dicdir
,maindic
,lang
[j
]);
snprintf(sdic
,sizeof(sdic
),"%s/%s.%s",dicdir
,suffixdic
,lang
[j
]);
snprintf(gdic
,sizeof(gdic
),"%s/%s.%s",dicdir
,groupdic
,lang
[j
]);
suffix_dic(sdic); prepare_dic(gdic);
gdicbuf=dicbuf; gentrycount=entrycount;
memmove(gentry
,entry
,gentrycount
*sizeof(entry
[0]));
prepare_dic(mdic);
mdicbuf=dicbuf; mentrycount=entrycount;
memmove(mentry
,entry
,mentrycount
*sizeof(entry
[0]));
unknown_type=unk_leave; translate(ignore[j]);
for(i=0;i<modcnt;i++) {
if(mod[i].langcnt>0) {
for(d=k=0;k<mod[i].langcnt;k++)
if(mod[i].langs[k]<mod[i].langs[d]) d=k;
for(k=0;k<mod[i].langcnt && mod[i].langs[k]!=j;k++);
if(k>=mod[i].langcnt) k=d;
snprintf(namebuf
,MAX_LINELEN
,"%s.%s",mod
[i
].
name,
lang[mod[i].langs[k]]);
onemodule(namebuf,mod[i].counts[k],j);
}
else {
onemodule(mod[i].name,mod[i].counts[0],j);
}
}
if(mentrycount
>0) free(mdicbuf
);
if(gentrycount
>0) free(gdicbuf
);
if(suffixcnt
>0) free(sufbuf
);
}
}
void sappenditem(char *word, int lind, int serial, int weight)
{
int ll;
char *p;
wordchr(taken,word)!=NULL ||
wordchr(ignore[lind],word)!=NULL ||
takenlen>=MAX_LINELEN-ll-16)
return;
for(p
=word
;*p
;p
++) if(!isalnum(*p
) && *p
!=' ') return;
taken[takenlen++]=' ';taken[takenlen++]=' ';
ovlstrcpy(taken+takenlen,word);
takenlen+=ll; tweight+=weight;
fprintf(indf
,"%s:%d?%d\n",word
,serial
,weight
);
}
void onesheet(int serial, int lind)
{
int i;
unsigned char trlist[]={
s_title,s_description,s_domain,s_keywords,s_remark
};
#define trcnt (sizeof(trlist)/sizeof(trlist[0]))
char *p1, *p2, buf[MAX_LINELEN+1];
if(sheet_index(serial)) return;
fprintf(listf
,"%s\n",mod
[serial
].
name+3);
fprintf(titf
,"%d:%s\n",serial
,sindbuf
[s_title
]);
fprintf(descf
,"%d:%s\n",serial
,sindbuf
[s_description
]);
entrycount=mentrycount; dicbuf=mdicbuf;
memmove(entry
,mentry
,mentrycount
*sizeof(entry
[0]));
unknown_type=unk_leave;
for(i=0;i<trcnt;i++) {
detag(sindbuf[trlist[i]]);
deaccent(sindbuf[trlist[i]]);
singlespace(sindbuf[trlist[i]]);
suffix_translate(sindbuf[trlist[i]]);
translate(sindbuf[trlist[i]]);
}
taken[0]=0; takenlen=tweight=0;
ovlstrcpy(buf,sindbuf[s_title]); towords(buf);
for(p1=find_word_start(buf);*p1;
p1=find_word_start(p2)) {
p2=find_word_end(p1); if(*p2) *p2++=0;
sappenditem(p1,lind,serial,4);
}
sindbuf[s_description],sindbuf[s_keywords],
sindbuf[s_domain],sindbuf[s_remark]);
towords(buf);
for(p1=find_word_start(buf);*p1;
p1=find_word_start(p2)) {
p2=find_word_end(p1); if(*p2) *p2++=0;
sappenditem(p1,lind,serial,2);
}
entrycount=gentrycount; dicbuf=gdicbuf;
memmove(entry
,gentry
,gentrycount
*sizeof(entry
[0]));
unknown_type=unk_delete;
ovlstrcpy(buf,sindbuf[s_title]); translate(buf);
for(p1=find_word_start(buf); *p1;
p1=find_word_start(p2)) {
if(p2
!=NULL
) *p2
++=0; else p2
=p1
+strlen(p1
);
sappenditem(p1,lind,serial,4);
}
snprintf(buf
,sizeof(buf
),"%s, %s, %s, %s",
sindbuf[s_description],sindbuf[s_keywords],
sindbuf[s_domain],sindbuf[s_remark]);
translate(buf);
for(p1=find_word_start(buf); *p1;
p1=find_word_start(p2)) {
if(p2
!=NULL
) *p2
++=0; else p2
=p1
+strlen(p1
);
sappenditem(p1,lind,serial,2);
}
fprintf(weightf
,"%d:%d\n",serial
,tweight
);
}
void sheets(void)
{
int i,j;
char mdic[MAX_LINELEN+1], sdic[MAX_LINELEN+1], gdic[MAX_LINELEN+1];
char buf[MAX_LINELEN+1];
for(j=0;j<langcnt;j++) {
snprintf(buf
,sizeof(buf
),"%s/index/title.%s",sheetdir
,lang
[j
]);
snprintf(buf
,sizeof(buf
),"%s/index/description.%s",sheetdir
,lang
[j
]);
snprintf(buf
,sizeof(buf
),"%s/index/%s",sheetdir
,lang
[j
]);
snprintf(buf
,sizeof(buf
),"%s/index/list.%s",sheetdir
,lang
[j
]);
snprintf(buf
,sizeof(buf
),"%s/index/weight.%s",sheetdir
,lang
[j
]);
snprintf(buf
,sizeof(buf
),"%s/index/addr.%s",sheetdir
,lang
[j
]);
snprintf(buf
,sizeof(buf
),"%s/index/serial.%s",sheetdir
,lang
[j
]);
snprintf(mdic
,sizeof(mdic
),"%s/%s.%s",dicdir
,maindic
,lang
[j
]);
snprintf(sdic
,sizeof(sdic
),"%s/%s.%s",dicdir
,suffixdic
,lang
[j
]);
snprintf(gdic
,sizeof(gdic
),"%s/%s.%s",dicdir
,groupdic
,lang
[j
]);
suffix_dic(sdic); prepare_dic(gdic);
gdicbuf=dicbuf; gentrycount=entrycount;
memmove(gentry
,entry
,gentrycount
*sizeof(entry
[0]));
prepare_dic(mdic);
mdicbuf=dicbuf; mentrycount=entrycount;
memmove(mentry
,entry
,mentrycount
*sizeof(entry
[0]));
unknown_type=unk_leave; translate(ignore[j]);
for(i=0;i<modcnt;i++) {
if(mod[i].langs[0]!=j) continue;
fprintf(addrf
,"%d:%s\n",i
,mod
[i
].
name+3);
fprintf(serialf
,"%s:%d\n",mod
[i
].
name+3,i
);
onesheet(i,j);
}
if(mentrycount
>0) free(mdicbuf
);
if(gentrycount
>0) free(gdicbuf
);
if(suffixcnt
>0) free(sufbuf
);
}
}
int main()
{
prep();
if(modcnt>0) modules();
clean();
sprep();
if(modcnt>0) sheets();
return 0;
}