1 /*-
2 * %sccs.include.proprietary.c%
3 */
4
5 #ifndef lint
6 static char sccsid[] = "@(#)inv5.c 4.4 (Berkeley) 04/18/91";
7 #endif /* not lint */
8
9 #include <stdio.h>
10
recopy(ft,fb,fa,nhash)11 recopy (ft, fb, fa, nhash)
12 FILE *ft, *fb, *fa;
13 {
14 /* copy fb (old hash items/pointers) to ft (new ones) */
15 int n, i, iflong;
16 long getl();
17 int getw();
18 int *hpt_s;
19 long *hpt_l;
20 long k, lp;
21 if (fa==NULL)
22 {
23 err("No old pointers",0);
24 return;
25 }
26 fread(&n, sizeof(n), 1, fa);
27 fread(&iflong, sizeof(iflong), 1, fa);
28 if (iflong)
29 {
30 hpt_l = (long *) calloc(sizeof(*hpt_l), n+1);
31 n =fread(hpt_l, sizeof(*hpt_l), n, fa);
32 }
33 else
34 {
35 hpt_s = (int *) calloc(sizeof(*hpt_s), n+1);
36 n =fread(hpt_s, sizeof(*hpt_s), n, fa);
37 }
38 if (n!= nhash)
39 fprintf(stderr, "Changing hash value to old %d\n",n);
40 fclose(fa);
41 for(i=0; i<n; i++)
42 {
43 if (iflong) {
44 lp = hpt_l[i];
45 fseek(fb, lp, 0);
46 while ( (k= getl(fb) ) != -1)
47 fprintf(ft, "%04d %06ld\n",i,k);
48 } else {
49 lp = hpt_s[i];
50 fseek(fb, lp, 0);
51 while ( (k= getw(fb) ) != -1)
52 fprintf(ft, "%04d %06ld\n",i,k);
53 }
54 }
55 fclose(fb);
56 return(n);
57 }
58