1*48297Sbostic /*-
2*48297Sbostic * %sccs.include.proprietary.c%
3*48297Sbostic */
4*48297Sbostic
512295Stut #ifndef lint
6*48297Sbostic static char sccsid[] = "@(#)inv5.c 4.4 (Berkeley) 04/18/91";
7*48297Sbostic #endif /* not lint */
812295Stut
912295Stut #include <stdio.h>
1012295Stut
recopy(ft,fb,fa,nhash)1112295Stut recopy (ft, fb, fa, nhash)
1212295Stut FILE *ft, *fb, *fa;
1312295Stut {
1412295Stut /* copy fb (old hash items/pointers) to ft (new ones) */
1512295Stut int n, i, iflong;
1612295Stut long getl();
1712295Stut int getw();
1812295Stut int *hpt_s;
1912295Stut long *hpt_l;
2012295Stut long k, lp;
2112295Stut if (fa==NULL)
2212295Stut {
2312295Stut err("No old pointers",0);
2412295Stut return;
2512295Stut }
2612295Stut fread(&n, sizeof(n), 1, fa);
2712295Stut fread(&iflong, sizeof(iflong), 1, fa);
2812295Stut if (iflong)
2912295Stut {
3017679Sralph hpt_l = (long *) calloc(sizeof(*hpt_l), n+1);
3112295Stut n =fread(hpt_l, sizeof(*hpt_l), n, fa);
3212295Stut }
3312295Stut else
3412295Stut {
3517679Sralph hpt_s = (int *) calloc(sizeof(*hpt_s), n+1);
3612295Stut n =fread(hpt_s, sizeof(*hpt_s), n, fa);
3712295Stut }
3812295Stut if (n!= nhash)
3912295Stut fprintf(stderr, "Changing hash value to old %d\n",n);
4012295Stut fclose(fa);
4112295Stut for(i=0; i<n; i++)
4212295Stut {
4334097Sbostic if (iflong) {
4412295Stut lp = hpt_l[i];
4534097Sbostic fseek(fb, lp, 0);
4634097Sbostic while ( (k= getl(fb) ) != -1)
4734097Sbostic fprintf(ft, "%04d %06ld\n",i,k);
4834097Sbostic } else {
4912295Stut lp = hpt_s[i];
5034097Sbostic fseek(fb, lp, 0);
5134097Sbostic while ( (k= getw(fb) ) != -1)
5234097Sbostic fprintf(ft, "%04d %06ld\n",i,k);
5334097Sbostic }
5412295Stut }
5512295Stut fclose(fb);
5612295Stut return(n);
5712295Stut }
58