Rev 8123 | Rev 8185 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10 | reyssat | 1 | /* Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis |
2 | * |
||
3 | * This program is free software; you can redistribute it and/or modify |
||
4 | * it under the terms of the GNU General Public License as published by |
||
5 | * the Free Software Foundation; either version 2 of the License, or |
||
6 | * (at your option) any later version. |
||
7 | * |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
11 | * GNU General Public License for more details. |
||
12 | * |
||
13 | * You should have received a copy of the GNU General Public License |
||
14 | * along with this program; if not, write to the Free Software |
||
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||
16 | */ |
||
17 | |||
6884 | bpr | 18 | /* This is an internal program, |
7915 | bpr | 19 | * used to index modules for search engine. |
6884 | bpr | 20 | */ |
10 | reyssat | 21 | |
22 | #include "../wims.h" |
||
8100 | bpr | 23 | #include "../Lib/libwims.h" |
8123 | bpr | 24 | #include "translator_.h" |
25 | #include "suffix.h" |
||
10 | reyssat | 26 | |
6884 | bpr | 27 | #define MAX_LANGS MAX_LANGUAGES |
28 | #define MAX_MODULES 65536 |
||
29 | char *moduledir= "public_html/modules"; |
||
30 | char *sheetdir= "public_html/bases/sheet"; |
||
31 | char *dicdir= "public_html/bases"; |
||
32 | char *outdir= "public_html/bases/site2"; |
||
33 | char *maindic= "sys/words"; |
||
34 | char *groupdic= "sys/wgrp/wgrp"; |
||
35 | char *suffixdic= "sys/suffix"; |
||
36 | char *domaindic= "sys/domaindic"; |
||
37 | char *ignoredic= "sys/indignore"; |
||
38 | char *conffile= "log/wims.conf"; |
||
39 | char *mlistbase= "list"; |
||
10 | reyssat | 40 | |
41 | char lang[MAX_LANGS][4]={ |
||
1792 | bpr | 42 | "en","fr","cn","es","it","nl","si","ca","pt" |
10 | reyssat | 43 | }; |
6884 | bpr | 44 | #define DEFAULT_LANGCNT 6 |
10 | reyssat | 45 | char allang[MAX_LANGS][4]={ |
6564 | bpr | 46 | "en","fr","cn","es","it","nl","de","si","ca","pt" |
10 | reyssat | 47 | }; |
48 | #define allangcnt 8 |
||
49 | char ignore[MAX_LANGS][MAX_LINELEN+1]; |
||
50 | char mlistfile[MAX_LANGS][256]; |
||
51 | int langcnt; |
||
6961 | bpr | 52 | FILE *langf, *titf, *descf, *weightf, *robotf, *indf, *listf, *addrf, *serialf, *authorf, *versionf, *remf; |
10 | reyssat | 53 | |
54 | struct cat { |
||
55 | char *name; |
||
56 | char typ; |
||
57 | } cat[]={ |
||
6884 | bpr | 58 | {"all_types", 'A'}, |
59 | {"exercise", 'X'}, |
||
60 | {"oef", 'O'}, |
||
61 | {"tool", 'T'}, |
||
62 | {"recreation",'R'}, |
||
63 | {"reference", 'Y'}, |
||
64 | {"document", 'D'}, |
||
65 | {"popup", 'P'}, |
||
66 | {"datamodule",'M'} |
||
10 | reyssat | 67 | }; |
68 | #define catno (sizeof(cat)/sizeof(cat[0])) |
||
69 | |||
70 | struct mod { |
||
71 | char *name; |
||
72 | unsigned char langs[MAX_LANGS]; |
||
73 | int counts[MAX_LANGS]; |
||
74 | int langcnt; |
||
75 | } mod[MAX_MODULES]; |
||
76 | int modcnt; |
||
77 | |||
78 | char *mlist; |
||
79 | |||
6884 | bpr | 80 | /* fold known accented letters to unaccented, other strange characters to space |
7915 | bpr | 81 | * apostrophe is among the exceptions to be kept (important for multi-word expressions) |
6884 | bpr | 82 | */ |
8100 | bpr | 83 | void deaccent2(char *p) |
10 | reyssat | 84 | { |
3247 | bpr | 85 | char *sp; |
10 | reyssat | 86 | char *v; |
87 | for(sp=p;*sp;sp++) { |
||
6884 | bpr | 88 | if(*sp<0 && (v=strchr(acctab,*sp))!=NULL) |
89 | *sp=*(deatab+(v-acctab)); |
||
90 | if(!isalnum(*sp) && strchr(",.&$+*",*sp)==0) *sp=' '; |
||
91 | else *sp=tolower(*sp); |
||
10 | reyssat | 92 | } |
93 | } |
||
94 | |||
6884 | bpr | 95 | /* translate everything non-alphanumeric into space */ |
10 | reyssat | 96 | void towords(char *p) |
97 | { |
||
98 | char *pp; |
||
99 | for(pp=p;*pp;pp++) if(!isalnum(*pp) && strchr("&$+*",*pp)==0) *pp=' '; |
||
100 | } |
||
101 | |||
6884 | bpr | 102 | /* Find first occurrence of word */ |
8100 | bpr | 103 | char *wordchr2(char *p, char *w) |
10 | reyssat | 104 | { |
105 | char *r; |
||
106 | |||
6881 | bpr | 107 | for(r=strstr(p,w);r!=NULL && |
6884 | bpr | 108 | ( (r>p && !isspace(*(r-1))) || (!isspace(*(r+strlen(w))) && *(r+strlen(w))!=0) ); |
109 | r=strstr(r+1,w)); |
||
10 | reyssat | 110 | return r; |
111 | } |
||
112 | |||
6884 | bpr | 113 | /* strip trailing spaces; return string end. */ |
8100 | bpr | 114 | char *strip_trailing_spaces2(char *p) |
10 | reyssat | 115 | { |
116 | char *pp; |
||
117 | if(*p==0) return p; |
||
118 | for(pp=p+strlen(p)-1; pp>=p && isspace(*pp); *(pp--)=0); |
||
119 | return pp; |
||
120 | } |
||
121 | |||
122 | char *find_tag_end(char *p) |
||
123 | { |
||
124 | char *pp; |
||
125 | pp=p; if(*pp=='<') pp++; |
||
126 | for(; *pp && *pp!='>'; pp++) { |
||
6884 | bpr | 127 | if(*pp=='<') { |
128 | pp=find_tag_end(pp)-1; continue; |
||
10 | reyssat | 129 | } |
6884 | bpr | 130 | if(*pp=='"') { |
131 | pp=strchr(pp+1,'"'); |
||
132 | if(pp==NULL) return p+strlen(p); else continue; |
||
133 | } |
||
134 | if(*pp=='\'') { |
||
135 | pp=strchr(pp+1,'\''); |
||
136 | if(pp==NULL) return p+strlen(p); else continue; |
||
137 | } |
||
138 | } |
||
10 | reyssat | 139 | if(*pp=='>') pp++; return pp; |
140 | } |
||
141 | |||
142 | char *find_tag(char *p, char *tag) |
||
143 | { |
||
144 | char *pp; |
||
145 | int len; |
||
146 | len=strlen(tag); |
||
147 | for(pp=strchr(p,'<'); pp!=NULL && *pp; pp=strchr(pp+1,'<')) { |
||
6884 | bpr | 148 | if(strncasecmp(pp+1,tag,len)==0 && !isalnum(*(pp+1+len))) return pp; |
10 | reyssat | 149 | } |
150 | return p+strlen(p); |
||
151 | } |
||
152 | |||
6884 | bpr | 153 | /* remove all html tags */ |
10 | reyssat | 154 | void detag(char *p) |
155 | { |
||
156 | char *pp, *p2; |
||
157 | for(pp=strchr(p,'<'); pp!=NULL; pp=strchr(pp,'<')) { |
||
6884 | bpr | 158 | p2=find_tag_end(pp); |
159 | if(*p2==0) {*pp=0; return; } |
||
160 | ovlstrcpy(pp,p2); |
||
10 | reyssat | 161 | } |
162 | } |
||
163 | |||
6884 | bpr | 164 | /* modify a string. Bufferlen must be at least MAX_LINELEN */ |
8100 | bpr | 165 | void string_modify3(char *start, char *bad_beg, char *bad_end, char *good,...) |
10 | reyssat | 166 | { |
167 | char buf[MAX_LINELEN+1]; |
||
168 | va_list vp; |
||
6881 | bpr | 169 | |
10 | reyssat | 170 | va_start(vp,good); |
171 | vsnprintf(buf,sizeof(buf),good,vp); va_end(vp); |
||
172 | if(strlen(start)-(bad_end-bad_beg)+strlen(buf)>=MAX_LINELEN) |
||
8100 | bpr | 173 | return; /* this is an error situation. */ |
10 | reyssat | 174 | strcat(buf,bad_end); |
3718 | reyssat | 175 | ovlstrcpy(bad_beg,buf); |
10 | reyssat | 176 | } |
177 | |||
6819 | reyssat | 178 | /* add a space after comma to see end of words */ |
179 | |||
180 | void comma(char *p) |
||
181 | { |
||
182 | char *pp; |
||
183 | for(pp=strchr(p,','); pp; pp=strchr(pp+1,',')) |
||
8100 | bpr | 184 | string_modify3(p,pp,pp+1,", "); |
6819 | reyssat | 185 | } |
186 | |||
10 | reyssat | 187 | void _getdef(char buf[], char *name, char value[]) |
188 | { |
||
189 | char *p1, *p2, *p3; |
||
190 | |||
191 | value[0]=0; |
||
192 | for(p1=strstr(buf,name); p1!=NULL; p1=strstr(p1+1,name)) { |
||
6884 | bpr | 193 | p2=find_word_start(p1+strlen(name)); |
194 | if((p1>buf && !isspace(*(p1-1))) || *p2!='=') continue; |
||
195 | p3=p1; while(p3>buf && isspace(*(p3-1)) && *(p3-1)!='\n') p3--; |
||
196 | if(p3>buf && *(p3-1)!='\n') continue; |
||
197 | p3=strchr(p2,'\n'); |
||
198 | p2=find_word_start(p2+1); |
||
199 | if(p3 <= p2) continue; |
||
200 | snprintf(value,MAX_LINELEN,"%s",p2); |
||
201 | if(p3!=NULL && p3-p2<MAX_LINELEN) value[p3-p2]=0; |
||
8100 | bpr | 202 | strip_trailing_spaces2(value); |
6884 | bpr | 203 | break; |
10 | reyssat | 204 | } |
205 | } |
||
206 | |||
6884 | bpr | 207 | /* Get variable definition from a file. |
208 | * Result stored in buffer value of length MAX_LINELEN. |
||
209 | */ |
||
10 | reyssat | 210 | void getdef(char *fname, char *name, char value[]) |
211 | { |
||
212 | FILE *f; |
||
213 | char *buf; |
||
214 | int l; |
||
6881 | bpr | 215 | |
10 | reyssat | 216 | value[0]=0; |
217 | f=fopen(fname,"r"); if(f==NULL) return; |
||
218 | fseek(f,0,SEEK_END); l=ftell(f); fseek(f,0,SEEK_SET); |
||
219 | buf=xmalloc(l+256); l=fread(buf,1,l,f); |
||
220 | fclose(f); |
||
221 | if(l<=0) return; else buf[l]=0; |
||
222 | _getdef(buf,name,value); |
||
223 | free(buf); |
||
224 | } |
||
225 | |||
8123 | bpr | 226 | char *mdicbuf, *gdicbuf, *ddicbuf, *gentry, *mentry, *dentry; |
10 | reyssat | 227 | |
6881 | bpr | 228 | int gentrycount, mentrycount, dentrycount; |
10 | reyssat | 229 | |
6884 | bpr | 230 | /* Preparation of data */ |
10 | reyssat | 231 | void prep(void) |
232 | { |
||
233 | char buf[MAX_LINELEN+1]; |
||
234 | char *p1,*p2,*s,*old; |
||
235 | int i,l,thislang,t; |
||
236 | FILE *f; |
||
6881 | bpr | 237 | |
10 | reyssat | 238 | s=getenv("modind_outdir"); if(s!=NULL && *s!=0) outdir=s; |
239 | s=getenv("modind_sheetdir"); if(s!=NULL && *s!=0) sheetdir=s; |
||
240 | snprintf(buf,sizeof(buf),"%s/addr",outdir); |
||
241 | addrf=fopen(buf,"w"); |
||
242 | snprintf(buf,sizeof(buf),"%s/serial",outdir); |
||
243 | serialf=fopen(buf,"w"); |
||
244 | modcnt=langcnt=0; |
||
6884 | bpr | 245 | /* take the langs declared in conffile */ |
10 | reyssat | 246 | getdef(conffile,"site_languages",buf); |
247 | for(p1=buf;*p1;p1++) if(!isalnum(*p1)) *p1=' '; |
||
248 | for(p1=find_word_start(buf); *p1 && langcnt<MAX_LANGS; p1=find_word_start(p2)) { |
||
6884 | bpr | 249 | p2=find_word_end(p1); |
250 | if(p2!=p1+2 || !isalpha(*p1) || !isalpha(*(p1+1))) continue; |
||
251 | memmove(lang[langcnt],p1,2); lang[langcnt++][2]=0; |
||
10 | reyssat | 252 | } |
6884 | bpr | 253 | if(langcnt==0) {/* default languages */ |
254 | langcnt=DEFAULT_LANGCNT; |
||
10 | reyssat | 255 | } |
256 | s=getenv("mlist"); if(s==NULL) exit(1); |
||
257 | l=strlen(s); if(l<0 || l>100*MAX_LINELEN) exit(1); |
||
3718 | reyssat | 258 | mlist=xmalloc(l+16); ovlstrcpy(mlist,s); old=""; |
10 | reyssat | 259 | for(i=0;i<langcnt;i++) { |
6884 | bpr | 260 | snprintf(buf,sizeof(buf),"%s/%s.%s",dicdir,ignoredic,lang[i]); |
261 | f=fopen(buf,"r"); if(f==NULL) continue; |
||
262 | l=fread(ignore[i],1,MAX_LINELEN,f);fclose(f); |
||
263 | if(l<0 || l>=MAX_LINELEN) l=0; |
||
264 | ignore[i][l]=0; |
||
10 | reyssat | 265 | } |
266 | for(t=0, p1=find_word_start(mlist); |
||
6884 | bpr | 267 | *p1 && modcnt<MAX_MODULES; |
268 | p1=find_word_start(p2), t++) { |
||
269 | p2=find_word_end(p1); |
||
270 | l=p2-p1; if(*p2) *p2++=0; |
||
271 | fprintf(addrf,"%d:%s\n",t,p1); |
||
272 | fprintf(serialf,"%s:%d\n",p1,t); |
||
273 | thislang=-1; |
||
6564 | bpr | 274 | /* language is taken from the address */ |
6884 | bpr | 275 | if(l>3 && p1[l-3]=='.') { |
276 | for(i=0;i<langcnt;i++) if(strcasecmp(lang[i],p1+l-2)==0) break; |
||
277 | if(i<langcnt) {p1[l-3]=0; thislang=i;} |
||
278 | else {/* unknown language, not referenced */ |
||
279 | continue; |
||
280 | } |
||
10 | reyssat | 281 | } |
6884 | bpr | 282 | if(modcnt>0 && strcmp(old,p1)==0 && thislang>=0) { |
283 | if(mod[modcnt-1].langcnt<langcnt) { |
||
284 | mod[modcnt-1].langs[mod[modcnt-1].langcnt]=thislang; |
||
285 | mod[modcnt-1].counts[mod[modcnt-1].langcnt]=t; |
||
286 | (mod[modcnt-1].langcnt)++; |
||
287 | } |
||
288 | } |
||
289 | else { |
||
290 | mod[modcnt].name=old=p1; |
||
291 | if(thislang>=0) { |
||
292 | mod[modcnt].langs[0]=thislang; |
||
293 | mod[modcnt].langcnt=1; |
||
294 | } |
||
295 | else mod[modcnt].langcnt=0; |
||
296 | mod[modcnt].counts[0]=t; |
||
297 | modcnt++; |
||
298 | } |
||
299 | } |
||
10 | reyssat | 300 | snprintf(buf,sizeof(buf),"%s/language",outdir); |
301 | langf=fopen(buf,"w"); |
||
302 | snprintf(buf,sizeof(buf),"%s/title",outdir); |
||
303 | titf=fopen(buf,"w"); |
||
304 | snprintf(buf,sizeof(buf),"%s/description",outdir); |
||
305 | descf=fopen(buf,"w"); |
||
306 | snprintf(buf,sizeof(buf),"%s/author",outdir); |
||
307 | authorf=fopen(buf,"w"); |
||
308 | snprintf(buf,sizeof(buf),"%s/version",outdir); |
||
309 | versionf=fopen(buf,"w"); |
||
310 | snprintf(buf,sizeof(buf),"%s/lists/robot.phtml",outdir); |
||
311 | robotf=fopen(buf,"w"); |
||
312 | fclose(addrf); fclose(serialf); |
||
313 | if(!robotf || !versionf || !authorf || !descf || !titf || !descf) { |
||
6884 | bpr | 314 | fprintf(stderr,"modind: error creating output files.\n"); |
315 | exit(1); |
||
10 | reyssat | 316 | } |
317 | } |
||
318 | |||
319 | void sprep(void) |
||
320 | { |
||
321 | char *p1,*p2,*s; |
||
322 | int i,l,thislang; |
||
6881 | bpr | 323 | |
10 | reyssat | 324 | modcnt=0; |
325 | s=getenv("slist"); if(s==NULL) return; |
||
326 | l=strlen(s); if(l<0 || l>100*MAX_LINELEN) return; |
||
3718 | reyssat | 327 | mlist=xmalloc(l+16); ovlstrcpy(mlist,s); |
10 | reyssat | 328 | for(p1=find_word_start(mlist); *p1 && modcnt<MAX_MODULES; p1=find_word_start(p2)) { |
6884 | bpr | 329 | p2=find_word_end(p1); |
330 | l=p2-p1; if(*p2) *p2++=0; |
||
331 | for(i=0;i<langcnt;i++) if(strncasecmp(lang[i],p1,2)==0) break; |
||
332 | if(i<langcnt) thislang=i; else continue; |
||
333 | mod[modcnt].name=p1; |
||
334 | mod[modcnt].langs[0]=thislang; |
||
335 | mod[modcnt].langcnt=1; |
||
336 | modcnt++; |
||
10 | reyssat | 337 | } |
338 | } |
||
339 | |||
340 | void clean(void) |
||
341 | { |
||
342 | fclose(langf); fclose(titf); fclose(descf); fclose(robotf); |
||
343 | fclose(authorf); fclose(versionf); |
||
344 | } |
||
345 | |||
346 | char *sheetindex[]={ |
||
6881 | bpr | 347 | "title", "description", |
10 | reyssat | 348 | "duration", "severity", |
349 | "level", "domain", |
||
6967 | bpr | 350 | "keywords", "reserved1", "reserved2", "information" |
10 | reyssat | 351 | }; |
352 | #define SHEETINDEX_NO (sizeof(sheetindex)/sizeof(sheetindex[0])) |
||
353 | char sindbuf[SHEETINDEX_NO][MAX_LINELEN+1]; |
||
354 | enum{s_title, s_description, |
||
355 | s_duration, s_severity, |
||
356 | s_level, s_domain, |
||
357 | s_keywords, s_reserved1, s_reserved2, |
||
6967 | bpr | 358 | s_information |
10 | reyssat | 359 | }; |
360 | |||
361 | char *modindex[]={ |
||
6881 | bpr | 362 | "title", "description", |
10 | reyssat | 363 | "author", "address", "copyright", |
364 | "version", "wims_version", "language", |
||
6881 | bpr | 365 | "category", "level", "domain", "keywords", |
6799 | bpr | 366 | "keywords_ca", "keywords_en", "keywords_fr", "keywords_it", "keywords_nl", |
367 | "title_ca", "title_en", "title_fr", "title_it", "title_nl", |
||
10 | reyssat | 368 | "require" |
369 | }; |
||
370 | #define MODINDEX_NO (sizeof(modindex)/sizeof(modindex[0])) |
||
371 | char indbuf[MODINDEX_NO][MAX_LINELEN+1]; |
||
372 | enum{i_title, i_description, |
||
373 | i_author,i_address,i_copyright, |
||
374 | i_version,i_wims_version,i_language, |
||
375 | i_category,i_level,i_domain,i_keywords, |
||
6799 | bpr | 376 | i_keywords_ca,i_keywords_en,i_keywords_fr,i_keywords_it,i_keywords_nl, |
377 | i_title_ca,i_title_en,i_title_fr,i_title_it,i_title_nl, |
||
10 | reyssat | 378 | i_require |
379 | }; |
||
380 | |||
381 | char *module_special_file[]={ |
||
382 | "intro","help","about" |
||
383 | }; |
||
384 | #define MODSPEC_NO (sizeof(module_special_file)/sizeof(module_special_file[0])) |
||
385 | char module_language[4]; |
||
386 | |||
6884 | bpr | 387 | /* read and treat module's INDEX file */ |
10 | reyssat | 388 | int module_index(const char *name) |
389 | { |
||
390 | char *p, fbuf[MAX_LINELEN+1], ibuf[MAX_LINELEN+1]; |
||
391 | FILE *indf; |
||
392 | int i,l; |
||
393 | |||
394 | snprintf(fbuf,sizeof(fbuf),"%s/%s/INDEX",moduledir,name); |
||
395 | indf=fopen(fbuf,"r"); if(indf==NULL) return -1; |
||
396 | l=fread(ibuf,1,MAX_LINELEN,indf); fclose(indf); |
||
397 | if(l>0 && l<MAX_LINELEN) ibuf[l]=0; else return -1; |
||
6884 | bpr | 398 | /* treate all fields in *modindex */ |
10 | reyssat | 399 | for(i=0;i<MODINDEX_NO;i++) { |
6884 | bpr | 400 | _getdef(ibuf,modindex[i],indbuf[i]); |
401 | /* compatibility precaution */ |
||
402 | if(indbuf[i][0]==':') indbuf[i][0]='.'; |
||
10 | reyssat | 403 | } |
404 | p=find_word_start(indbuf[i_language]); |
||
405 | if(isalpha(*p) && isalpha(*(p+1))) { |
||
6884 | bpr | 406 | memmove(module_language,p,2); module_language[2]=0; |
10 | reyssat | 407 | } |
3718 | reyssat | 408 | else ovlstrcpy(module_language,"en"); |
10 | reyssat | 409 | return 0; |
410 | } |
||
411 | |||
412 | int sheet_index(int serial) |
||
413 | { |
||
414 | char *p1, *p2, fbuf[MAX_LINELEN+1], ibuf[MAX_LINELEN+1]; |
||
415 | FILE *indf; |
||
416 | int i,l; |
||
417 | |||
418 | snprintf(fbuf,sizeof(fbuf),"%s/%s.def",sheetdir,mod[serial].name); |
||
419 | indf=fopen(fbuf,"r"); if(indf==NULL) return -1; |
||
420 | l=fread(ibuf,1,MAX_LINELEN,indf); fclose(indf); |
||
421 | if(l>0 && l<MAX_LINELEN) ibuf[l]=0; else return -1; |
||
422 | for(i=0;i<SHEETINDEX_NO;i++) sindbuf[i][0]=0; |
||
423 | for(i=0,p1=find_word_start(ibuf); |
||
6884 | bpr | 424 | i<SHEETINDEX_NO-1 && *p1!=':' && *p1!=0; |
425 | i++,p1=p2) { |
||
426 | p2=strchr(p1,'\n'); |
||
427 | if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1); |
||
8100 | bpr | 428 | p1=find_word_start(p1); strip_trailing_spaces2(p1); |
6884 | bpr | 429 | snprintf(sindbuf[i],MAX_LINELEN,"%s",p1); |
10 | reyssat | 430 | } |
431 | p2=strstr(p1,"\n:"); if(p2==NULL) p2=p1+strlen(p1); |
||
432 | else *p2=0; |
||
8100 | bpr | 433 | p1=find_word_start(p1); strip_trailing_spaces2(p1); |
10 | reyssat | 434 | for(p2=p1;*p2;p2++) if(*p2=='\n') *p2=' '; |
6967 | bpr | 435 | ovlstrcpy(sindbuf[s_information],p1); |
10 | reyssat | 436 | return 0; |
437 | } |
||
438 | |||
439 | unsigned char categories[16]; |
||
440 | char taken[MAX_LINELEN+1]; |
||
441 | int catcnt, takenlen, tweight; |
||
442 | |||
443 | void appenditem(char *word, int lind, int serial, int weight, char *l) |
||
444 | { |
||
445 | char nbuf[MAX_LINELEN+1], buf[MAX_LINELEN+1]; |
||
446 | int i, ll; |
||
447 | char *p; |
||
448 | FILE *f; |
||
6881 | bpr | 449 | |
10 | reyssat | 450 | if(!isalnum(*word) || (ll=strlen(word))<2 || |
8100 | bpr | 451 | wordchr2(taken,word)!=NULL || |
452 | wordchr2(ignore[lind],word)!=NULL || |
||
10 | reyssat | 453 | takenlen>=MAX_LINELEN-ll-16) |
454 | return; |
||
455 | if(ll==2 && (!isdigit(word[0]) || !isalpha(word[1]))) return; |
||
456 | for(p=word;*p;p++) if(!isalnum(*p) && *p!=' ') return; |
||
457 | taken[takenlen++]=' '; taken[takenlen++]=' '; |
||
3718 | reyssat | 458 | ovlstrcpy(taken+takenlen,word); |
10 | reyssat | 459 | takenlen+=ll; tweight+=weight; |
460 | snprintf(buf,sizeof(buf),"%s:%d?%d\n",word,serial,weight); |
||
461 | for(i=0;i<catcnt;i++) { |
||
6884 | bpr | 462 | snprintf(nbuf,sizeof(nbuf),"%s/%c.%s", |
463 | outdir,categories[i],lang[lind]); |
||
464 | f=fopen(nbuf,"a"); |
||
465 | if(f!=NULL) {fputs(buf,f); fclose(f);} |
||
10 | reyssat | 466 | } |
467 | } |
||
468 | |||
6881 | bpr | 469 | void appenditem1 (char *buf, int lind, int serial, int weight, char *l ) |
470 | { |
||
471 | char *p1, *p2 ; |
||
472 | for(p1=find_word_start(buf); *p1; |
||
6884 | bpr | 473 | p1=find_word_start(p2)) { |
474 | p2=strchr(p1,','); |
||
475 | if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1); |
||
476 | if(strlen(p1)<=0) continue; |
||
477 | appenditem(p1,lind,serial,weight,module_language); |
||
6881 | bpr | 478 | } |
479 | } |
||
480 | void appenditem2 (char *buf, int lind, int serial, int weight, char *l ) |
||
481 | { |
||
482 | char *p1, *p2 ; |
||
483 | for(p1=find_word_start(buf);*p1; |
||
6884 | bpr | 484 | p1=find_word_start(p2)) { |
485 | p2=find_word_end(p1); if(*p2) *p2++=0; |
||
486 | appenditem(p1,lind,serial,weight,module_language); |
||
6881 | bpr | 487 | } |
488 | } |
||
10 | reyssat | 489 | void onemodule(const char *name, int serial, int lind) |
490 | { |
||
491 | int i; |
||
492 | unsigned char trlist[]={ |
||
6884 | bpr | 493 | i_title,i_description,i_category,i_domain,i_keywords, |
494 | i_require,i_author, |
||
495 | i_keywords_ca,i_keywords_en,i_keywords_fr,i_keywords_it,i_keywords_nl, |
||
496 | i_title_ca,i_title_en,i_title_fr,i_title_it,i_title_nl |
||
10 | reyssat | 497 | }; |
498 | #define trcnt (sizeof(trlist)/sizeof(trlist[0])) |
||
6564 | bpr | 499 | char *p1, *p2, *pp, *q, buf[MAX_LINELEN+1], lbuf[16]; |
10 | reyssat | 500 | FILE *f; |
6881 | bpr | 501 | |
10 | reyssat | 502 | if(module_index(name)) return; |
503 | towords(indbuf[i_category]); |
||
7915 | bpr | 504 | /* list the categories (among A=all,X=eXercise,O,D,...) corresponding |
6884 | bpr | 505 | * to this module |
506 | */ |
||
10 | reyssat | 507 | for(i=catcnt=0;i<catno && catcnt<16;i++) { |
8100 | bpr | 508 | if(wordchr2(indbuf[i_category],cat[i].name)!=NULL) |
6884 | bpr | 509 | categories[catcnt++]=cat[i].typ; |
10 | reyssat | 510 | } |
511 | if(catcnt==0) return; |
||
512 | if(categories[0]!=cat[0].typ) |
||
513 | categories[catcnt++]=cat[0].typ; |
||
6884 | bpr | 514 | /* write module's name in the category.language files, for instance lists/X.fr |
515 | * for french exercises |
||
516 | */ |
||
10 | reyssat | 517 | for(i=0;i<catcnt;i++) { |
6884 | bpr | 518 | snprintf(buf,sizeof(buf),"%s/lists/%c.%s", |
519 | outdir,categories[i],lang[lind]); |
||
520 | f=fopen(buf,"a"); |
||
521 | if(f!=NULL) {fprintf(f,"%s\n",name); fclose(f);} |
||
10 | reyssat | 522 | } |
6884 | bpr | 523 | /* add serial number and language (resp.title, ...) to corresponding file */ |
10 | reyssat | 524 | fprintf(langf,"%d:%s\n",serial,module_language); |
525 | fprintf(titf,"%d:%s\n",serial,indbuf[i_title]); |
||
526 | fprintf(descf,"%d:%s\n",serial,indbuf[i_description]); |
||
527 | fprintf(authorf,"%d:%s\n",serial,indbuf[i_author]); |
||
528 | fprintf(versionf,"%d:%s\n",serial,indbuf[i_version]); |
||
6881 | bpr | 529 | |
6884 | bpr | 530 | /* add module's information in html page for robots */ |
10 | reyssat | 531 | snprintf(buf,sizeof(buf),"%s",indbuf[i_description]); |
532 | for(pp=strchr(buf,','); pp; pp=strchr(pp,',')) |
||
8100 | bpr | 533 | string_modify3(buf,pp,pp+1,","); |
10 | reyssat | 534 | if(strcmp(module_language,lang[lind])==0) |
535 | fprintf(robotf,"%s ,%s,%s,%s,%s\n",name,module_language,name, |
||
6884 | bpr | 536 | indbuf[i_title], buf); |
6819 | reyssat | 537 | |
6884 | bpr | 538 | /* Normalize the information of trlist, using dictionary |
7915 | bpr | 539 | * -- bases/sys/domain.xx without suffix translation (--> english version) |
6884 | bpr | 540 | */ |
6881 | bpr | 541 | entrycount=dentrycount; dicbuf=ddicbuf; |
542 | memmove(entry,dentry,dentrycount*sizeof(entry[0])); |
||
543 | unknown_type=unk_leave; |
||
10 | reyssat | 544 | for(i=0;i<trcnt;i++) { |
6884 | bpr | 545 | detag(indbuf[trlist[i]]); |
8100 | bpr | 546 | deaccent2(indbuf[trlist[i]]); |
6884 | bpr | 547 | comma(indbuf[trlist[i]]); |
8100 | bpr | 548 | singlespace2(indbuf[trlist[i]]); |
6884 | bpr | 549 | translate(indbuf[trlist[i]]); |
6881 | bpr | 550 | } |
6884 | bpr | 551 | /* Normalize the information, using dictionary |
7915 | bpr | 552 | * bases/sys/words.xx with suffix translation |
6884 | bpr | 553 | */ |
6881 | bpr | 554 | entrycount=mentrycount; dicbuf=mdicbuf; |
555 | memmove(entry,mentry,mentrycount*sizeof(entry[0])); |
||
6884 | bpr | 556 | unknown_type=unk_leave;/* used in translator_.c */ |
6881 | bpr | 557 | for(i=0;i<trcnt;i++) { |
6884 | bpr | 558 | suffix_translate(indbuf[trlist[i]]); |
559 | translate(indbuf[trlist[i]]); |
||
10 | reyssat | 560 | } |
6881 | bpr | 561 | |
562 | /* taken contains all words already seen in the module index */ |
||
10 | reyssat | 563 | taken[0]=0; takenlen=tweight=0; |
6881 | bpr | 564 | /* append words of title */ |
3718 | reyssat | 565 | ovlstrcpy(buf,indbuf[i_title]); towords(buf); |
6881 | bpr | 566 | appenditem2(buf,lind,serial,4,module_language); |
567 | |||
6884 | bpr | 568 | /* extract words of every other information except level */ |
6799 | bpr | 569 | snprintf(buf,sizeof(buf),"%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s", |
6884 | bpr | 570 | indbuf[i_description],indbuf[i_keywords], |
571 | indbuf[i_keywords_ca],indbuf[i_keywords_en],indbuf[i_keywords_fr], |
||
572 | indbuf[i_keywords_it],indbuf[i_keywords_nl], |
||
573 | indbuf[i_title_ca],indbuf[i_title_en],indbuf[i_title_fr], |
||
574 | indbuf[i_title_it],indbuf[i_title_nl], |
||
575 | indbuf[i_domain],indbuf[i_require],indbuf[i_author]); |
||
10 | reyssat | 576 | towords(buf); |
6884 | bpr | 577 | appenditem2(buf,lind,serial,2,module_language); |
6881 | bpr | 578 | |
6884 | bpr | 579 | /* this time the dictionary is the group dictionary sys/wgrp/wgrp |
580 | * with a g (groupdic), not an m (maindic) . see below main, suffix, group. |
||
7915 | bpr | 581 | * and delete unknown ?? and translate |
6884 | bpr | 582 | */ |
10 | reyssat | 583 | entrycount=gentrycount; dicbuf=gdicbuf; |
584 | memmove(entry,gentry,gentrycount*sizeof(entry[0])); |
||
6881 | bpr | 585 | |
6884 | bpr | 586 | /* append words of every title information */ |
6881 | bpr | 587 | ovlstrcpy(buf,indbuf[i_title]); |
10 | reyssat | 588 | unknown_type=unk_delete; |
6881 | bpr | 589 | translate(buf); |
590 | appenditem1(buf,lind,serial,2,module_language); |
||
591 | |||
6884 | bpr | 592 | /* append words of information of description except level */ |
6881 | bpr | 593 | snprintf(buf,sizeof(buf),"%s", indbuf[i_description]); |
594 | unknown_type=unk_delete; |
||
595 | translate(buf); |
||
596 | appenditem1(buf,lind,serial,4,module_language); |
||
597 | |||
6884 | bpr | 598 | /* append words (or group of words) of keywords and domain */ |
6881 | bpr | 599 | snprintf(buf,sizeof(buf),"%s, %s, %s, %s, %s, %s, %s", |
6884 | bpr | 600 | indbuf[i_domain],indbuf[i_keywords], |
601 | indbuf[i_keywords_ca], indbuf[i_keywords_en],indbuf[i_keywords_fr], |
||
602 | indbuf[i_keywords_it], indbuf[i_keywords_nl]); |
||
603 | unknown_type=unk_leave; |
||
10 | reyssat | 604 | translate(buf); |
6881 | bpr | 605 | appenditem1(buf,lind,serial,2,module_language); |
606 | |||
6884 | bpr | 607 | /* append level information, with weight 2 */ |
10 | reyssat | 608 | snprintf(buf,sizeof(buf),"%s",indbuf[i_level]); |
3718 | reyssat | 609 | ovlstrcpy(lbuf,"level"); |
10 | reyssat | 610 | for(p1=buf; *p1; p1++) if(!isalnum(*p1)) *p1=' '; |
6564 | bpr | 611 | q=buf+strlen(buf); |
612 | for(p1=find_word_start(buf); (*p1) && (p1 < q) ; |
||
6884 | bpr | 613 | p1=find_word_start(p2)) { |
614 | p2=find_word_end(p1); |
||
615 | if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1); |
||
616 | if(!isalpha(*p1) || |
||
617 | (!isdigit(*(p1+1)) && *(p1+1)!=0) || |
||
618 | (*(p1+1)!=0 && *(p1+2)!=0)) |
||
619 | continue; |
||
620 | *p1=tolower(*p1); |
||
621 | ovlstrcpy(lbuf+strlen("level"),p1); |
||
622 | appenditem(lbuf,lind,serial,2,module_language); |
||
10 | reyssat | 623 | } |
6884 | bpr | 624 | /* append total weight of module to weight file site2/weight.xx */ |
10 | reyssat | 625 | fprintf(weightf,"%d:%d\n",serial,tweight); |
626 | } |
||
627 | |||
628 | void modules(void) |
||
629 | { |
||
630 | int i,j,k,d; |
||
631 | char namebuf[MAX_LINELEN+1]; |
||
6881 | bpr | 632 | char mdic[MAX_LINELEN+1], sdic[MAX_LINELEN+1], gdic[MAX_LINELEN+1], ddic[MAX_LINELEN+1]; |
10 | reyssat | 633 | |
634 | for(j=0;j<langcnt;j++) { |
||
6884 | bpr | 635 | snprintf(namebuf,sizeof(namebuf),"%s/weight.%s",outdir,lang[j]); |
636 | weightf=fopen(namebuf,"w"); |
||
637 | snprintf(mdic,sizeof(mdic),"%s/%s.%s",dicdir,maindic,lang[j]); |
||
638 | snprintf(sdic,sizeof(sdic),"%s/%s.%s",dicdir,suffixdic,lang[j]); |
||
639 | snprintf(gdic,sizeof(gdic),"%s/%s.%s",dicdir,groupdic,lang[j]); |
||
640 | snprintf(ddic,sizeof(ddic),"%s/%s.%s",dicdir,domaindic,lang[j]); |
||
641 | suffix_dic(sdic); prepare_dic(gdic); |
||
642 | gdicbuf=dicbuf; gentrycount=entrycount; |
||
643 | memmove(gentry,entry,gentrycount*sizeof(entry[0])); |
||
644 | prepare_dic(mdic); |
||
645 | mdicbuf=dicbuf; mentrycount=entrycount; |
||
646 | memmove(mentry,entry,mentrycount*sizeof(entry[0])); |
||
647 | prepare_dic(ddic); |
||
648 | ddicbuf=dicbuf; dentrycount=entrycount; |
||
649 | memmove(dentry,entry,dentrycount*sizeof(entry[0])); |
||
650 | unknown_type=unk_leave; translate(ignore[j]); |
||
651 | for(i=0;i<modcnt;i++) { |
||
652 | if(mod[i].langcnt>0) { |
||
653 | for(d=k=0;k<mod[i].langcnt;k++) |
||
654 | if(mod[i].langs[k]<mod[i].langs[d]) d=k; |
||
655 | for(k=0;k<mod[i].langcnt && mod[i].langs[k]!=j;k++); |
||
656 | if(k>=mod[i].langcnt) k=d; |
||
657 | snprintf(namebuf,MAX_LINELEN,"%s.%s",mod[i].name, |
||
658 | lang[mod[i].langs[k]]); |
||
659 | onemodule(namebuf,mod[i].counts[k],j); |
||
660 | } |
||
661 | else { |
||
662 | onemodule(mod[i].name,mod[i].counts[0],j); |
||
663 | } |
||
10 | reyssat | 664 | } |
6884 | bpr | 665 | if(mentrycount>0) free(mdicbuf); |
666 | if(gentrycount>0) free(gdicbuf); |
||
667 | if(suffixcnt>0) free(sufbuf); |
||
668 | if(dentrycount>0) free(ddicbuf); |
||
669 | if(weightf) fclose(weightf); |
||
670 | } |
||
10 | reyssat | 671 | } |
672 | |||
6881 | bpr | 673 | /* FIXME ? differences with appenditem - use fprintf instead of snprintf */ |
10 | reyssat | 674 | void sappenditem(char *word, int lind, int serial, int weight) |
675 | { |
||
676 | int ll; |
||
677 | char *p; |
||
6881 | bpr | 678 | |
10 | reyssat | 679 | if(!isalnum(*word) || (ll=strlen(word))<2 || |
8100 | bpr | 680 | wordchr2(taken,word)!=NULL || |
681 | wordchr2(ignore[lind],word)!=NULL || |
||
10 | reyssat | 682 | takenlen>=MAX_LINELEN-ll-16) |
683 | return; |
||
684 | if(ll==2 && (!isdigit(word[0]) || !isalpha(word[1]))) return; |
||
685 | for(p=word;*p;p++) if(!isalnum(*p) && *p!=' ') return; |
||
686 | taken[takenlen++]=' ';taken[takenlen++]=' '; |
||
3718 | reyssat | 687 | ovlstrcpy(taken+takenlen,word); |
10 | reyssat | 688 | takenlen+=ll; tweight+=weight; |
689 | fprintf(indf,"%s:%d?%d\n",word,serial,weight); |
||
690 | } |
||
691 | |||
692 | void onesheet(int serial, int lind) |
||
693 | { |
||
694 | int i; |
||
695 | unsigned char trlist[]={ |
||
6967 | bpr | 696 | s_title,s_description,s_domain,s_keywords,s_information |
10 | reyssat | 697 | }; |
698 | #define trcnt (sizeof(trlist)/sizeof(trlist[0])) |
||
699 | char *p1, *p2, buf[MAX_LINELEN+1]; |
||
6881 | bpr | 700 | |
10 | reyssat | 701 | if(sheet_index(serial)) return; |
702 | fprintf(listf,"%s\n",mod[serial].name+3); |
||
703 | fprintf(titf,"%d:%s\n",serial,sindbuf[s_title]); |
||
704 | fprintf(descf,"%d:%s\n",serial,sindbuf[s_description]); |
||
6967 | bpr | 705 | fprintf(remf,"%d:%s\n",serial,sindbuf[s_information]); |
7915 | bpr | 706 | |
6881 | bpr | 707 | entrycount=dentrycount; dicbuf=ddicbuf; |
708 | memmove(entry,dentry,dentrycount*sizeof(entry[0])); |
||
10 | reyssat | 709 | unknown_type=unk_leave; |
710 | for(i=0;i<trcnt;i++) { |
||
6884 | bpr | 711 | detag(sindbuf[trlist[i]]); |
8100 | bpr | 712 | deaccent2(sindbuf[trlist[i]]); |
6884 | bpr | 713 | comma(sindbuf[trlist[i]]); |
8100 | bpr | 714 | singlespace2(sindbuf[trlist[i]]); |
6884 | bpr | 715 | translate(sindbuf[trlist[i]]); |
6881 | bpr | 716 | } |
7915 | bpr | 717 | |
6881 | bpr | 718 | entrycount=mentrycount; dicbuf=mdicbuf; |
719 | memmove(entry,mentry,mentrycount*sizeof(entry[0])); |
||
720 | unknown_type=unk_leave; |
||
721 | for(i=0;i<trcnt;i++) { |
||
6884 | bpr | 722 | suffix_translate(sindbuf[trlist[i]]); |
723 | translate(sindbuf[trlist[i]]); |
||
10 | reyssat | 724 | } |
725 | taken[0]=0; takenlen=tweight=0; |
||
3718 | reyssat | 726 | ovlstrcpy(buf,sindbuf[s_title]); towords(buf); |
10 | reyssat | 727 | for(p1=find_word_start(buf);*p1; |
6884 | bpr | 728 | p1=find_word_start(p2)) { |
729 | p2=find_word_end(p1); if(*p2) *p2++=0; |
||
730 | sappenditem(p1,lind,serial,4); |
||
10 | reyssat | 731 | } |
732 | snprintf(buf,sizeof(buf),"%s %s %s %s", |
||
6884 | bpr | 733 | sindbuf[s_description],sindbuf[s_keywords], |
6967 | bpr | 734 | sindbuf[s_domain],sindbuf[s_information]); |
10 | reyssat | 735 | towords(buf); |
736 | for(p1=find_word_start(buf);*p1; |
||
6884 | bpr | 737 | p1=find_word_start(p2)) { |
738 | p2=find_word_end(p1); if(*p2) *p2++=0; |
||
739 | sappenditem(p1,lind,serial,2); |
||
10 | reyssat | 740 | } |
741 | entrycount=gentrycount; dicbuf=gdicbuf; |
||
742 | memmove(entry,gentry,gentrycount*sizeof(entry[0])); |
||
743 | unknown_type=unk_delete; |
||
3718 | reyssat | 744 | ovlstrcpy(buf,sindbuf[s_title]); translate(buf); |
10 | reyssat | 745 | for(p1=find_word_start(buf); *p1; |
6884 | bpr | 746 | p1=find_word_start(p2)) { |
747 | p2=strchr(p1,','); |
||
748 | if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1); |
||
749 | if(strlen(p1)<=0) continue; |
||
750 | sappenditem(p1,lind,serial,4); |
||
10 | reyssat | 751 | } |
752 | snprintf(buf,sizeof(buf),"%s, %s, %s, %s", |
||
6884 | bpr | 753 | sindbuf[s_description],sindbuf[s_keywords], |
6967 | bpr | 754 | sindbuf[s_domain],sindbuf[s_information]); |
10 | reyssat | 755 | translate(buf); |
756 | for(p1=find_word_start(buf); *p1; |
||
6884 | bpr | 757 | p1=find_word_start(p2)) { |
758 | p2=strchr(p1,','); |
||
759 | if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1); |
||
760 | if(strlen(p1)<=0) continue; |
||
761 | sappenditem(p1,lind,serial,2); |
||
10 | reyssat | 762 | } |
763 | fprintf(weightf,"%d:%d\n",serial,tweight); |
||
764 | } |
||
765 | |||
766 | void sheets(void) |
||
767 | { |
||
768 | int i,j; |
||
6961 | bpr | 769 | char mdic[MAX_LINELEN+1], sdic[MAX_LINELEN+1], gdic[MAX_LINELEN+1], ddic[MAX_LINELEN+1]; |
10 | reyssat | 770 | char buf[MAX_LINELEN+1]; |
7915 | bpr | 771 | |
10 | reyssat | 772 | for(j=0;j<langcnt;j++) { |
6884 | bpr | 773 | snprintf(buf,sizeof(buf),"%s/index/title.%s",sheetdir,lang[j]); |
774 | titf=fopen(buf,"w"); |
||
775 | snprintf(buf,sizeof(buf),"%s/index/description.%s",sheetdir,lang[j]); |
||
776 | descf=fopen(buf,"w"); |
||
777 | snprintf(buf,sizeof(buf),"%s/index/%s",sheetdir,lang[j]); |
||
778 | indf=fopen(buf,"w"); |
||
779 | snprintf(buf,sizeof(buf),"%s/index/list.%s",sheetdir,lang[j]); |
||
780 | listf=fopen(buf,"w"); |
||
781 | snprintf(buf,sizeof(buf),"%s/index/weight.%s",sheetdir,lang[j]); |
||
782 | weightf=fopen(buf,"w"); |
||
783 | snprintf(buf,sizeof(buf),"%s/index/addr.%s",sheetdir,lang[j]); |
||
784 | addrf=fopen(buf,"w"); |
||
6967 | bpr | 785 | snprintf(buf,sizeof(buf),"%s/index/information.%s",sheetdir,lang[j]); |
6961 | bpr | 786 | remf=fopen(buf,"w"); |
6884 | bpr | 787 | snprintf(buf,sizeof(buf),"%s/index/serial.%s",sheetdir,lang[j]); |
788 | serialf=fopen(buf,"w"); |
||
789 | snprintf(mdic,sizeof(mdic),"%s/%s.%s",dicdir,maindic,lang[j]); |
||
790 | snprintf(sdic,sizeof(sdic),"%s/%s.%s",dicdir,suffixdic,lang[j]); |
||
791 | snprintf(gdic,sizeof(gdic),"%s/%s.%s",dicdir,groupdic,lang[j]); |
||
6961 | bpr | 792 | snprintf(ddic,sizeof(ddic),"%s/%s.%s",dicdir,domaindic,lang[j]); |
6884 | bpr | 793 | suffix_dic(sdic); prepare_dic(gdic); |
794 | gdicbuf=dicbuf; gentrycount=entrycount; |
||
795 | memmove(gentry,entry,gentrycount*sizeof(entry[0])); |
||
796 | prepare_dic(mdic); |
||
797 | mdicbuf=dicbuf; mentrycount=entrycount; |
||
798 | memmove(mentry,entry,mentrycount*sizeof(entry[0])); |
||
6973 | bpr | 799 | prepare_dic(ddic); |
800 | ddicbuf=dicbuf; dentrycount=entrycount; |
||
801 | memmove(dentry,entry,dentrycount*sizeof(entry[0])); |
||
6884 | bpr | 802 | unknown_type=unk_leave; translate(ignore[j]); |
803 | for(i=0;i<modcnt;i++) { |
||
804 | if(mod[i].langs[0]!=j) continue; |
||
805 | fprintf(addrf,"%d:%s\n",i,mod[i].name+3); |
||
806 | fprintf(serialf,"%s:%d\n",mod[i].name+3,i); |
||
807 | onesheet(i,j); |
||
10 | reyssat | 808 | } |
6884 | bpr | 809 | if(mentrycount>0) free(mdicbuf); |
810 | if(gentrycount>0) free(gdicbuf); |
||
811 | if(suffixcnt>0) free(sufbuf); |
||
6961 | bpr | 812 | if(dentrycount>0) free(ddicbuf); |
6884 | bpr | 813 | fclose(titf); fclose(descf); fclose(indf); fclose(listf); |
814 | fclose(weightf); fclose(addrf); fclose(serialf); |
||
815 | } |
||
10 | reyssat | 816 | } |
817 | |||
818 | int main() |
||
819 | { |
||
8123 | bpr | 820 | gentry=xmalloc(entry_size); |
821 | dentry=xmalloc(entry_size); |
||
822 | mentry=xmalloc(entry_size); |
||
10 | reyssat | 823 | prep(); |
824 | if(modcnt>0) modules(); |
||
825 | clean(); |
||
826 | sprep(); |
||
827 | if(modcnt>0) sheets(); |
||
828 | return 0; |
||
829 | } |
||
830 |