root/trunk/b7.c

Revision 389, 2.0 kB (checked in by heitor.barbieri, 3 weeks ago)

essage first commit

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