2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
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.
15 #pragma ident "%Z%%M% %I% %E% SMI"
24 newkeys(FILE *outf
, FILE *inf
, FILE *recf
, int nhash
, FILE *fd
, int *iflong
)
27 * reads key lines from inf; hashes and writes on outf;
28 * writes orig key on recf, records pointer on outf too.
29 * format of outf is : hash code space record pointer
36 char key
[30], bkeys
[40];
39 int i
, nk
, ndoc
= 0, more
= 0, c
;
42 while (fgets(line
, LINESIZ
, inf
)) {
44 while (*p
!= '\t') p
++;
48 sprintf(bkeys
, ";%ld", ld
);
52 sprintf(bkeys
, ",%d", ll
);
66 assert(fd
== 0 || more
== 0);
67 nk
= getargs(p
, keyv
);
70 for (i
= 0; i
< nk
; i
++)
71 fprintf(outf
, "%04d %06ld\n", hash(keyv
[i
])%nhash
, lp
);
73 for (i
= 0; i
< nk
; i
++)
74 printf("key %s hash %d\n",
75 keyv
[i
], hash(keyv
[i
])%nhash
);
77 if (more
) { /* allow more than LINESIZ keys */
78 strcpy(key
, keyv
[nk
]);
79 for (s
= key
; *s
; s
++)
81 while ((c
= getc(inf
)) != '\n') {
88 fprintf(outf
, "%04d %06ld\n",
93 lp
+= (strlen(line
)+lt
+1);
96 *iflong
= (lp
>= 65536L);
97 if (sizeof (int) > 2) *iflong
= 1; /* force long on VAX */
108 if (*p
== '\n') *p
= 0;