xref: /titanic_41/usr/src/cmd/refer/inv5.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
2*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
3*7c478bd9Sstevel@tonic-gate 
4*7c478bd9Sstevel@tonic-gate 
5*7c478bd9Sstevel@tonic-gate /*
6*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
7*7c478bd9Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
8*7c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
9*7c478bd9Sstevel@tonic-gate  */
10*7c478bd9Sstevel@tonic-gate 
11*7c478bd9Sstevel@tonic-gate /*
12*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc.
13*7c478bd9Sstevel@tonic-gate  * All Rights Reserved.
14*7c478bd9Sstevel@tonic-gate  */
15*7c478bd9Sstevel@tonic-gate 
16*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
17*7c478bd9Sstevel@tonic-gate 
18*7c478bd9Sstevel@tonic-gate #include <stdio.h>
19*7c478bd9Sstevel@tonic-gate #include <locale.h>
20*7c478bd9Sstevel@tonic-gate 
21*7c478bd9Sstevel@tonic-gate recopy (ft, fb, fa, nhash)
22*7c478bd9Sstevel@tonic-gate FILE *ft, *fb, *fa;
23*7c478bd9Sstevel@tonic-gate {
24*7c478bd9Sstevel@tonic-gate 	/* copy fb (old hash items/pointers) to ft (new ones) */
25*7c478bd9Sstevel@tonic-gate 	int n, i, iflong;
26*7c478bd9Sstevel@tonic-gate 	long getl();
27*7c478bd9Sstevel@tonic-gate 	int getw();
28*7c478bd9Sstevel@tonic-gate 	int *hpt_s;
29*7c478bd9Sstevel@tonic-gate 	int (*getfun)();
30*7c478bd9Sstevel@tonic-gate 	long *hpt_l;
31*7c478bd9Sstevel@tonic-gate 	long k, lp;
32*7c478bd9Sstevel@tonic-gate 	if (fa==NULL)
33*7c478bd9Sstevel@tonic-gate 	{
34*7c478bd9Sstevel@tonic-gate 		err(gettext("No old pointers"),0);
35*7c478bd9Sstevel@tonic-gate 		return;
36*7c478bd9Sstevel@tonic-gate 	}
37*7c478bd9Sstevel@tonic-gate 	fread(&n, sizeof(n), 1, fa);
38*7c478bd9Sstevel@tonic-gate 	fread(&iflong, sizeof(iflong), 1, fa);
39*7c478bd9Sstevel@tonic-gate 	if (iflong)
40*7c478bd9Sstevel@tonic-gate 	{
41*7c478bd9Sstevel@tonic-gate 		hpt_l = (long *) calloc(sizeof(*hpt_l), n+1);
42*7c478bd9Sstevel@tonic-gate 		n =fread(hpt_l, sizeof(*hpt_l), n, fa);
43*7c478bd9Sstevel@tonic-gate 	}
44*7c478bd9Sstevel@tonic-gate 	else
45*7c478bd9Sstevel@tonic-gate 	{
46*7c478bd9Sstevel@tonic-gate 		hpt_s =  (int *) calloc(sizeof(*hpt_s), n+1);
47*7c478bd9Sstevel@tonic-gate 		n =fread(hpt_s, sizeof(*hpt_s), n, fa);
48*7c478bd9Sstevel@tonic-gate 	}
49*7c478bd9Sstevel@tonic-gate 	if (n!= nhash)
50*7c478bd9Sstevel@tonic-gate 		fprintf(stderr, gettext("Changing hash value to old %d\n"),n);
51*7c478bd9Sstevel@tonic-gate 	fclose(fa);
52*7c478bd9Sstevel@tonic-gate 	if (iflong)
53*7c478bd9Sstevel@tonic-gate 		getfun = (int(*)())getl;
54*7c478bd9Sstevel@tonic-gate 	else
55*7c478bd9Sstevel@tonic-gate 		getfun = getw;
56*7c478bd9Sstevel@tonic-gate 	for(i=0; i<n; i++)
57*7c478bd9Sstevel@tonic-gate 	{
58*7c478bd9Sstevel@tonic-gate 		if (iflong)
59*7c478bd9Sstevel@tonic-gate 			lp = hpt_l[i];
60*7c478bd9Sstevel@tonic-gate 		else
61*7c478bd9Sstevel@tonic-gate 			lp = hpt_s[i];
62*7c478bd9Sstevel@tonic-gate 		fseek(fb, lp, 0);
63*7c478bd9Sstevel@tonic-gate 		while ( (k= (*getfun)(fb) ) != -1)
64*7c478bd9Sstevel@tonic-gate 			fprintf(ft, "%04d %06ld\n",i,k);
65*7c478bd9Sstevel@tonic-gate 	}
66*7c478bd9Sstevel@tonic-gate 	fclose(fb);
67*7c478bd9Sstevel@tonic-gate 	return(n);
68*7c478bd9Sstevel@tonic-gate }
69