IDZEBRA 2.2.8
dictext.c
Go to the documentation of this file.
1/* This file is part of the Zebra server.
2 Copyright (C) Index Data
3
4Zebra is free software; you can redistribute it and/or modify it under
5the terms of the GNU General Public License as published by the Free
6Software Foundation; either version 2, or (at your option) any later
7version.
8
9Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10WARRANTY; without even the implied warranty of MERCHANTABILITY or
11FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
18*/
19
20
21
22#if HAVE_CONFIG_H
23#include <config.h>
24#endif
25#include <string.h>
26#include <stdlib.h>
27#include <stdio.h>
28#include <assert.h>
29#include <ctype.h>
30
31#include <idzebra/util.h>
32#include <yaz/yaz-util.h>
33
34char *prog;
35
36int main(int argc, char **argv)
37{
38 char *arg;
39 int ret;
40 int use8 = 0;
41 char *inputfile = NULL;
42 FILE *ipf = stdin;
43 char ipf_buf[1024];
44
45 prog = *argv;
46 while ((ret = options("8vh", argv, argc, &arg)) != -2)
47 {
48 if (ret == 0)
49 {
50 if (!inputfile)
51 inputfile = arg;
52 else
53 {
54 yaz_log(YLOG_FATAL, "too many files specified\n");
55 exit(1);
56 }
57 }
58 else if (ret == 'v')
59 {
60 yaz_log_init(yaz_log_mask_str(arg), prog, NULL);
61 }
62 else if (ret == 'h')
63 {
64 fprintf(stderr, "usage:\n"
65 " %s [-8] [-h] [-v n] [file]\n", prog);
66 exit(1);
67 }
68 else if (ret == '8')
69 use8 = 1;
70 else
71 {
72 yaz_log(YLOG_FATAL, "Unknown option '-%s'", arg);
73 exit(1);
74 }
75 }
76 if (inputfile)
77 {
78 ipf = fopen(inputfile, "r");
79 if (!ipf)
80 {
81 yaz_log(YLOG_FATAL|YLOG_ERRNO, "cannot open '%s'", inputfile);
82 exit(1);
83 }
84 }
85 while (fgets(ipf_buf, 1023, ipf))
86 {
87 char *ipf_ptr = ipf_buf;
88 for (;*ipf_ptr && *ipf_ptr != '\n';ipf_ptr++)
89 {
90 if ((use8 && *ipf_ptr<0)
91 || (*ipf_ptr > 0 && isalpha(*ipf_ptr))
92 || *ipf_ptr == '_')
93 {
94 int i = 1;
95 while (ipf_ptr[i] && ((use8 && ipf_ptr[i] < 0)
96 || (ipf_ptr[i]>0 && isalnum(ipf_ptr[i]))
97 || ipf_ptr[i] == '_'))
98 i++;
99 if (ipf_ptr[i])
100 ipf_ptr[i++] = '\0';
101 printf("%s\n", ipf_ptr);
102 ipf_ptr += (i-1);
103 }
104 }
105 }
106 return 0;
107}
108
109
110
111/*
112 * Local variables:
113 * c-basic-offset: 4
114 * c-file-style: "Stroustrup"
115 * indent-tabs-mode: nil
116 * End:
117 * vim: shiftwidth=4 tabstop=8 expandtab
118 */
119
int main(int argc, char **argv)
Definition dictext.c:36
char * prog
Definition dictext.c:34