Commit | Line | Data |
---|---|---|
2b1a705e TL |
1 | # include "stdio.h" |
2 | ||
3 | recopy (ft, fb, fa, nhash) | |
4 | FILE *ft, *fb, *fa; | |
5 | { | |
6 | /* copy fb (old hash items/pointers) to ft (new ones) */ | |
7 | int n, i, iflong; | |
8 | long getl(); | |
9 | int getw(); | |
10 | int *hpt_s; | |
11 | int (*getfun)(); | |
12 | long *hpt_l; | |
13 | long k, lp; | |
14 | if (fa==NULL) | |
15 | { | |
16 | err("No old pointers",0); | |
17 | return; | |
18 | } | |
19 | fread(&n, sizeof(n), 1, fa); | |
20 | fread(&iflong, sizeof(iflong), 1, fa); | |
21 | if (iflong) | |
22 | { | |
23 | hpt_l = calloc(sizeof(*hpt_l), n+1); | |
24 | n =fread(hpt_l, sizeof(*hpt_l), n, fa); | |
25 | } | |
26 | else | |
27 | { | |
28 | hpt_s = calloc(sizeof(*hpt_s), n+1); | |
29 | n =fread(hpt_s, sizeof(*hpt_s), n, fa); | |
30 | } | |
31 | if (n!= nhash) | |
32 | fprintf(stderr, "Changing hash value to old %d\n",n); | |
33 | fclose(fa); | |
34 | if (iflong) | |
35 | getfun = getl; | |
36 | else | |
37 | getfun = getw; | |
38 | for(i=0; i<n; i++) | |
39 | { | |
40 | if (iflong) | |
41 | lp = hpt_l[i]; | |
42 | else | |
43 | lp = hpt_s[i]; | |
44 | fseek(fb, lp, 0); | |
45 | while ( (k= (*getfun)(fb) ) != -1) | |
46 | fprintf(ft, "%04d %06ld\n",i,k); | |
47 | } | |
48 | fclose(fb); | |
49 | return(n); | |
50 | } |