Rev 7676 | Rev 8185 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7676 | Rev 8147 | ||
---|---|---|---|
Line 17... | Line 17... | ||
17 | 17 | ||
18 | /* This is an internal program, |
18 | /* This is an internal program, |
19 | * used to show statistics of frequentation, module by module. */ |
19 | * used to show statistics of frequentation, module by module. */ |
20 | 20 | ||
21 | #include "../wims.h" |
21 | #include "../wims.h" |
22 | - | ||
- | 22 | #include "../Lib/libwims.h" |
|
23 | #define MAX_FLEN 102400 |
23 | #define MAX_FLEN 102400 |
24 | #define MAX_LANGS 16 |
24 | #define MAX_LANGS 16 |
25 | char mbuf[MAX_LINELEN+1]; |
25 | char mbuf[MAX_LINELEN+1]; |
26 | char mbase[MAX_LINELEN+1]; |
26 | char mbase[MAX_LINELEN+1]; |
27 | char indexfile[MAX_LINELEN+1]; |
27 | char indexfile[MAX_LINELEN+1]; |
28 | char modify_time[1024]; |
28 | char modify_time[1024]; |
29 | char vbuf[MAX_LINELEN+1]; |
29 | char vbuf[MAX_LINELEN+1]; |
30 | char *tlist, *mlist, *slist; /* fields, modules, sqled modules */ |
30 | char *tlist, *mlist, *slist; /* fields, modules, sqled modules */ |
31 | char *langs; /* site languages */ |
31 | char *langs; /* site languages */ |
32 | char language[MAX_LANGS][4]; |
32 | char language[MAX_LANGS][4]; |
33 | 33 | ||
34 | int start,end,mstart,mend,modtype,reqs,sites; |
34 | int start,end,mstart,mend,modtype,reqs,sites; |
35 | int languagecnt=0; |
35 | int languagecnt=0; |
36 | int count[MAX_LANGS],tcount; |
36 | int count[MAX_LANGS],tcount; |
37 | - | ||
38 | void *xmalloc(size_t n) |
- | |
39 | { |
- | |
40 | void *p; |
- | |
41 | p=malloc(n); |
- | |
42 | if(p==NULL) { |
- | |
43 | printf("Malloc failure.\n"); |
- | |
44 | exit(1); |
- | |
45 | } |
- | |
46 | return p; |
- | |
47 | } |
- | |
48 | - | ||
49 | /* Points to the end of the word */ |
- | |
50 | char *find_word_end(char *p) |
- | |
51 | { |
- | |
52 | int i; |
- | |
53 | for(i=0;!isspace(*p) && *p!=0 && i<MAX_LINELEN; p++,i++); |
- | |
54 | return p; |
- | |
55 | } |
- | |
56 | - | ||
57 | /* Strips leading spaces */ |
- | |
58 | char *find_word_start(char *p) |
- | |
59 | { |
- | |
60 | int i; |
- | |
61 | for(i=0; isspace(*p) && i<MAX_LINELEN; p++,i++); |
- | |
62 | return p; |
- | |
63 | } |
- | |
64 | - | ||
65 | /* Find first occurrence of word */ |
- | |
66 | char *wordchr(char *p, char *w) |
- | |
67 | { |
- | |
68 | char *r; |
- | |
69 | - | ||
70 | for(r=strstr(p,w);r!=NULL && |
- | |
71 | ( (r>p && !isspace(*(r-1))) || (!isspace(*(r+strlen(w))) && *(r+strlen(w))!=0) ); |
- | |
72 | r=strstr(r+1,w)); |
- | |
73 | return r; |
- | |
74 | } |
- | |
75 | - | ||
76 | /* find a variable in a string (math expression). |
- | |
77 | * Returns the pointer or NULL. */ |
- | |
78 | char *varchr(char *p, char *v) |
- | |
79 | { |
- | |
80 | char *pp; int n=strlen(v); |
- | |
81 | for(pp=strstr(p,v); pp!=NULL; pp=strstr(pp+1,v)) { |
- | |
82 | if((pp==p || !isalnum(*(pp-1))) && |
- | |
83 | (!isalnum(*(pp+n)) || *(pp+n)==0)) break; |
- | |
84 | } |
- | |
85 | return pp; |
- | |
86 | } |
- | |
87 | - | ||
88 | /* strip trailing spaces; return string end. */ |
- | |
89 | char *strip_trailing_spaces(char *p) |
- | |
90 | { |
- | |
91 | char *pp; |
- | |
92 | if(*p==0) return p; |
- | |
93 | for(pp=p+strlen(p)-1; pp>=p && isspace(*pp); *(pp--)=0); |
- | |
94 | return pp; |
- | |
95 | } |
- | |
96 | 37 | ||
97 | void getlangs(void) |
38 | void getlangs(void) |
98 | { |
39 | { |
99 | char *p; |
40 | char *p; |
100 | 41 |