mkey1.c (0:68f95e015346) mkey1.c (719:6c26331bc6b8)
1/*
2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5
1/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
2/* All Rights Reserved */
3
6/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7/* All Rights Reserved */
8
4
5/*
6 * Copyright (c) 1980 Regents of the University of California.
7 * All rights reserved. The Berkeley software License Agreement
8 * specifies the terms and conditions for redistribution.
9 */
10
9/*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
13 */
14
11/*
12 * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc.
13 * All Rights Reserved.
14 */
15#pragma ident "%Z%%M% %I% %E% SMI"
15
16
16#pragma ident "%Z%%M% %I% %E% SMI"
17
18#include <stdio.h>
19#include <locale.h>
20
21extern char *comname; /* "/usr/lib/refer/eign" */
22int wholefile = 0;
23int keycount = 100;
24int labels = 1;
25int minlen = 3;
26extern int comcount;
27char *iglist = "XYZ#";
28
17#include <stdio.h>
18#include <locale.h>
19
20extern char *comname; /* "/usr/lib/refer/eign" */
21int wholefile = 0;
22int keycount = 100;
23int labels = 1;
24int minlen = 3;
25extern int comcount;
26char *iglist = "XYZ#";
27
29main (argc,argv)
30char *argv[];
28extern void dofile();
29extern void err();
30extern char *trimnl();
31
32int
33main(int argc, char *argv[])
31{
34{
32 /* this program expects as its arguments a list of
35 /*
36 * this program expects as its arguments a list of
33 * files and generates a set of lines of the form
34 * filename:byte-add,length (tab) key1 key2 key3
35 * where the byte addresses give the position within
36 * the file and the keys are the strings off the lines
37 * which are alphabetic, first six characters only.
38 */
39
40 int i;
41 char *name, qn[200];
42 char *inlist = 0;
43
44 FILE *f, *ff;
45
46 (void) setlocale(LC_ALL, "");
47
48#if !defined(TEXT_DOMAIN)
37 * files and generates a set of lines of the form
38 * filename:byte-add,length (tab) key1 key2 key3
39 * where the byte addresses give the position within
40 * the file and the keys are the strings off the lines
41 * which are alphabetic, first six characters only.
42 */
43
44 int i;
45 char *name, qn[200];
46 char *inlist = 0;
47
48 FILE *f, *ff;
49
50 (void) setlocale(LC_ALL, "");
51
52#if !defined(TEXT_DOMAIN)
49#define TEXT_DOMAIN "SYS_TEST"
53#define TEXT_DOMAIN "SYS_TEST"
50#endif
51 (void) textdomain(TEXT_DOMAIN);
52
54#endif
55 (void) textdomain(TEXT_DOMAIN);
56
53 while (argc>1 && argv[1][0] == '-')
54 {
55 switch(argv[1][1])
56 {
57 while (argc > 1 && argv[1][0] == '-') {
58 switch (argv[1][1]) {
57 case 'c':
58 comname = argv[2];
59 case 'c':
60 comname = argv[2];
59 argv++;
61 argv++;
60 argc--;
61 break;
62 case 'w':
62 argc--;
63 break;
64 case 'w':
63 wholefile = 1;
65 wholefile = 1;
64 break;
65 case 'f':
66 inlist = argv[2];
66 break;
67 case 'f':
68 inlist = argv[2];
67 argv++;
69 argv++;
68 argc--;
69 break;
70 case 'i':
71 iglist = argv[2];
70 argc--;
71 break;
72 case 'i':
73 iglist = argv[2];
72 argv++;
74 argv++;
73 argc--;
74 break;
75 case 'l':
76 minlen = atoi(argv[1]+2);
75 argc--;
76 break;
77 case 'l':
78 minlen = atoi(argv[1]+2);
77 if (minlen<=0) minlen=3;
79 if (minlen <= 0) minlen = 3;
78 break;
79 case 'n': /* number of common words to use */
80 comcount = atoi(argv[1]+2);
81 break;
82 case 'k': /* number of keys per file max */
83 keycount = atoi(argv[1]+2);
84 break;
85 case 's': /* suppress labels, search only */
86 labels = 0;
87 break;
88 }
80 break;
81 case 'n': /* number of common words to use */
82 comcount = atoi(argv[1]+2);
83 break;
84 case 'k': /* number of keys per file max */
85 keycount = atoi(argv[1]+2);
86 break;
87 case 's': /* suppress labels, search only */
88 labels = 0;
89 break;
90 }
89 argc--;
91 argc--;
90 argv++;
91 }
92 argv++;
93 }
92 if (inlist)
93 {
94 if (inlist) {
94 ff = fopen(inlist, "r");
95 ff = fopen(inlist, "r");
95 while (fgets(qn, 200, ff))
96 {
96 while (fgets(qn, 200, ff)) {
97 trimnl(qn);
97 trimnl(qn);
98 f = fopen (qn, "r");
99 if (f!=NULL)
98 f = fopen(qn, "r");
99 if (f != NULL)
100 dofile(f, qn);
101 else
100 dofile(f, qn);
101 else
102 fprintf(stderr, gettext("Can't read %s\n"),qn);
102 fprintf(stderr, gettext("Can't read %s\n"), qn);
103 }
103 }
104 }
105 else
106 if (argc<=1)
104 } else
105 if (argc <= 1)
107 dofile(stdin, "");
108 else
106 dofile(stdin, "");
107 else
109 for(i=1; i<argc; i++)
110 {
111 f = fopen(name=argv[i], "r");
112 if (f==NULL)
113 err(gettext("No file %s"),name);
108 for (i = 1; i < argc; i++) {
109 f = fopen(name = argv[i], "r");
110 if (f == NULL)
111 err(gettext("No file %s"), name);
114 else
115 dofile(f, name);
116 }
112 else
113 dofile(f, name);
114 }
117 exit(0);
118 /* NOTREACHED */
115 return (0);
119}
116}