Rev 15393 | Rev 15440 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 15393 | Rev 15394 | ||
---|---|---|---|
Line 191... | Line 191... | ||
191 | /*if(p3-p2>=MAX_LINELEN) user_error("cmd_output_too_long");*/ |
191 | /*if(p3-p2>=MAX_LINELEN) user_error("cmd_output_too_long");*/ |
192 | memmove(value,p2,p3-p2); value[p3-p2]=0; |
192 | memmove(value,p2,p3-p2); value[p3-p2]=0; |
193 | strip_trailing_spaces(value); return; |
193 | strip_trailing_spaces(value); return; |
194 | } |
194 | } |
195 | nothing: |
195 | nothing: |
196 | value[0]=0 |
196 | value[0]=0; |
197 | } |
197 | } |
198 | 198 | ||
199 | /* Get variable definition from a file. |
199 | /* Get variable definition from a file. |
200 | * Result stored in buffer value of length MAX_LINELEN. |
200 | * Result stored in buffer value of length MAX_LINELEN. |
201 | */ |
201 | */ |
Line 353... | Line 353... | ||
353 | mod[modcnt].name=p1; |
353 | mod[modcnt].name=p1; |
354 | mod[modcnt].langs[0]=i; |
354 | mod[modcnt].langs[0]=i; |
355 | mod[modcnt].langcnt=1; |
355 | mod[modcnt].langcnt=1; |
356 | modcnt++; |
356 | modcnt++; |
357 | } |
357 | } |
358 | } |
- | |
359 | - | ||
360 | void clean(void) |
- | |
361 | { |
- | |
362 | fclose(langf); fclose(titf); fclose(descf); fclose(robotf); |
- | |
363 | fclose(authorf); fclose(versionf); |
- | |
364 | } |
358 | } |
365 | 359 | ||
366 | char *sheetindex[]={ |
360 | char *sheetindex[]={ |
367 | "title", "description", |
361 | "title", "description", |
368 | "duration", "severity", |
362 | "duration", "severity", |
Line 484... | Line 478... | ||
484 | } |
478 | } |
485 | 479 | ||
486 | unsigned char categories[16]; |
480 | unsigned char categories[16]; |
487 | char taken[MAX_LINELEN+1]; |
481 | char taken[MAX_LINELEN+1]; |
488 | int catcnt, takenlen, tweight; |
482 | int catcnt, takenlen, tweight; |
- | 483 | ||
- | 484 | /* file management for appenditem */ |
|
- | 485 | #define MAX_FILES (MAX_LANGS*catno) |
|
- | 486 | ||
- | 487 | char *fnames[MAX_FILES]; |
|
- | 488 | FILE *files[MAX_FILES]; |
|
- | 489 | int open_files; |
|
- | 490 | ||
- | 491 | FILE * file_from_list(char *name){ |
|
- | 492 | int i, l = 0, r = open_files; |
|
- | 493 | while (r>l){ |
|
- | 494 | int m = (l+r)/2; |
|
- | 495 | int cmp = strcmp(name,fnames[m]); |
|
- | 496 | if (!cmp) return files[m]; |
|
- | 497 | if (cmp < 0) r = m; else l = m+1; |
|
- | 498 | } |
|
- | 499 | for (i=open_files; i > l; i--) {files[i]=files[i-1]; fnames[i]=fnames[i-1];} |
|
- | 500 | fnames[l] = xmalloc(MAX_FNAME); |
|
- | 501 | ovlstrcpy(fnames[l],name); |
|
- | 502 | open_files++; |
|
- | 503 | return files[l]=fopen(name,"a"); |
|
- | 504 | } |
|
489 | 505 | ||
490 | void appenditem(char *word, int lind, int serial, int weight, char *l) |
506 | void appenditem(char *word, int lind, int serial, int weight, char *l) |
491 | { |
507 | { |
492 | char nbuf[MAX_LINELEN+1], buf[MAX_LINELEN+1]; |
508 | char nbuf[MAX_LINELEN+1], buf[MAX_LINELEN+1]; |
493 | int i, ll; |
509 | int i, ll; |
Line 506... | Line 522... | ||
506 | takenlen+=ll; tweight+=weight; |
522 | takenlen+=ll; tweight+=weight; |
507 | snprintf(buf,sizeof(buf),"%s:%d?%d\n",word,serial,weight); |
523 | snprintf(buf,sizeof(buf),"%s:%d?%d\n",word,serial,weight); |
508 | for(i=0;i<catcnt;i++) { |
524 | for(i=0;i<catcnt;i++) { |
509 | snprintf(nbuf,sizeof(nbuf),"%s/%c.%s", |
525 | snprintf(nbuf,sizeof(nbuf),"%s/%c.%s", |
510 | outdir,categories[i],lang[lind]); |
526 | outdir,categories[i],lang[lind]); |
511 | f= |
527 | f = file_from_list(nbuf); |
512 | if(f!=NULL) {fputs(buf, |
528 | if(f!=NULL) {fputs(buf,f);} |
513 | } |
529 | } |
514 | } |
530 | } |
515 | 531 | ||
516 | void appenditem1 (char *buf, int lind, int serial, int weight, char *l ) |
532 | void appenditem1 (char *buf, int lind, int serial, int weight, char *l ) |
517 | { |
533 | { |
Line 648... | Line 664... | ||
648 | indbuf[i_keywords_ca], indbuf[i_keywords_en],indbuf[i_keywords_fr], |
664 | indbuf[i_keywords_ca], indbuf[i_keywords_en],indbuf[i_keywords_fr], |
649 | indbuf[i_keywords_it], indbuf[i_keywords_nl]); |
665 | indbuf[i_keywords_it], indbuf[i_keywords_nl]); |
650 | unknown_type=unk_leave; |
666 | unknown_type=unk_leave; |
651 | translate(buf); |
667 | translate(buf); |
652 | appenditem1(buf,lind,serial,2,module_language); |
668 | appenditem1(buf,lind,serial,2,module_language); |
653 | 669 | ||
654 | /* append level information, with weight 2 */ |
670 | /* append level information, with weight 2 */ |
655 | snprintf(buf,sizeof(buf),"%s",indbuf[i_level]); |
671 | snprintf(buf,sizeof(buf),"%s",indbuf[i_level]); |
656 | ovlstrcpy(lbuf,"level"); |
672 | ovlstrcpy(lbuf,"level"); |
657 | for(p1=buf; *p1; p1++) if(!isalnum(*p1)) *p1=' '; |
673 | for(p1=buf; *p1; p1++) if(!isalnum(*p1)) *p1=' '; |
658 | q=buf+strlen(buf); |
674 | q=buf+strlen(buf); |
Line 665... | Line 681... | ||
665 | (*(p1+1)!=0 && *(p1+2)!=0))) |
681 | (*(p1+1)!=0 && *(p1+2)!=0))) |
666 | continue; |
682 | continue; |
667 | *p1=tolower(*p1); |
683 | *p1=tolower(*p1); |
668 | ovlstrcpy(lbuf+strlen("level"),p1); |
684 | ovlstrcpy(lbuf+strlen("level"),p1); |
669 | appenditem(lbuf,lind,serial,2,module_language); |
685 | appenditem(lbuf,lind,serial,2,module_language); |
670 | } |
686 | } |
671 | /* append total weight of module to weight file site2/weight.xx */ |
687 | /* append total weight of module to weight file site2/weight.xx */ |
672 | fprintf(weightf,"%d:%d\n",serial,tweight); |
688 | fprintf(weightf,"%d:%d\n",serial,tweight); |
673 | } |
689 | } |
674 | 690 | ||
675 | void modules(void) |
691 | void modules(void) |
Line 714... | Line 730... | ||
714 | if(gentrycount>0) free(gdicbuf); |
730 | if(gentrycount>0) free(gdicbuf); |
715 | if(suffixcnt>0) free(sufbuf); |
731 | if(suffixcnt>0) free(sufbuf); |
716 | if(dentrycount>0) free(ddicbuf); |
732 | if(dentrycount>0) free(ddicbuf); |
717 | if(weightf) fclose(weightf); |
733 | if(weightf) fclose(weightf); |
718 | } |
734 | } |
- | 735 | } |
|
- | 736 | void clean(void) |
|
- | 737 | { |
|
- | 738 | int i; |
|
- | 739 | for (i = 0; i < open_files; i++) fclose(files[i]); |
|
- | 740 | fclose(langf); fclose(titf); fclose(descf); fclose(robotf); |
|
- | 741 | fclose(authorf); fclose(versionf); |
|
719 | } |
742 | } |
720 | 743 | ||
721 | /* FIXME ? differences with appenditem - use fprintf instead of snprintf */ |
744 | /* FIXME ? differences with appenditem - use fprintf instead of snprintf */ |
722 | void sappenditem(char *word, int lind, int serial, int weight) |
745 | void sappenditem(char *word, int lind, int serial, int weight) |
723 | { |
746 | { |
Line 901... | Line 924... | ||
901 | if(gentrycount>0) free(gdicbuf); |
924 | if(gentrycount>0) free(gdicbuf); |
902 | if(suffixcnt>0) free(sufbuf); |
925 | if(suffixcnt>0) free(sufbuf); |
903 | if(dentrycount>0) free(ddicbuf); |
926 | if(dentrycount>0) free(ddicbuf); |
904 | fclose(titf); fclose(descf); fclose(indf); fclose(listf); |
927 | fclose(titf); fclose(descf); fclose(indf); fclose(listf); |
905 | fclose(weightf); fclose(addrf); fclose(serialf); |
928 | fclose(weightf); fclose(addrf); fclose(serialf); |
906 | fclose(remf);fclose(titlef); |
- | |
907 | } |
929 | } |
908 | } |
930 | } |
909 | 931 | ||
910 | int main() |
932 | int main() |
911 | { |
933 | { |