root/tags/5.52/iflind.c

Revision 4, 4.0 kB (checked in by heitor.barbieri, 2 years ago)

Versão 5.52 do cisis (28/04/2010)

Line 
1/* iflind.c - Load an inverted file from sorted link files
2*/
3#include <stdio.h>
4#include <string.h>
5#include "cisis.h"
6#include "cirun.h"
7extern int ifl_balan; /* cisis.h */
8void main(argc,argv)
9int argc;
10char *argv[];
11{
12    char *dbnp,*fillk1p,*fillk2p,*rdbnp;
13    int pstflag=IFUPISIS;
14    LONGX parmxmfn=0L;
15    char *parmxmfp=NULL;
16    char *parmlogp=NULL;
17    LONGX parmtell=0L;
18    int parmtrace=0;
19    int parmreset=0;
20    int argnext=1;
21    char *p;
22    if (argc < 4) {
23        printf("%s",cicopyr("Utility IFLIND"));
24        printf("\n");
25        printf("iflind <dbname> <file_lk1> <file_lk2> [<option> [...]] \n");
26        printf("\n");
27        printf(" <dbname>               -> output inverted file \n");
28        printf(" <file_lk1>             -> sorted %2d-byte link file\n",LE1);
29        printf(" <file_lk2>             -> sorted %2d-byte link file\n",LE2);
30        printf("\n");
31        printf("options: \n");
32        printf("\n");
33        printf(" -posts                 -> do not load .iyp \n");
34        printf(" -balan                 -> do not rebalance the dict \n");
35        printf(" maxmfn=<n>             -> max master file number \n");
36        printf(" master=<dbn>           -> master file to get maxmfn \n");
37        printf(" log=<file>             -> log file name \n");
38        printf(" tell=<n>               -> tell <n> links has been loaded \n");
39#if CIIFLFIX
40        printf(" +fix[/m]               -> read fixed length link records \n");
41#endif
42        printf(" +reset[=<dbn>]         -> reset IF update is pending \n");
43        printf(" \n");
44        exit(1);
45    }
46
47    /* get positional parms */
48    dbnp=argv[argnext++];
49    fillk1p=argv[argnext++];
50    fillk2p=argv[argnext++];
51    /* get optional parms */
52    rdbnp=dbnp;
53    for (; argnext < argc; argnext++) {
54        p=argv[argnext];
55        if (strncmp(p,"maxmfn?",7) == 0 || strncmp(p,"maxmfn=",7) == 0) {
56            if (sscanf(p+7,"%ld",&parmxmfn) != 1) fatal(p);
57            if (parmxmfn < 1) fatal(p);
58            continue;
59        }
60        if (strncmp(p,"master?",7) == 0 || strncmp(p,"master=",7) == 0) {
61            parmxmfp=p+7;
62            if (!*parmxmfp) fatal(p);
63            continue;
64        }
65        if (strncmp(p,"log?",4) == 0 || strncmp(p,"log=",4) == 0) {
66            parmlogp=p+4;
67            if (!*parmlogp) fatal(p);
68            continue;
69        }
70        if (strncmp(p,"tell?",5) == 0 || strncmp(p,"tell=",5) == 0) {
71            if (sscanf(p+5,"%ld",&parmtell) != 1) fatal(p);
72            if (parmtell < 0) fatal(p);
73            continue;
74        }
75        if (strcmp(p,"-balan") == 0) {
76            ifl_balan=0;
77            continue;
78        }
79        if (strcmp(p,"-posts") == 0) {
80            pstflag=IFUPDICT;
81            continue;
82        }
83#if CIIFLFIX
84        if (strcmp(p,"+fix") == 0) {
85            ciiflfix=1;
86            continue;
87        }
88        if (strcmp(p,"+fix/m") == 0) {
89            ciiflfix=ciiflfim=1;
90            continue;
91        }
92#endif
93        if (strcmp(p,"+reset") == 0) {
94            parmreset=1;
95            continue;
96        }
97        if (strncmp(p,"+reset?",7) == 0 || strncmp(p,"+reset=",7) == 0) {
98            rdbnp=p+7;
99            if (!*rdbnp) fatal(p);
100            continue;
101        }
102        if (strcmp(p,"trace") == 0) {
103            parmtrace=1;
104            dbxtrace=1; trmtrace=1;
105            continue;
106        }
107        fatal(p);
108    }
109    /* get maxmfn */
110    if (!parmxmfn) {
111        if (!parmxmfp) parmxmfp=dbnp;
112        parmxmfn=VMF0nxtmfn(record(nrecs,parmxmfp,0L))-1;
113        dbxflush(parmxmfp);
114    }
115   
116    /* should pause */
117    if (parmtrace || parmtell) {
118        printf("+++ create=%s \n",dbnp);
119        printf("+++ maxmfn=%ld\n",parmxmfn);
120    }
121    if (parmtrace) printf("+++ coreleft=%ld\n",CORELEFT());
122    /* initialize IF and load link files */
123    svdiflind (dbnp, fillk1p ,fillk2p, parmxmfn, parmlogp, pstflag, parmtell);
124    if (parmtrace) printf("+++ coreleft=%ld\n",CORELEFT());
125    dbxflush(dbnp);
126    if (parmtrace) printf("+++ coreleft=%ld\n",CORELEFT());
127    if (parmreset) {
128        recreset(rdbnp,1L,MAXUPDMFN,0L,parmtell);
129    }
130    exit(0);
131}
Note: See TracBrowser for help on using the browser.