| 1 | #include <string.h> |
|---|
| 2 | #include <stdio.h> |
|---|
| 3 | #if CIAPI |
|---|
| 4 | #include "ciapi.h" |
|---|
| 5 | #if !TLS |
|---|
| 6 | #define ciapip cib7p->ciapip |
|---|
| 7 | #else |
|---|
| 8 | DWORD extern ciapiTlsIndex; |
|---|
| 9 | #endif |
|---|
| 10 | #else /* CIAPI */ |
|---|
| 11 | #include "cisis.h" |
|---|
| 12 | #include "cirun.h" |
|---|
| 13 | #endif /* CIAPI */ |
|---|
| 14 | #include "cib70.h" |
|---|
| 15 | |
|---|
| 16 | void main(argc,argv) |
|---|
| 17 | int argc; |
|---|
| 18 | char *argv[]; |
|---|
| 19 | { |
|---|
| 20 | RECSTRU *recp; |
|---|
| 21 | char *dbnp,*p,*xb70p="xb70"; |
|---|
| 22 | LONGX mfn,irec,crec,nord,hit,maxhits=LONGX_MAX,tlirec=0L; |
|---|
| 23 | int xfd,chkhits; |
|---|
| 24 | char buffup[512]; |
|---|
| 25 | int pref; |
|---|
| 26 | int tell; |
|---|
| 27 | b7_CIB7 *cib7p=NULL; |
|---|
| 28 | |
|---|
| 29 | cib7p = b7_cib7( cib7p, 0 ); |
|---|
| 30 | |
|---|
| 31 | chkhits=1; |
|---|
| 32 | pref=1; |
|---|
| 33 | tell=1; |
|---|
| 34 | |
|---|
| 35 | if (argc < 3) { |
|---|
| 36 | printf("%s",cicopyr("?Utility B7")); |
|---|
| 37 | printf("\n"); |
|---|
| 38 | printf("b7 <dbn> <expr> [options]"); |
|---|
| 39 | printf("\n"); |
|---|
| 40 | printf("options: <pref> -> use prefix if pref != x\n"); |
|---|
| 41 | printf(" <hits> -> max hits to show \n"); |
|---|
| 42 | printf(" <x> -> b7tell \n"); |
|---|
| 43 | printf("\n"); |
|---|
| 44 | exit(1); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | if (argc > 3) pref=strcmp( argv[3], "x" ); |
|---|
| 48 | if (argc > 4) maxhits=atol(argv[4]); |
|---|
| 49 | if (argc > 5) tell=atol(argv[5]); |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | for (irec=nrecs, dbnp=argv[1], mfn=1; ; mfn++) { |
|---|
| 54 | RECORD(irec,dbnp,mfn); |
|---|
| 55 | if (RECrc == RCEOF) fatal(dbnp); |
|---|
| 56 | if (RECrc == RCNORMAL) break; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | if ((p=(UBYTE *)getenv("B7")) == NULL) p=(UBYTE *)getenv("b7"); |
|---|
| 60 | |
|---|
| 61 | if( p && pref ) |
|---|
| 62 | record(tlirec=nrecs,p,1L); |
|---|
| 63 | |
|---|
| 64 | /* |
|---|
| 65 | dbxopt_fatal=0; |
|---|
| 66 | xfd=dbxopen("",xb70p,xx1extp); |
|---|
| 67 | |
|---|
| 68 | if (xfd > 0) |
|---|
| 69 | CLOSE(xfd); |
|---|
| 70 | else |
|---|
| 71 | */ |
|---|
| 72 | recisis0(xb70p); |
|---|
| 73 | |
|---|
| 74 | RECORD(crec=nrecs,xb70p,0L); |
|---|
| 75 | RECORD(crec,xb70p,b7setno=MF0nxtmfn-1L); |
|---|
| 76 | RECORD(crec,xb70p,0L); |
|---|
| 77 | |
|---|
| 78 | p=b7_exp(cib7p,irec,dbnp,argv[2],buffup,xb70p,crec,&errno); |
|---|
| 79 | |
|---|
| 80 | if (p || errno) |
|---|
| 81 | printf("Expression syntax error %d: '%s'\n",errno,p); |
|---|
| 82 | else{ |
|---|
| 83 | p=b7_run(cib7p,irec,dbnp,buffup,sizeof(buffup), |
|---|
| 84 | tell,isisuctab,"/* */",tlirec,crec,&errno); |
|---|
| 85 | |
|---|
| 86 | printf("Hits=%"_LD_" \n",b7_hit(cib7p,irec,0L,mfn)); |
|---|
| 87 | |
|---|
| 88 | if (chkhits) |
|---|
| 89 | |
|---|
| 90 | for (hit=nord=1L; hit > 0; nord++) { |
|---|
| 91 | hit=b7_hit(cib7p,irec,nord,mfn); |
|---|
| 92 | if (nord <= maxhits && hit > 0 ) |
|---|
| 93 | printf("mfn=%"_LD_"\n",hit); |
|---|
| 94 | } |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | getchar(); |
|---|
| 98 | |
|---|
| 99 | } |
|---|