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 <locale.h> 20 21 recopy (ft, fb, fa, nhash) 22 FILE *ft, *fb, *fa; 23 { 24 /* copy fb (old hash items/pointers) to ft (new ones) */ 25 int n, i, iflong; 26 long getl(); 27 int getw(); 28 int *hpt_s; 29 int (*getfun)(); 30 long *hpt_l; 31 long k, lp; 32 if (fa==NULL) 33 { 34 err(gettext("No old pointers"),0); 35 return; 36 } 37 fread(&n, sizeof(n), 1, fa); 38 fread(&iflong, sizeof(iflong), 1, fa); 39 if (iflong) 40 { 41 hpt_l = (long *) calloc(sizeof(*hpt_l), n+1); 42 n =fread(hpt_l, sizeof(*hpt_l), n, fa); 43 } 44 else 45 { 46 hpt_s = (int *) calloc(sizeof(*hpt_s), n+1); 47 n =fread(hpt_s, sizeof(*hpt_s), n, fa); 48 } 49 if (n!= nhash) 50 fprintf(stderr, gettext("Changing hash value to old %d\n"),n); 51 fclose(fa); 52 if (iflong) 53 getfun = (int(*)())getl; 54 else 55 getfun = getw; 56 for(i=0; i<n; i++) 57 { 58 if (iflong) 59 lp = hpt_l[i]; 60 else 61 lp = hpt_s[i]; 62 fseek(fb, lp, 0); 63 while ( (k= (*getfun)(fb) ) != -1) 64 fprintf(ft, "%04d %06ld\n",i,k); 65 } 66 fclose(fb); 67 return(n); 68 } 69