-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchkterm.c
More file actions
81 lines (70 loc) · 2.14 KB
/
chkterm.c
File metadata and controls
81 lines (70 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdio.h>
#include <string.h>
#include "cisis.h" /* CISIS Interface */
#include "cirun.h" /* runtime area and defines by AOT */
void main(argc,argv)
int argc;
char *argv[];
{
TRMSTRU *trmp; /* mandatory for defines TRM, TDB */
LONGX itrm; /* term "shelf" index */
char *dbnp;
UBYTE key[LE2+1],*keyp,*p;
char line[BUFSIZ];
int argnext=1;
int found=0;
LONGX mfn=0L;
#if BEFORE20010814
if (argc < 3) fatal("chkterm <dbn> <key> [mfn] \n");
#endif
if (argc < 3) {
printf("%s",cicopyr("Utility CHKTERM"));
printf("\n");
printf("chkterm <dbn> <key> [<mfn>] \n");
printf("\n");
printf("check term <key> in <dbn> \n");
printf("if <key> is absent in inverted file <dbn> then display \n");
printf("*** dbn: <dbn> \n");
printf("*** key: <key> \n");
printf("and exit 1 \n");
printf("\n");
printf("if <key> has no postings for record <mfn> then display \n");
printf("*** dbn: <dbn> \n");
printf("*** key: <key> \n");
printf("*** mfn: <mfn> \n");
printf("and exit 2 \n");
printf("\n");
printf("otherwise produce no output and exit 0 \n");
printf("\n");
exit(1);
}
dbnp=argv[argnext++];
keyp=argv[argnext++];
if (strlen(keyp) > LE2) fatal(keyp);
if (argnext < argc) {
p=argv[argnext++];
if (sscanf(p,"%"_LD_,&mfn) != 1) fatal(p);
if (mfn < 1) fatal(p);
}
for (p=key; *keyp; p++, keyp++) *p = isisuctab[*keyp];
*p='\0';
TERM(itrm=ntrms,dbnp,key); p=line;
if (TRMrc != RCNORMAL) {
sprintf(p,"*** dbn: %s\n",dbnp); p+=strlen(p);
sprintf(p,"*** key: %s\n",key);
printf("%s",line);
exit(1);
}
if (mfn) {
while (posting(itrm,TRMpost+1) > 0)
if (TRMpmfn == mfn) { found=1; break; }
if (!found) {
sprintf(p,"*** dbn: %s\n",dbnp); p+=strlen(p);
sprintf(p,"*** key: %s\n",key); p+=strlen(p);
sprintf(p,"*** mfn: %6"_LD_"\n",mfn);
printf("%s",line);
exit(2);
}
}
exit(0);
}