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