17 |
/* along with this program; if not, write to the Free Software */ |
/* along with this program; if not, write to the Free Software */ |
18 |
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
19 |
|
|
|
/* $Id$ */ |
|
|
|
|
20 |
/** |
/** |
21 |
* \file listdic.c |
* \file listdic.c |
22 |
* \brief Program used to list a dictionary |
* \brief Program used to list a dictionary |
37 |
if (i.term) /* edge points at a complete word */ |
if (i.term) /* edge points at a complete word */ |
38 |
{ |
{ |
39 |
*s = '\0'; |
*s = '\0'; |
40 |
fprintf (out,"%s\n", buf); |
fprintf (out,"%s\n", buf); |
41 |
} |
} |
42 |
if (i.ptr) |
if (i.ptr) |
43 |
{ /* Compute index: is it non-zero ? */ |
{ /* Compute index: is it non-zero ? */ |
44 |
Dawg_edge *p = dic->dawg + i.ptr; |
Dawg_edge *p = dic->dawg + i.ptr; |
45 |
do { /* for each edge out of this node */ |
do { /* for each edge out of this node */ |
46 |
*s = p->chr + 'a' - 1; |
*s = p->chr + 'a' - 1; |
47 |
print_dic_rec (out,dic,buf,s + 1, *p); |
print_dic_rec (out,dic,buf,s + 1, *p); |
48 |
} |
} |
49 |
while (!(*p++).last); |
while (!(*p++).last); |
50 |
} |
} |
51 |
} |
} |
52 |
|
|
53 |
void |
void |
54 |
dic_load(Dictionary* dic, char* filename) |
dic_load(Dictionary* dic, char* filename) |
55 |
{ |
{ |
56 |
int res; |
int res; |
57 |
if ((res = Dic_load(dic, filename)) != 0) |
if ((res = Dic_load(dic, filename)) != 0) |
58 |
{ |
{ |
59 |
switch (res) { |
switch (res) { |
60 |
case 1: printf("chargement: problème d'ouverture de %s\n",filename); break; |
case 1: printf("chargement: problème d'ouverture de %s\n",filename); break; |
74 |
FILE* fout; |
FILE* fout; |
75 |
Dictionary dic; |
Dictionary dic; |
76 |
static char buf[80]; |
static char buf[80]; |
77 |
|
|
78 |
dic_load(&dic,filename); |
dic_load(&dic,filename); |
79 |
|
|
80 |
if (strcmp(out,"stdout") == 0) |
if (strcmp(out,"stdout") == 0) |
176 |
int i; |
int i; |
177 |
Dictionary dic; |
Dictionary dic; |
178 |
dic_load(&dic,filename); |
dic_load(&dic,filename); |
179 |
|
|
180 |
printf("offs binary structure \n"); |
printf("offs binary structure \n"); |
181 |
printf("---- -------- | ------------------\n"); |
printf("---- -------- | ------------------\n"); |
182 |
for(i=0; i < (dic->nedges + 1); i++) |
for(i=0; i < (dic->nedges + 1); i++) |
195 |
} |
} |
196 |
|
|
197 |
|
|
198 |
int |
int |
199 |
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
200 |
{ |
{ |
201 |
int arg_count; |
int arg_count; |
204 |
int option_print_dic_hex = 0; |
int option_print_dic_hex = 0; |
205 |
int option_print_dic_list = 0; |
int option_print_dic_list = 0; |
206 |
|
|
207 |
if (argc < 2) |
if (argc < 2) |
208 |
{ |
{ |
209 |
usage(argv[0]); |
usage(argv[0]); |
210 |
exit(1); |
exit(1); |
211 |
} |
} |
212 |
|
|
213 |
arg_count = 1; |
arg_count = 1; |
214 |
while(argv[arg_count][0] == '-') |
while(argv[arg_count][0] == '-') |
215 |
{ |
{ |
224 |
} |
} |
225 |
arg_count++; |
arg_count++; |
226 |
} |
} |
227 |
|
|
228 |
if (option_print_header || option_print_all) |
if (option_print_header || option_print_all) |
229 |
{ |
{ |
230 |
print_header(argv[arg_count]); |
print_header(argv[arg_count]); |