1*11a8fa6cSceastha /*
2*11a8fa6cSceastha * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3*11a8fa6cSceastha * Use is subject to license terms.
4*11a8fa6cSceastha */
5*11a8fa6cSceastha
67c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
77c478bd9Sstevel@tonic-gate /* All Rights Reserved */
87c478bd9Sstevel@tonic-gate
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California.
117c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement
127c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution.
137c478bd9Sstevel@tonic-gate */
147c478bd9Sstevel@tonic-gate
157c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
167c478bd9Sstevel@tonic-gate
177c478bd9Sstevel@tonic-gate #include <stdio.h>
187c478bd9Sstevel@tonic-gate #include <locale.h>
197c478bd9Sstevel@tonic-gate
207c478bd9Sstevel@tonic-gate extern char *comname; /* "/usr/lib/refer/eign" */
217c478bd9Sstevel@tonic-gate int wholefile = 0;
227c478bd9Sstevel@tonic-gate int keycount = 100;
237c478bd9Sstevel@tonic-gate int labels = 1;
247c478bd9Sstevel@tonic-gate int minlen = 3;
257c478bd9Sstevel@tonic-gate extern int comcount;
267c478bd9Sstevel@tonic-gate char *iglist = "XYZ#";
277c478bd9Sstevel@tonic-gate
28*11a8fa6cSceastha extern void dofile();
29*11a8fa6cSceastha extern void err();
30*11a8fa6cSceastha extern char *trimnl();
31*11a8fa6cSceastha
32*11a8fa6cSceastha int
main(int argc,char * argv[])33*11a8fa6cSceastha main(int argc, char *argv[])
347c478bd9Sstevel@tonic-gate {
35*11a8fa6cSceastha /*
36*11a8fa6cSceastha * this program expects as its arguments a list of
377c478bd9Sstevel@tonic-gate * files and generates a set of lines of the form
387c478bd9Sstevel@tonic-gate * filename:byte-add,length (tab) key1 key2 key3
397c478bd9Sstevel@tonic-gate * where the byte addresses give the position within
407c478bd9Sstevel@tonic-gate * the file and the keys are the strings off the lines
417c478bd9Sstevel@tonic-gate * which are alphabetic, first six characters only.
427c478bd9Sstevel@tonic-gate */
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate int i;
457c478bd9Sstevel@tonic-gate char *name, qn[200];
467c478bd9Sstevel@tonic-gate char *inlist = 0;
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate FILE *f, *ff;
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate (void) setlocale(LC_ALL, "");
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN)
537c478bd9Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST"
547c478bd9Sstevel@tonic-gate #endif
557c478bd9Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN);
567c478bd9Sstevel@tonic-gate
57*11a8fa6cSceastha while (argc > 1 && argv[1][0] == '-') {
58*11a8fa6cSceastha switch (argv[1][1]) {
597c478bd9Sstevel@tonic-gate case 'c':
607c478bd9Sstevel@tonic-gate comname = argv[2];
617c478bd9Sstevel@tonic-gate argv++;
627c478bd9Sstevel@tonic-gate argc--;
637c478bd9Sstevel@tonic-gate break;
647c478bd9Sstevel@tonic-gate case 'w':
657c478bd9Sstevel@tonic-gate wholefile = 1;
667c478bd9Sstevel@tonic-gate break;
677c478bd9Sstevel@tonic-gate case 'f':
687c478bd9Sstevel@tonic-gate inlist = argv[2];
697c478bd9Sstevel@tonic-gate argv++;
707c478bd9Sstevel@tonic-gate argc--;
717c478bd9Sstevel@tonic-gate break;
727c478bd9Sstevel@tonic-gate case 'i':
737c478bd9Sstevel@tonic-gate iglist = argv[2];
747c478bd9Sstevel@tonic-gate argv++;
757c478bd9Sstevel@tonic-gate argc--;
767c478bd9Sstevel@tonic-gate break;
777c478bd9Sstevel@tonic-gate case 'l':
787c478bd9Sstevel@tonic-gate minlen = atoi(argv[1]+2);
797c478bd9Sstevel@tonic-gate if (minlen <= 0) minlen = 3;
807c478bd9Sstevel@tonic-gate break;
817c478bd9Sstevel@tonic-gate case 'n': /* number of common words to use */
827c478bd9Sstevel@tonic-gate comcount = atoi(argv[1]+2);
837c478bd9Sstevel@tonic-gate break;
847c478bd9Sstevel@tonic-gate case 'k': /* number of keys per file max */
857c478bd9Sstevel@tonic-gate keycount = atoi(argv[1]+2);
867c478bd9Sstevel@tonic-gate break;
877c478bd9Sstevel@tonic-gate case 's': /* suppress labels, search only */
887c478bd9Sstevel@tonic-gate labels = 0;
897c478bd9Sstevel@tonic-gate break;
907c478bd9Sstevel@tonic-gate }
917c478bd9Sstevel@tonic-gate argc--;
927c478bd9Sstevel@tonic-gate argv++;
937c478bd9Sstevel@tonic-gate }
94*11a8fa6cSceastha if (inlist) {
957c478bd9Sstevel@tonic-gate ff = fopen(inlist, "r");
96*11a8fa6cSceastha while (fgets(qn, 200, ff)) {
977c478bd9Sstevel@tonic-gate trimnl(qn);
987c478bd9Sstevel@tonic-gate f = fopen(qn, "r");
997c478bd9Sstevel@tonic-gate if (f != NULL)
1007c478bd9Sstevel@tonic-gate dofile(f, qn);
1017c478bd9Sstevel@tonic-gate else
1027c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("Can't read %s\n"), qn);
1037c478bd9Sstevel@tonic-gate }
104*11a8fa6cSceastha } else
1057c478bd9Sstevel@tonic-gate if (argc <= 1)
1067c478bd9Sstevel@tonic-gate dofile(stdin, "");
1077c478bd9Sstevel@tonic-gate else
108*11a8fa6cSceastha for (i = 1; i < argc; i++) {
1097c478bd9Sstevel@tonic-gate f = fopen(name = argv[i], "r");
1107c478bd9Sstevel@tonic-gate if (f == NULL)
1117c478bd9Sstevel@tonic-gate err(gettext("No file %s"), name);
1127c478bd9Sstevel@tonic-gate else
1137c478bd9Sstevel@tonic-gate dofile(f, name);
1147c478bd9Sstevel@tonic-gate }
115*11a8fa6cSceastha return (0);
1167c478bd9Sstevel@tonic-gate }
117