Use log_mask_str now.
[idzebra-moved-to-github.git] / dict / dictext.c
1 /*
2  * Copyright (C) 1994, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: dictext.c,v $
7  * Revision 1.2  1994-09-28 13:07:08  adam
8  * Use log_mask_str now.
9  *
10  * Revision 1.1  1994/09/16  15:39:11  adam
11  * Initial code of lookup - not tested yet.
12  *
13  */
14
15 #include <string.h>
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <assert.h>
19 #include <ctype.h>
20
21 #include <util.h>
22
23 char *prog;
24
25 int main (int argc, char **argv)
26 {
27     char *arg;
28     int ret;
29     char *inputfile = NULL;
30     FILE *ipf = stdin;
31     char ipf_buf[1024];
32
33     prog = *argv;
34     while ((ret = options ("vh", argv, argc, &arg)) != -2)
35     {
36         if (ret == 0)
37         {
38             if (!inputfile)
39                 inputfile = arg;
40             else
41             {
42                 log (LOG_FATAL, "too many files specified\n");
43                 exit (1);
44             }
45         }
46         else if (ret == 'v')
47         {
48             log_init (log_mask_str(arg), prog, NULL);
49         }
50         else if (ret == 'h')
51         {
52             fprintf (stderr, "usage:\n"
53                      "  %s [-h] [-v n] [file]\n", prog);
54             exit (1);
55         }
56         else
57         {
58             log (LOG_FATAL, "unknown option");
59             exit (1);
60         }
61     }
62     if (inputfile)
63     {
64         ipf = fopen (inputfile, "r");
65         if (!ipf)
66         {
67             log (LOG_FATAL|LOG_ERRNO, "cannot open '%s'", inputfile);
68             exit (1);
69         }
70     }
71     while (fgets (ipf_buf, 1023, ipf))
72     {
73         char *ipf_ptr = ipf_buf;
74         for (;*ipf_ptr && *ipf_ptr != '\n';ipf_ptr++)
75         {
76             if (isalpha(*ipf_ptr) || *ipf_ptr == '_')
77             {
78                 int i = 1;
79                 while (ipf_ptr[i] && (isalnum(ipf_ptr[i]) ||
80                                       ipf_ptr[i] == '_'))
81                     i++;
82                 if (ipf_ptr[i])
83                     ipf_ptr[i++] = '\0';
84                 printf ("%s\n", ipf_ptr);
85                 ipf_ptr += (i-1);
86             }
87         }
88     }
89     return 0;
90 }
91
92
93