xref: /titanic_52/usr/src/cmd/refer/hunt5.c (revision bdfc6d18da790deeec2e0eb09c625902defe2498)
1 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
2 /*	  All Rights Reserved  	*/
3 
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 
11 /*
12  * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc.
13  * All Rights Reserved.
14  */
15 
16 #pragma ident	"%Z%%M%	%I%	%E% SMI"
17 
18 #include <stdio.h>
19 #include <sys/types.h>
20 #include <sys/stat.h>
21 
22 extern char *soutput, *tagout, usedir[];
23 union ptr {
24 	unsigned *a;
25 	long *b;
26 };
27 
28 result(mptr, nf, fc)
29 unsigned *mptr;
30 FILE *fc;
31 {
32 	int i, c;
33 	char *s;
34 	long lp;
35 	extern int iflong;
36 	char res[100];
37 	union ptr master;
38 
39 	if (iflong) {
40 		master.b = (long *) mptr;
41 	}
42 	else {
43 		master.a = mptr;
44 	}
45 
46 	for(i=0; i<nf; i++)
47 	{
48 		lp = iflong ? master.b[i] : master.a[i];
49 		fseek(fc,lp, 0);
50 		fgets(res, 100, fc);
51 		for(s=res; c = *s; s++)
52 			if (c== ';')
53 			{
54 				*s=0;
55 				break;
56 			}
57 		if (tagout !=0)
58 		{
59 			if (res[0]=='/' || usedir[0]==0)
60 				sprintf(tagout, "%s", res);
61 			else
62 				sprintf(tagout, "%s/%s", usedir, res);
63 			while (*tagout) tagout++;
64 		}
65 		else
66 		{
67 			if (res[0]!='/' || usedir[0]==0)
68 				printf("%s/", usedir);
69 			printf("%s\n", res);
70 		}
71 	}
72 }
73 
74 long
75 gdate(f)
76 FILE *f;
77 {
78 	struct stat sb;
79 	fstat (fileno(f), &sb);
80 	return  (sb . st_mtime);
81 }
82