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