148260Sbostic /*-
2*66541Sbostic * Copyright (c) 1991, 1993, 1994
361993Sbostic * The Regents of the University of California. All rights reserved.
448260Sbostic *
548260Sbostic * %sccs.include.proprietary.c%
648260Sbostic */
748260Sbostic
812673Ssam #ifndef lint
961993Sbostic static char copyright[] =
10*66541Sbostic "@(#) Copyright (c) 1991, 1993, 1994\n\
1161993Sbostic The Regents of the University of California. All rights reserved.\n";
1248260Sbostic #endif /* not lint */
1348260Sbostic
1448260Sbostic #ifndef lint
15*66541Sbostic static char sccsid[] = "@(#)file.c 8.2 (Berkeley) 03/31/94";
1648260Sbostic #endif /* not lint */
1748260Sbostic
18613Sbill /*
19613Sbill * file - determine type of file
20613Sbill */
21613Sbill
2217963Sserge #include <sys/param.h>
2313755Ssam #include <sys/stat.h>
2442419Sbostic #include <string.h>
25613Sbill #include <stdio.h>
26613Sbill #include <ctype.h>
27904Sbill #include <a.out.h>
2832251Sbostic
2950870Skarels #if defined(hp300) || defined(hp800)
3054024Sbostic #include <hp/hpux/hpux_exec.h>
3150870Skarels #endif
3232251Sbostic
3350870Skarels extern int errno;
34613Sbill int in;
35613Sbill int i = 0;
3660104Selan
3760104Selan #define BUFSIZE 4096
3860104Selan
3960104Selan char buf[BUFSIZE];
40613Sbill char *troff[] = { /* new troff intermediate lang */
41613Sbill "x","T","res","init","font","202","V0","p1",0};
42613Sbill char *fort[] = {
43613Sbill "function","subroutine","common","dimension","block","integer",
44613Sbill "real","data","double",0};
45613Sbill char *asc[] = {
46613Sbill "chmk","mov","tst","clr","jmp",0};
47613Sbill char *c[] = {
4860108Selan "int","char","float","double","struct","extern", "static",0};
49613Sbill char *as[] = {
50613Sbill "globl","byte","align","text","data","comm",0};
5120852Ssam char *sh[] = {
5220852Ssam "fi", "elif", "esac", "done", "export",
5320852Ssam "readonly", "trap", "PATH", "HOME", 0 };
5420852Ssam char *csh[] = {
5520852Ssam "alias", "breaksw", "endsw", "foreach", "limit", "onintr",
5620852Ssam "repeat", "setenv", "source", "path", "home", 0 };
57613Sbill int ifile;
58613Sbill
59*66541Sbostic int (*statfcn) __P((const char *, struct stat *));
60*66541Sbostic
main(argc,argv)61613Sbill main(argc, argv)
62613Sbill char **argv;
63613Sbill {
64613Sbill FILE *fl;
65613Sbill register char *p;
6617963Sserge char ap[MAXPATHLEN + 1];
67613Sbill
6817963Sserge if (argc < 2) {
6917963Sserge fprintf(stderr, "usage: %s file ...\n", argv[0]);
7017963Sserge exit(3);
7117963Sserge }
72*66541Sbostic
73*66541Sbostic if (argc>1 && argv[1][0]=='-' && argv[1][1]=='h') {
74*66541Sbostic statfcn = lstat;
75*66541Sbostic --argc;
76*66541Sbostic ++argv;
77*66541Sbostic } else
78*66541Sbostic statfcn = stat;
79*66541Sbostic
80613Sbill if (argc>1 && argv[1][0]=='-' && argv[1][1]=='f') {
81613Sbill if ((fl = fopen(argv[2], "r")) == NULL) {
8212101Smckusick perror(argv[2]);
83613Sbill exit(2);
84613Sbill }
8517963Sserge while ((p = fgets(ap, sizeof ap, fl)) != NULL) {
86613Sbill int l = strlen(p);
87613Sbill if (l>0)
88613Sbill p[l-1] = '\0';
89613Sbill type(p);
90613Sbill if (ifile>=0)
91613Sbill close(ifile);
92613Sbill }
93613Sbill exit(1);
94613Sbill }
95613Sbill while(argc > 1) {
9647028Sbostic ifile = -1;
97613Sbill type(argv[1]);
98613Sbill fflush(stdout);
99613Sbill argc--;
100613Sbill argv++;
101613Sbill if (ifile >= 0)
102613Sbill close(ifile);
103613Sbill }
10417963Sserge exit(0);
105613Sbill }
106613Sbill
type(file)107613Sbill type(file)
108613Sbill char *file;
109613Sbill {
110613Sbill int j,nl;
111613Sbill char ch;
112613Sbill struct stat mbuf;
11317963Sserge char slink[MAXPATHLEN + 1];
11450870Skarels struct exec *hdr;
11550870Skarels #if defined(hp300) || defined(hp800)
11650870Skarels int ishpux300 = 0;
11750870Skarels int ishpux800 = 0;
11850870Skarels #endif
119613Sbill
120*66541Sbostic if (statfcn(file, &mbuf) < 0 &&
121*66541Sbostic (statfcn == lstat || lstat(file, &mbuf))) {
12242419Sbostic fprintf(stderr, "file: %s: %s\n", file, strerror(errno));
123613Sbill return;
124613Sbill }
125613Sbill switch (mbuf.st_mode & S_IFMT) {
1266719Smckusick case S_IFLNK:
12747869Skarels printf("%s:\tsymbolic link", file);
12817963Sserge j = readlink(file, slink, sizeof slink - 1);
12917963Sserge if (j >= 0) {
13017963Sserge slink[j] = '\0';
13117963Sserge printf(" to %s", slink);
13217963Sserge }
13317963Sserge printf("\n");
1346719Smckusick return;
1356719Smckusick
136613Sbill case S_IFDIR:
13747869Skarels printf("%s:\t", file);
13817963Sserge if (mbuf.st_mode & S_ISVTX)
13917963Sserge printf("append-only ");
140613Sbill printf("directory\n");
141613Sbill return;
142613Sbill
14317963Sserge case S_IFCHR:
144613Sbill case S_IFBLK:
14547869Skarels printf("%s:\t%s special (%d/%d)\n", file,
14625499Ssam (mbuf.st_mode&S_IFMT) == S_IFCHR ? "character" : "block",
14725499Ssam major(mbuf.st_rdev), minor(mbuf.st_rdev));
14817963Sserge return;
149613Sbill
15017963Sserge case S_IFSOCK:
15147869Skarels printf("%s:\tsocket\n", file);
152613Sbill return;
153613Sbill }
154613Sbill
155613Sbill ifile = open(file, 0);
15650870Skarels if (ifile < 0) {
15742419Sbostic fprintf(stderr, "file: %s: %s\n", file, strerror(errno));
158613Sbill return;
159613Sbill }
16047869Skarels printf("%s:\t", file);
16160104Selan in = read(ifile, buf, BUFSIZE);
16250870Skarels if (in == 0) {
163613Sbill printf("empty\n");
164613Sbill return;
165613Sbill }
16650870Skarels hdr = (struct exec *) buf;
16750870Skarels #ifdef MID_ZERO /* if we have a_mid field */
16850870Skarels switch (hdr->a_mid) {
16950870Skarels case MID_SUN010:
17050870Skarels printf("SUN 68010/68020 ");
17150870Skarels break;
17250870Skarels case MID_SUN020:
17350870Skarels printf("SUN 68020 ");
17450870Skarels break;
17550870Skarels case MID_HP200:
17650870Skarels printf("HP200 ");
17750870Skarels break;
17850870Skarels case MID_HP300:
17950870Skarels printf("HP300 ");
18050870Skarels break;
18150870Skarels #if defined(hp300) || defined(hp800)
18250870Skarels case MID_HPUX:
18357473Shibler printf("HP-UX series [234]00 ");
18450870Skarels ishpux300 = 1;
18550870Skarels if (hdr->a_magic == 0406) {
18650870Skarels printf("relocatable object\n");
18750870Skarels return;
18850870Skarels }
18950870Skarels break;
19050870Skarels case MID_HPUX800:
19150870Skarels printf("HP-UX series 800 ");
19250870Skarels ishpux800 = 1;
19350870Skarels if (hdr->a_magic == 0x106) {
19450870Skarels printf("relocatable object\n");
19550870Skarels return;
19650870Skarels }
19750870Skarels break;
19850870Skarels #endif
19958575Sralph #ifdef MID_MIPSI
20058575Sralph case MID_MIPSI:
20158575Sralph printf("MIPS R3000 ");
20258575Sralph break;
20358575Sralph #endif
20458575Sralph #ifdef MID_MIPSII
20558575Sralph case MID_MIPSII:
20658575Sralph printf("MIPS R4000 ");
20758575Sralph break;
20858575Sralph #endif
20950870Skarels #if BYTE_ORDER == BIG_ENDIAN
21050870Skarels case ((OMAGIC & 0xff) << 8) | (OMAGIC >> 8):
21150870Skarels case ((NMAGIC & 0xff) << 8) | (NMAGIC >> 8):
21250870Skarels case ((ZMAGIC & 0xff) << 8) | (ZMAGIC >> 8):
21350870Skarels printf("byte-swapped (VAX/386) ");
21450870Skarels hdr->a_magic = ((hdr->a_mid & 0xff) << 8) | (hdr->a_mid >> 8);
21550870Skarels break;
21658575Sralph #endif
21750870Skarels }
21850870Skarels #endif /* MID_ZERO, a_mid */
21950870Skarels switch (hdr->a_magic) {
220613Sbill
22150870Skarels case 0411:
22250870Skarels printf("jfr or pdp-11 unix 411 executable\n");
22350870Skarels return;
22450870Skarels
22550870Skarels case ZMAGIC:
226613Sbill printf("demand paged ");
22750870Skarels /* FALLTHROUGH */
228613Sbill
22950870Skarels case NMAGIC:
230613Sbill printf("pure ");
23150870Skarels /* FALLTHROUGH */
232613Sbill
23350870Skarels case OMAGIC:
23417963Sserge if (mbuf.st_mode & S_ISUID)
23517963Sserge printf("set-uid ");
23617963Sserge if (mbuf.st_mode & S_ISGID)
23717963Sserge printf("set-gid ");
23817963Sserge if (mbuf.st_mode & S_ISVTX)
23917963Sserge printf("sticky ");
24050870Skarels if ((mbuf.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) == 0 &&
24150870Skarels (hdr->a_trsize || hdr->a_drsize)) {
24250870Skarels printf("relocatable object\n");
24350870Skarels return;
24450870Skarels }
24557473Shibler #if defined(hp300)
24657473Shibler if (ishpux300) {
24757473Shibler if (((int *)buf)[2] & 0x40000000)
24857473Shibler printf("dynamically-linked ");
24957473Shibler }
25057473Shibler #endif
251613Sbill printf("executable");
25250870Skarels #if defined(hp300) || defined(hp800)
25350870Skarels if (ishpux300) {
25450870Skarels if (((int *)buf)[9] != 0)
25550870Skarels printf(" not stripped");
25650870Skarels } else if (ishpux800) {
25750870Skarels if (((int *)buf)[24] != 0)
25850870Skarels printf(" not stripped");
25950870Skarels } else
26050870Skarels #endif
26150870Skarels if (hdr->a_syms != 0)
262613Sbill printf(" not stripped");
263613Sbill printf("\n");
26420852Ssam return;
26557473Shibler #if defined(hp300)
26657473Shibler case 0x10e:
26757473Shibler printf("shared library, version %d\n", ((short *)buf)[2]);
26857473Shibler return;
26957473Shibler #endif
27050870Skarels }
271613Sbill
27250870Skarels switch (*(int *)buf) {
273613Sbill case 0177555:
274613Sbill printf("very old archive\n");
27520852Ssam return;
276613Sbill
277613Sbill case 0177545:
278613Sbill printf("old archive\n");
27920852Ssam return;
280897Sbill
281897Sbill case 070707:
282897Sbill printf("cpio data\n");
28320852Ssam return;
284613Sbill }
285613Sbill
28620852Ssam if (buf[0] == '#' && buf[1] == '!' && shellscript(buf+2, &mbuf))
28720852Ssam return;
28824666Sserge if (buf[0] == '\037' && buf[1] == '\235') {
28924666Sserge if (buf[2]&0x80)
29024666Sserge printf("block ");
29124666Sserge printf("compressed %d bit code data\n", buf[2]&0x1f);
29224666Sserge return;
29324666Sserge }
29450870Skarels if (strncmp(buf, "!<arch>\n__.SYMDEF", 17) == 0 ) {
295613Sbill printf("archive random library\n");
29620852Ssam return;
297613Sbill }
298613Sbill if (strncmp(buf, "!<arch>\n", 8)==0) {
299613Sbill printf("archive\n");
30020852Ssam return;
301613Sbill }
3025900Sroot if (mbuf.st_size % 512 == 0) { /* it may be a PRESS file */
3035900Sroot lseek(ifile, -512L, 2); /* last block */
30460104Selan if (read(ifile, buf, BUFSIZE) > 0 && *(short *)buf == 12138) {
3055900Sroot printf("PRESS file\n");
30620852Ssam return;
3075900Sroot }
3085900Sroot }
309613Sbill i = 0;
310613Sbill if(ccom() == 0)goto notc;
311613Sbill while(buf[i] == '#'){
312613Sbill j = i;
313613Sbill while(buf[i++] != '\n'){
314613Sbill if(i - j > 255){
315613Sbill printf("data\n");
31620852Ssam return;
317613Sbill }
318613Sbill if(i >= in)goto notc;
319613Sbill }
320613Sbill if(ccom() == 0)goto notc;
321613Sbill }
322613Sbill check:
323613Sbill if(lookup(c) == 1){
324613Sbill while((ch = buf[i++]) != ';' && ch != '{')if(i >= in)goto notc;
325613Sbill printf("c program text");
326613Sbill goto outa;
327613Sbill }
328613Sbill nl = 0;
329613Sbill while(buf[i] != '('){
330613Sbill if(buf[i] <= 0)
331613Sbill goto notas;
332613Sbill if(buf[i] == ';'){
333613Sbill i++;
334613Sbill goto check;
335613Sbill }
336613Sbill if(buf[i++] == '\n')
337613Sbill if(nl++ > 6)goto notc;
338613Sbill if(i >= in)goto notc;
339613Sbill }
340613Sbill while(buf[i] != ')'){
341613Sbill if(buf[i++] == '\n')
342613Sbill if(nl++ > 6)goto notc;
343613Sbill if(i >= in)goto notc;
344613Sbill }
345613Sbill while(buf[i] != '{'){
346613Sbill if(buf[i++] == '\n')
347613Sbill if(nl++ > 6)goto notc;
348613Sbill if(i >= in)goto notc;
349613Sbill }
350613Sbill printf("c program text");
351613Sbill goto outa;
352613Sbill notc:
353613Sbill i = 0;
354613Sbill while(buf[i] == 'c' || buf[i] == '#'){
355613Sbill while(buf[i++] != '\n')if(i >= in)goto notfort;
356613Sbill }
357613Sbill if(lookup(fort) == 1){
358613Sbill printf("fortran program text");
359613Sbill goto outa;
360613Sbill }
361613Sbill notfort:
362613Sbill i=0;
363613Sbill if(ascom() == 0)goto notas;
364613Sbill j = i-1;
365613Sbill if(buf[i] == '.'){
366613Sbill i++;
367613Sbill if(lookup(as) == 1){
368613Sbill printf("assembler program text");
369613Sbill goto outa;
370613Sbill }
371613Sbill else if(buf[j] == '\n' && isalpha(buf[j+2])){
372613Sbill printf("roff, nroff, or eqn input text");
373613Sbill goto outa;
374613Sbill }
375613Sbill }
376613Sbill while(lookup(asc) == 0){
377613Sbill if(ascom() == 0)goto notas;
378613Sbill while(buf[i] != '\n' && buf[i++] != ':')
379613Sbill if(i >= in)goto notas;
380613Sbill while(buf[i] == '\n' || buf[i] == ' ' || buf[i] == '\t')if(i++ >= in)goto notas;
381613Sbill j = i-1;
382613Sbill if(buf[i] == '.'){
383613Sbill i++;
384613Sbill if(lookup(as) == 1){
385613Sbill printf("assembler program text");
386613Sbill goto outa;
387613Sbill }
388613Sbill else if(buf[j] == '\n' && isalpha(buf[j+2])){
389613Sbill printf("roff, nroff, or eqn input text");
390613Sbill goto outa;
391613Sbill }
392613Sbill }
393613Sbill }
394613Sbill printf("assembler program text");
395613Sbill goto outa;
396613Sbill notas:
397613Sbill for(i=0; i < in; i++)if(buf[i]&0200){
39820852Ssam if (buf[0]=='\100' && buf[1]=='\357')
399613Sbill printf("troff (CAT) output\n");
40020852Ssam else
40120852Ssam printf("data\n");
40220852Ssam return;
403613Sbill }
40417963Sserge if (mbuf.st_mode&((S_IEXEC)|(S_IEXEC>>3)|(S_IEXEC>>6))) {
40517963Sserge if (mbuf.st_mode & S_ISUID)
40617963Sserge printf("set-uid ");
40717963Sserge if (mbuf.st_mode & S_ISGID)
40817963Sserge printf("set-gid ");
40917963Sserge if (mbuf.st_mode & S_ISVTX)
41017963Sserge printf("sticky ");
41120852Ssam if (shell(buf, in, sh))
41220852Ssam printf("shell script");
41320852Ssam else if (shell(buf, in, csh))
41420852Ssam printf("c-shell script");
41520852Ssam else
41620852Ssam printf("commands text");
41717963Sserge } else if (troffint(buf, in))
418613Sbill printf("troff intermediate output text");
41920852Ssam else if (shell(buf, in, sh))
42020852Ssam printf("shell commands");
42120852Ssam else if (shell(buf, in, csh))
42220852Ssam printf("c-shell commands");
423613Sbill else if (english(buf, in))
424613Sbill printf("English text");
425613Sbill else
426613Sbill printf("ascii text");
427613Sbill outa:
428613Sbill while(i < in)
429613Sbill if((buf[i++]&0377) > 127){
430613Sbill printf(" with garbage\n");
43120852Ssam return;
432613Sbill }
433613Sbill /* if next few lines in then read whole file looking for nulls ...
43460104Selan while((in = read(ifile,buf,BUFSIZE)) > 0)
435613Sbill for(i = 0; i < in; i++)
436613Sbill if((buf[i]&0377) > 127){
437613Sbill printf(" with garbage\n");
43820852Ssam return;
439613Sbill }
440613Sbill /*.... */
441613Sbill printf("\n");
442613Sbill }
443613Sbill
troffint(bp,n)444613Sbill troffint(bp, n)
445613Sbill char *bp;
446613Sbill int n;
447613Sbill {
448613Sbill int k;
449613Sbill
450613Sbill i = 0;
451613Sbill for (k = 0; k < 6; k++) {
452613Sbill if (lookup(troff) == 0)
453613Sbill return(0);
454613Sbill if (lookup(troff) == 0)
455613Sbill return(0);
456613Sbill while (i < n && buf[i] != '\n')
457613Sbill i++;
458613Sbill if (i++ >= n)
459613Sbill return(0);
460613Sbill }
461613Sbill return(1);
462613Sbill }
lookup(tab)463613Sbill lookup(tab)
464613Sbill char *tab[];
465613Sbill {
466613Sbill char r;
467613Sbill int k,j,l;
468613Sbill while(buf[i] == ' ' || buf[i] == '\t' || buf[i] == '\n')i++;
469613Sbill for(j=0; tab[j] != 0; j++){
470613Sbill l=0;
471613Sbill for(k=i; ((r=tab[j][l++]) == buf[k] && r != '\0');k++);
472613Sbill if(r == '\0')
473613Sbill if(buf[k] == ' ' || buf[k] == '\n' || buf[k] == '\t'
474613Sbill || buf[k] == '{' || buf[k] == '/'){
475613Sbill i=k;
476613Sbill return(1);
477613Sbill }
478613Sbill }
479613Sbill return(0);
480613Sbill }
ccom()481613Sbill ccom(){
482613Sbill char cc;
483613Sbill while((cc = buf[i]) == ' ' || cc == '\t' || cc == '\n')if(i++ >= in)return(0);
484613Sbill if(buf[i] == '/' && buf[i+1] == '*'){
485613Sbill i += 2;
486613Sbill while(buf[i] != '*' || buf[i+1] != '/'){
487613Sbill if(buf[i] == '\\')i += 2;
488613Sbill else i++;
489613Sbill if(i >= in)return(0);
490613Sbill }
491613Sbill if((i += 2) >= in)return(0);
492613Sbill }
493613Sbill if(buf[i] == '\n')if(ccom() == 0)return(0);
494613Sbill return(1);
495613Sbill }
ascom()496613Sbill ascom(){
497613Sbill while(buf[i] == '/'){
498613Sbill i++;
499613Sbill while(buf[i++] != '\n')if(i >= in)return(0);
500613Sbill while(buf[i] == '\n')if(i++ >= in)return(0);
501613Sbill }
502613Sbill return(1);
503613Sbill }
504613Sbill
english(bp,n)505613Sbill english (bp, n)
506613Sbill char *bp;
507613Sbill {
508613Sbill # define NASC 128
509613Sbill int ct[NASC], j, vow, freq, rare;
510613Sbill int badpun = 0, punct = 0;
511613Sbill if (n<50) return(0); /* no point in statistics on squibs */
512613Sbill for(j=0; j<NASC; j++)
513613Sbill ct[j]=0;
514613Sbill for(j=0; j<n; j++)
515613Sbill {
51634099Sbostic if ((u_char)bp[j]<NASC)
517613Sbill ct[bp[j]|040]++;
518613Sbill switch (bp[j])
519613Sbill {
520613Sbill case '.':
521613Sbill case ',':
522613Sbill case ')':
523613Sbill case '%':
524613Sbill case ';':
525613Sbill case ':':
526613Sbill case '?':
527613Sbill punct++;
528613Sbill if ( j < n-1 &&
529613Sbill bp[j+1] != ' ' &&
530613Sbill bp[j+1] != '\n')
531613Sbill badpun++;
532613Sbill }
533613Sbill }
534613Sbill if (badpun*5 > punct)
535613Sbill return(0);
536613Sbill vow = ct['a'] + ct['e'] + ct['i'] + ct['o'] + ct['u'];
537613Sbill freq = ct['e'] + ct['t'] + ct['a'] + ct['i'] + ct['o'] + ct['n'];
538613Sbill rare = ct['v'] + ct['j'] + ct['k'] + ct['q'] + ct['x'] + ct['z'];
539613Sbill if (2*ct[';'] > ct['e']) return(0);
540613Sbill if ( (ct['>']+ct['<']+ct['/'])>ct['e']) return(0); /* shell file test */
541613Sbill return (vow*5 >= n-ct[' '] && freq >= 10*rare);
542613Sbill }
54320852Ssam
shellscript(buf,sb)54420852Ssam shellscript(buf, sb)
54520852Ssam char buf[];
54620852Ssam struct stat *sb;
54720852Ssam {
54820852Ssam register char *tp;
54920852Ssam char *cp, *xp, *index();
55020852Ssam
55120852Ssam cp = index(buf, '\n');
55220852Ssam if (cp == 0 || cp - buf > in)
55320852Ssam return (0);
55420852Ssam for (tp = buf; tp != cp && isspace(*tp); tp++)
55520852Ssam if (!isascii(*tp))
55620852Ssam return (0);
55720852Ssam for (xp = tp; tp != cp && !isspace(*tp); tp++)
55820852Ssam if (!isascii(*tp))
55920852Ssam return (0);
56020852Ssam if (tp == xp)
56120852Ssam return (0);
56220852Ssam if (sb->st_mode & S_ISUID)
56320852Ssam printf("set-uid ");
56420852Ssam if (sb->st_mode & S_ISGID)
56520852Ssam printf("set-gid ");
56620852Ssam if (strncmp(xp, "/bin/sh", tp-xp) == 0)
56720852Ssam xp = "shell";
56820852Ssam else if (strncmp(xp, "/bin/csh", tp-xp) == 0)
56920852Ssam xp = "c-shell";
57020852Ssam else
57120852Ssam *tp = '\0';
57220852Ssam printf("executable %s script\n", xp);
57320852Ssam return (1);
57420852Ssam }
57520852Ssam
shell(bp,n,tab)57620852Ssam shell(bp, n, tab)
57720852Ssam char *bp;
57820852Ssam int n;
57920852Ssam char *tab[];
58020852Ssam {
58120852Ssam
58220852Ssam i = 0;
58320852Ssam do {
58420852Ssam if (buf[i] == '#' || buf[i] == ':')
58520852Ssam while (i < n && buf[i] != '\n')
58620852Ssam i++;
58720852Ssam if (++i >= n)
58820852Ssam break;
58920852Ssam if (lookup(tab) == 1)
59020852Ssam return (1);
59120852Ssam } while (i < n);
59220852Ssam return (0);
59320852Ssam }
594