Rev 15778 | Rev 17024 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 15778 | Rev 16987 | ||
---|---|---|---|
Line 50... | Line 50... | ||
50 | #define allangcnt 8 |
50 | #define allangcnt 8 |
51 | char ignore[MAX_LANGS][MAX_LINELEN+1]; |
51 | char ignore[MAX_LANGS][MAX_LINELEN+1]; |
52 | char mlistfile[MAX_LANGS][256]; |
52 | char mlistfile[MAX_LANGS][256]; |
53 | int langcnt; |
53 | int langcnt; |
54 | FILE *langf, *titf, *descf, *weightf, *robotf, *indf, *listf, *addrf, *serialf, *authorf, *versionf, *remf; |
54 | FILE *langf, *titf, *descf, *weightf, *robotf, *indf, *listf, *addrf, *serialf, *authorf, *versionf, *remf; |
55 | - | ||
- | 55 | FILE *titf_ca,*titf_en,*titf_es,*titf_fr,*titf_it,*titf_nl; |
|
56 | struct cat { |
56 | struct cat { |
57 | char *name; |
57 | char *name; |
58 | char typ; |
58 | char typ; |
59 | } cat[]={ |
59 | } cat[]={ |
60 | {"all_types", 'A'}, |
60 | {"all_types", 'A'}, |
Line 96... | Line 96... | ||
96 | char *glindex[]={ |
96 | char *glindex[]={ |
97 | "gl_title", "gl_description", |
97 | "gl_title", "gl_description", |
98 | "", "", |
98 | "", "", |
99 | "gl_level", "gl_domain", |
99 | "gl_level", "gl_domain", |
100 | "gl_keywords","","",""}; |
100 | "gl_keywords","","",""}; |
101 | 101 | ||
102 | #define SHEETINDEX_NO (sizeof(sheetindex)/sizeof(sheetindex[0])) |
102 | #define SHEETINDEX_NO (sizeof(sheetindex)/sizeof(sheetindex[0])) |
103 | char gsindbuf[SHEETINDEX_NO+1][MAX_LINELEN+1]; |
103 | char gsindbuf[SHEETINDEX_NO+1][MAX_LINELEN+1]; |
104 | 104 | ||
105 | /* do not modify the order, correspond to the order in the sheet file */ |
105 | /* do not modify the order, correspond to the order in the sheet file */ |
106 | enum{s_title, s_description, |
106 | enum{s_title, s_description, |
Line 114... | Line 114... | ||
114 | "title", "description", |
114 | "title", "description", |
115 | "author", "address", "copyright", |
115 | "author", "address", "copyright", |
116 | "version", "wims_version", "language", |
116 | "version", "wims_version", "language", |
117 | "category", "level", "domain", "keywords", |
117 | "category", "level", "domain", "keywords", |
118 | "keywords_ca", "keywords_en", "keywords_fr", "keywords_it", "keywords_nl", |
118 | "keywords_ca", "keywords_en", "keywords_fr", "keywords_it", "keywords_nl", |
119 | "title_ca", "title_en", "title_fr", "title_it", "title_nl", |
119 | "title_ca", "title_en", "title_es", "title_fr", "title_it", "title_nl", |
120 | "require" |
120 | "require" |
121 | }; |
121 | }; |
122 | #define MODINDEX_NO (sizeof(modindex)/sizeof(modindex[0])) |
122 | #define MODINDEX_NO (sizeof(modindex)/sizeof(modindex[0])) |
123 | char indbuf[MODINDEX_NO][MAX_LINELEN+1]; |
123 | char indbuf[MODINDEX_NO][MAX_LINELEN+1]; |
124 | enum{i_title, i_description, |
124 | enum{i_title, i_description, |
125 | i_author,i_address,i_copyright, |
125 | i_author,i_address,i_copyright, |
126 | i_version,i_wims_version,i_language, |
126 | i_version,i_wims_version,i_language, |
127 | i_category,i_level,i_domain,i_keywords, |
127 | i_category,i_level,i_domain,i_keywords, |
128 | i_keywords_ca,i_keywords_en,i_keywords_fr,i_keywords_it,i_keywords_nl, |
128 | i_keywords_ca,i_keywords_en,i_keywords_fr,i_keywords_it,i_keywords_nl, |
129 | i_title_ca,i_title_en,i_title_fr,i_title_it,i_title_nl, |
129 | i_title_ca,i_title_en,i_title_es,i_title_fr,i_title_it,i_title_nl, |
130 | i_require |
130 | i_require |
131 | }; |
131 | }; |
132 | 132 | ||
133 | char *module_special_file[]={ |
133 | char *module_special_file[]={ |
134 | "intro","help","about" |
134 | "intro","help","about" |
135 | }; |
135 | }; |
136 | #define MODSPEC_NO (sizeof(module_special_file)/sizeof(module_special_file[0])) |
136 | #define MODSPEC_NO (sizeof(module_special_file)/sizeof(module_special_file[0])) |
137 | char module_language[4]; |
137 | char module_language[4]; |
138 | 138 | ||
139 | char *mdicbuf, *gdicbuf, *ddicbuf, *gentry, *mentry, *dentry; |
139 | char *mdicbuf, *gdicbuf, *ddicbuf, *gentry, *mentry, *dentry; |
140 | 140 | ||
141 | int gentrycount, mentrycount, dentrycount; |
141 | int gentrycount, mentrycount, dentrycount; |
142 | 142 | ||
143 | 143 | ||
144 | /* fold known accented letters to unaccented, other strange characters to space |
144 | /* fold known accented letters to unaccented, other strange characters to space |
145 | * apostrophe is among the exceptions to be kept (important for multi-word expressions) |
145 | * apostrophe is among the exceptions to be kept (important for multi-word expressions) |
146 | */ |
146 | */ |
147 | void deaccent2(char *p) |
147 | void deaccent2(char *p) |
148 | { |
148 | { |
Line 156... | Line 156... | ||
156 | } |
156 | } |
157 | } |
157 | } |
158 | 158 | ||
159 | /* translate everything non-alphanumeric into space */ |
159 | /* translate everything non-alphanumeric into space */ |
160 | void towords(char *p) |
160 | void towords(char *p) |
161 | { |
161 | { |
162 | char *pp; |
162 | char *pp; |
163 | for(pp=p;*pp;pp++) if(!isalnum(*pp) && strchr("&$+*",*pp)==0) *pp=' '; |
163 | for(pp=p;*pp;pp++) if(!isalnum(*pp) && strchr("&$+*",*pp)==0) *pp=' '; |
164 | } |
164 | } |
165 | 165 | ||
166 | /* Find first occurrence of word */ |
166 | /* Find first occurrence of word */ |
167 | char *wordchr2(char *p, char *w) |
167 | char *wordchr2(char *p, char *w) |
168 | { |
168 | { |
169 | char *r; |
169 | char *r; |
170 | 170 | ||
171 | for(r=strstr(p,w);r!=NULL && |
171 | for(r=strstr(p,w);r!=NULL && |
172 | ( (r>p && !isspace(*(r-1))) || (!isspace(*(r+strlen(w))) && *(r+strlen(w))!=0) ); |
172 | ( (r>p && !isspace(*(r-1))) || (!isspace(*(r+strlen(w))) && *(r+strlen(w))!=0) ); |
173 | r=strstr(r+1,w)); |
173 | r=strstr(r+1,w)); |
174 | return r; |
174 | return r; |
175 | } |
175 | } |
Line 202... | Line 202... | ||
202 | len=strlen(tag); |
202 | len=strlen(tag); |
203 | for(pp=strchr(p,'<'); pp!=NULL && *pp; pp=strchr(pp+1,'<')) { |
203 | for(pp=strchr(p,'<'); pp!=NULL && *pp; pp=strchr(pp+1,'<')) { |
204 | if(strncasecmp(pp+1,tag,len)==0 && !isalnum(*(pp+1+len))) return pp; |
204 | if(strncasecmp(pp+1,tag,len)==0 && !isalnum(*(pp+1+len))) return pp; |
205 | } |
205 | } |
206 | return p+strlen(p); |
206 | return p+strlen(p); |
207 | } |
207 | } |
208 | 208 | ||
209 | /* remove all html tags */ |
209 | /* remove all html tags */ |
210 | void detag(char *p) |
210 | void detag(char *p) |
211 | { |
211 | { |
212 | char *pp, *p2; |
212 | char *pp, *p2; |
213 | for(pp=strchr(p,'<'); pp!=NULL; pp=strchr(pp,'<')) { |
213 | for(pp=strchr(p,'<'); pp!=NULL; pp=strchr(pp,'<')) { |
214 | p2=find_tag_end(pp); |
214 | p2=find_tag_end(pp); |
215 | if(*p2==0) {*pp=0; return; } |
215 | if(*p2==0) {*pp=0; return; } |
216 | ovlstrcpy(pp,p2); |
216 | ovlstrcpy(pp,p2); |
217 | } |
217 | } |
218 | } |
218 | } |
219 | 219 | ||
220 | /* add a space after comma to see end of words */ |
220 | /* add a space after comma to see end of words */ |
221 | 221 | ||
222 | void comma(char *p) |
222 | void comma(char *p) |
223 | { |
223 | { |
224 | char *pp; |
224 | char *pp; |
225 | for(pp=strchr(p,','); pp; pp=strchr(pp+1,',')) |
225 | for(pp=strchr(p,','); pp; pp=strchr(pp+1,',')) |
226 | string_modify3(p,pp,pp+1,", "); |
226 | string_modify3(p,pp,pp+1,", "); |
227 | } |
227 | } |
228 | /* replace / by , */ |
228 | /* replace / by , */ |
229 | void backslash(char *p) |
229 | void backslash(char *p) |
230 | { |
230 | { |
231 | char *pp; |
231 | char *pp; |
232 | for(pp=strchr(p,'/'); pp; pp=strchr(pp+1,'/')) |
232 | for(pp=strchr(p,'/'); pp; pp=strchr(pp+1,'/')) |
233 | string_modify3(p,pp,pp+1,","); |
233 | string_modify3(p,pp,pp+1,","); |
234 | } |
234 | } |
235 | /* _getdef from lines.c except the error msg*/ |
235 | /* _getdef from lines.c except the error msg*/ |
236 | void _getdef(char buf[], char *name, char value[]) |
236 | void _getdef(char buf[], char *name, char value[]) |
237 | { |
237 | { |
238 | char *p1, *p2, *p3, *p4; |
238 | char *p1, *p2, *p3, *p4; |
239 | 239 | ||
240 | if(*name==0) goto nothing; /* this would create segfault. */ |
240 | if(*name==0) goto nothing; /* this would create segfault. */ |
241 | for(p1=strstr(buf,name); p1!=NULL; p1=strstr(p1+1,name)) { |
241 | for(p1=strstr(buf,name); p1!=NULL; p1=strstr(p1+1,name)) { |
242 | p2=find_word_start(p1+strlen(name)); |
242 | p2=find_word_start(p1+strlen(name)); |
Line 279... | Line 279... | ||
279 | buf=xmalloc(l+256); l=fread(buf,1,l,f); |
279 | buf=xmalloc(l+256); l=fread(buf,1,l,f); |
280 | fclose(f); |
280 | fclose(f); |
281 | if(l<=0) return; else buf[l]=0; |
281 | if(l<=0) return; else buf[l]=0; |
282 | _getdef(buf,name,value); |
282 | _getdef(buf,name,value); |
283 | free(buf); |
283 | free(buf); |
284 | } |
284 | } |
285 | 285 | ||
286 | void init(void) |
286 | void init(void) |
287 | { |
287 | { |
288 | char buf[MAX_LINELEN+1]; |
288 | char buf[MAX_LINELEN+1]; |
289 | char *p1,*p2,*s; |
289 | char *p1,*p2,*s; |
290 | int i,l; |
290 | int i,l; |
291 | FILE *f; |
291 | FILE *f; |
292 | 292 | ||
293 | s=getenv("modind_outdir"); if(s!=NULL && *s!=0) outdir=s; |
293 | s=getenv("modind_outdir"); if(s!=NULL && *s!=0) outdir=s; |
294 | s=getenv("modind_sheetdir"); if(s!=NULL && *s!=0) sheetdir=s; |
294 | s=getenv("modind_sheetdir"); if(s!=NULL && *s!=0) sheetdir=s; |
295 | s=getenv("modind_sheetoutdir"); if(s!=NULL && *s!=0) sheetoutdir=s; |
295 | s=getenv("modind_sheetoutdir"); if(s!=NULL && *s!=0) sheetoutdir=s; |
296 | s=getenv("modind_glossaryoutdir"); if(s!=NULL && *s!=0) glossaryoutdir=s; |
296 | s=getenv("modind_glossaryoutdir"); if(s!=NULL && *s!=0) glossaryoutdir=s; |
297 | /* take the langs declared in conffile */ |
297 | /* take the langs declared in conffile */ |
Line 346... | Line 346... | ||
346 | else {/* unknown language, not referenced */ |
346 | else {/* unknown language, not referenced */ |
347 | continue; |
347 | continue; |
348 | } |
348 | } |
349 | } |
349 | } |
350 | if(modcnt>0 && strcmp(old,p1)==0 && thislang>=0) { |
350 | if(modcnt>0 && strcmp(old,p1)==0 && thislang>=0) { |
351 | if(mod[modcnt-1].langcnt<langcnt) { |
351 | if(mod[modcnt-1].langcnt<langcnt) { |
352 | mod[modcnt-1].langs[mod[modcnt-1].langcnt]=thislang; |
352 | mod[modcnt-1].langs[mod[modcnt-1].langcnt]=thislang; |
353 | mod[modcnt-1].counts[mod[modcnt-1].langcnt]=t; |
353 | mod[modcnt-1].counts[mod[modcnt-1].langcnt]=t; |
354 | (mod[modcnt-1].langcnt)++; |
354 | (mod[modcnt-1].langcnt)++; |
355 | } |
355 | } |
356 | } |
356 | } |
357 | else { |
357 | else { |
358 | mod[modcnt].name=old=p1; |
358 | mod[modcnt].name=old=p1; |
359 | if(thislang>=0) { |
359 | if(thislang>=0) { |
360 | mod[modcnt].langs[0]=thislang; |
360 | mod[modcnt].langs[0]=thislang; |
361 | mod[modcnt].langcnt=1; |
361 | mod[modcnt].langcnt=1; |
362 | } |
362 | } |
363 | else mod[modcnt].langcnt=0; |
363 | else mod[modcnt].langcnt=0; |
364 | mod[modcnt].counts[0]=t; |
364 | mod[modcnt].counts[0]=t; |
Line 367... | Line 367... | ||
367 | } |
367 | } |
368 | snprintf(buf,sizeof(buf),"%s/language",outdir); |
368 | snprintf(buf,sizeof(buf),"%s/language",outdir); |
369 | langf=fopen(buf,"w"); |
369 | langf=fopen(buf,"w"); |
370 | snprintf(buf,sizeof(buf),"%s/title",outdir); |
370 | snprintf(buf,sizeof(buf),"%s/title",outdir); |
371 | titf=fopen(buf,"w"); |
371 | titf=fopen(buf,"w"); |
- | 372 | snprintf(buf,sizeof(buf),"%s/title_ca",outdir); |
|
- | 373 | titf_ca=fopen(buf,"w"); |
|
- | 374 | snprintf(buf,sizeof(buf),"%s/title_en",outdir); |
|
- | 375 | titf_en=fopen(buf,"w"); |
|
- | 376 | snprintf(buf,sizeof(buf),"%s/title_es",outdir); |
|
- | 377 | titf_es=fopen(buf,"w"); |
|
- | 378 | snprintf(buf,sizeof(buf),"%s/title_fr",outdir); |
|
- | 379 | titf_fr=fopen(buf,"w"); |
|
- | 380 | snprintf(buf,sizeof(buf),"%s/title_it",outdir); |
|
- | 381 | titf_it=fopen(buf,"w"); |
|
- | 382 | snprintf(buf,sizeof(buf),"%s/title_nl",outdir); |
|
- | 383 | titf_nl=fopen(buf,"w"); |
|
372 | snprintf(buf,sizeof(buf),"%s/description",outdir); |
384 | snprintf(buf,sizeof(buf),"%s/description",outdir); |
373 | descf=fopen(buf,"w"); |
385 | descf=fopen(buf,"w"); |
374 | snprintf(buf,sizeof(buf),"%s/author",outdir); |
386 | snprintf(buf,sizeof(buf),"%s/author",outdir); |
375 | authorf=fopen(buf,"w"); |
387 | authorf=fopen(buf,"w"); |
376 | snprintf(buf,sizeof(buf),"%s/version",outdir); |
388 | snprintf(buf,sizeof(buf),"%s/version",outdir); |
377 | versionf=fopen(buf,"w"); |
389 | versionf=fopen(buf,"w"); |
378 | snprintf(buf,sizeof(buf),"%s/%s/robot.phtml",outdir,mlistbase); |
390 | snprintf(buf,sizeof(buf),"%s/%s/robot.phtml",outdir,mlistbase); |
379 | robotf=fopen(buf,"w"); |
391 | robotf=fopen(buf,"w"); |
380 | fclose(addrf); fclose(serialf); |
392 | fclose(addrf); fclose(serialf); |
381 | if(!robotf || !versionf || !authorf || !descf || !titf |
393 | if(!robotf || !versionf || !authorf || !descf || !titf |
- | 394 | || !titf_ca || !titf_en || !titf_es || !titf_fr || !titf_it || !titf_nl |
|
- | 395 | || !langf) { |
|
382 | fprintf(stderr,"modind: error creating output files.\n"); |
396 | fprintf(stderr,"modind: error creating output files.\n"); |
383 | exit(1); |
397 | exit(1); |
384 | } |
398 | } |
385 | } |
399 | } |
386 | 400 | ||
Line 506... | Line 520... | ||
506 | FILE *indf; |
520 | FILE *indf; |
507 | int i,l; |
521 | int i,l; |
508 | 522 | ||
509 | snprintf(fbuf,sizeof(fbuf),"%s/%s.def",sheetdir,mod[serial].name); |
523 | snprintf(fbuf,sizeof(fbuf),"%s/%s.def",sheetdir,mod[serial].name); |
510 | indf=fopen(fbuf,"r"); if(indf==NULL) return -1; |
524 | indf=fopen(fbuf,"r"); if(indf==NULL) return -1; |
511 | l=fread(ibuf,1,MAX_LINELEN,indf); fclose(indf); |
525 | l=fread(ibuf,1,MAX_LINELEN,indf); fclose(indf); |
512 | if(l>0 && l<MAX_LINELEN) ibuf[l]=0; else return -1; |
526 | if(l>0 && l<MAX_LINELEN) ibuf[l]=0; else return -1; |
513 | for(i=0;i<SHEETINDEX_NO;i++) gsindbuf[i][0]=0; |
527 | for(i=0;i<SHEETINDEX_NO;i++) gsindbuf[i][0]=0; |
514 | for(i=0,p1=find_word_start(ibuf); |
528 | for(i=0,p1=find_word_start(ibuf); |
515 | i<SHEETINDEX_NO-1 && *p1!=':' && *p1!=0; |
529 | i<SHEETINDEX_NO-1 && *p1!=':' && *p1!=0; |
516 | i++,p1=p2) { |
530 | i++,p1=p2) { |
517 | p2=strchr(p1,'\n'); |
531 | p2=strchr(p1,'\n'); |
Line 659... | Line 673... | ||
659 | if(f!=NULL) {fprintf(f,"%s\n",name); fclose(f);} |
673 | if(f!=NULL) {fprintf(f,"%s\n",name); fclose(f);} |
660 | } |
674 | } |
661 | /* add serial number and language (resp.title, ...) to corresponding file */ |
675 | /* add serial number and language (resp.title, ...) to corresponding file */ |
662 | fprintf(langf,"%d:%s\n",serial,module_language); |
676 | fprintf(langf,"%d:%s\n",serial,module_language); |
663 | fprintf(titf,"%d:%s\n",serial,indbuf[i_title]); |
677 | fprintf(titf,"%d:%s\n",serial,indbuf[i_title]); |
- | 678 | if(indbuf[i_title_ca][0]!=0) |
|
- | 679 | fprintf(titf_ca,"%d:%s\n",serial,indbuf[i_title_ca]); |
|
- | 680 | else |
|
- | 681 | fprintf(titf_ca,"%d:%s\n",serial,indbuf[i_title]); |
|
- | 682 | if(indbuf[i_title_en][0]!=0) |
|
- | 683 | fprintf(titf_en,"%d:%s\n",serial,indbuf[i_title_en]); |
|
- | 684 | else |
|
- | 685 | fprintf(titf_en,"%d:%s\n",serial,indbuf[i_title]); |
|
- | 686 | if(indbuf[i_title_es][0]!=0) |
|
- | 687 | fprintf(titf_es,"%d:%s\n",serial,indbuf[i_title_es]); |
|
- | 688 | else |
|
- | 689 | fprintf(titf_es,"%d:%s\n",serial,indbuf[i_title]); |
|
- | 690 | if(indbuf[i_title_fr][0]!=0) |
|
- | 691 | fprintf(titf_fr,"%d:%s\n",serial,indbuf[i_title_fr]); |
|
- | 692 | else |
|
- | 693 | fprintf(titf_fr,"%d:%s\n",serial,indbuf[i_title]); |
|
- | 694 | if(indbuf[i_title_it][0]!=0) |
|
- | 695 | fprintf(titf_it,"%d:%s\n",serial,indbuf[i_title_it]); |
|
- | 696 | else |
|
- | 697 | fprintf(titf_it,"%d:%s\n",serial,indbuf[i_title]); |
|
- | 698 | if(indbuf[i_title_nl][0]!=0) |
|
- | 699 | fprintf(titf_nl,"%d:%s\n",serial,indbuf[i_title_nl]); |
|
- | 700 | else |
|
- | 701 | fprintf(titf_nl,"%d:%s\n",serial,indbuf[i_title]); |
|
- | 702 | ||
664 | fprintf(descf,"%d:%s\n",serial,indbuf[i_description]); |
703 | fprintf(descf,"%d:%s\n",serial,indbuf[i_description]); |
665 | fprintf(authorf,"%d:%s\n",serial,indbuf[i_author]); |
704 | fprintf(authorf,"%d:%s\n",serial,indbuf[i_author]); |
666 | fprintf(versionf,"%d:%s\n",serial,indbuf[i_version]); |
705 | fprintf(versionf,"%d:%s\n",serial,indbuf[i_version]); |
667 | 706 | ||
668 | /* add module's information in html page for robots */ |
707 | /* add module's information in html page for robots */ |
Line 812... | Line 851... | ||
812 | { |
851 | { |
813 | int i; |
852 | int i; |
814 | for (i = 0; i < open_files; i++) fclose(files[i]); |
853 | for (i = 0; i < open_files; i++) fclose(files[i]); |
815 | fclose(langf); fclose(titf); fclose(descf); fclose(robotf); |
854 | fclose(langf); fclose(titf); fclose(descf); fclose(robotf); |
816 | fclose(authorf); fclose(versionf); |
855 | fclose(authorf); fclose(versionf); |
- | 856 | fclose(titf_fr); fclose(titf_it);fclose(titf_es);fclose(titf_nl); |
|
- | 857 | fclose(titf_ca);fclose(titf_en); |
|
817 | } |
858 | } |
818 | 859 | ||
819 | /* FIXME ? differences with appenditem - use fprintf instead of snprintf */ |
860 | /* FIXME ? differences with appenditem - use fprintf instead of snprintf */ |
820 | void sappenditem(char *word, int lind, int serial, int weight) |
861 | void sappenditem(char *word, int lind, int serial, int weight) |
821 | { |
862 | { |