root/trunk/mxaot.c

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

essage first commit

Line 
1/* ------------------------------ mxaot.c ---------------------------------- */
2
3#include <stdio.h>
4#include <ctype.h>
5#include <string.h>
6
7#if CIAPI
8#include "ciapi.h"
9#else /* CIAPI */
10#include "cisis.h"                  /* CISIS Interface header file */
11#endif /* CIAPI */
12
13#include "mx.h"                     /* MX Program header file */
14
15#define DIR_FILE 1                  /* list=directory */
16#if DIR_FILE
17#include <sys/types.h>
18#include <dirent.h>
19#endif
20
21#define XML_FILE 1                  /* xml=file,tag */
22#if XML_FILE
23    char tagName[64];
24
25    char * findTag(char     *in,       /* input string */
26                   char     *tagName,  /* tag name */
27                   int      *type,     /* -1-unknown 0-open 1-close 2-openclose */
28                   unsigned *len) {    /* tag length including < and > */
29
30        char *initPos = NULL;
31        char *curPos = in;
32        int tagLen;
33
34        *type = -1; /* unknown */
35        *len = 0;
36
37        if (tagName != NULL) {
38            tagLen = strlen(tagName);
39            while (curPos != NULL) {
40                curPos = strchr(curPos, '<');
41                if (curPos != NULL) {
42                    initPos = curPos;
43                    curPos++;
44                    if (*curPos == '/') {
45                        *type = 1; /* close */
46                        curPos++;
47                    }
48                    if (strncmp(curPos, tagName, tagLen) == 0) {
49                        curPos += tagLen;
50                        if ((*curPos == ' ') || (*curPos == '/') || (*curPos == '>')) {
51                            while ((*curPos != '\0') && (*curPos == ' ')) {
52                                curPos++;
53                            }
54                            while ((*curPos != '\0') && (*curPos != '/') && (*curPos != '>')) {
55                                curPos++;
56                            }
57                            if (*curPos == '/') {
58                                *type = 2; /* openclose */
59                                curPos++;
60                            }
61                            if (*curPos == '>') {
62                                if (*type == -1) {
63                                    *type = 0; /* open */
64                                }
65                                break;
66                            }
67                        }
68                    }
69                    initPos = NULL;
70                    *type = -1;
71                }
72            }
73            if (curPos != NULL) {
74                 *len = curPos - initPos + 1;
75            }
76        }
77
78        return initPos;
79    }
80
81int recfgetxml(char *xmlfile, char *ibuf, unsigned ibufsiz, char *obuf, unsigned obufsiz, char *ubuf, unsigned ubufsiz, int *fdp, unsigned *n1p, char **iptrp, LONGX *countp);
82
83int recfgetxml(char *xmlfile, char *ibuf, unsigned ibufsiz, char *obuf, unsigned obufsiz, char *ubuf, unsigned ubufsiz, int *fdp, unsigned *n1p, char **iptrp, LONGX *countp)
84{
85    int fd=fdp[0];
86    unsigned n1=n1p[0];
87    char *iptr=iptrp[0];
88    LONGX count=countp[0];
89    char *batchp = ubuf;
90    unsigned ubu=ubufsiz-20;
91    unsigned j=0;  /* indice em obuf */
92    int eol=0;
93    int rc=0;
94    int insideTag = 0;
95    int newInstance = 0;
96    int closeFound = 0;
97    int type;
98#if PC
99    int nlSize = 2;
100#else
101    int nlSize = 1;
102#endif
103
104    *ubuf='\0';                                            // null update comand
105
106    if (!iptr) {                                           // close/open file
107        if (fd) CLOSE(fd);
108        dbxopt_fatal=0; fd=dbxopen(NULL,xmlfile,NULL);
109        if (fd < 0) return(fd);
110        n1=0; iptr=""; //force read
111        rc=fd;
112    }
113
114    /* read lines
115    */
116    if (obufsiz) {
117        while (1) {
118            char *jptr;
119            unsigned jn=0;
120            if (n1 == 0) {                                 // le buffer
121                n1=read(fd,ibuf,ibufsiz-1);
122                if (n1 <= 0) {  // if (j) ;
123                    rc=EOF; break;                         // EOF
124                }
125                ibuf[n1]='\0';
126                iptr=ibuf;
127            }
128            jptr=iptr;
129#if PC
130            while (n1 && *iptr != '\r') { jn++; iptr++; n1--; }
131            if (*iptr == '\r') { iptr++; n1--; }
132#else
133            while (n1 && *iptr != '\n') { jn++; iptr++; n1--; }
134#endif
135            if (*iptr == '\n') { iptr++; n1--; eol=1; }
136            if (jn) {
137                if (j+jn >= obufsiz) jn=(obufsiz-1)-j;
138                memcpy(obuf+j,jptr,jn); j+=jn;
139            }
140            if (eol) {
141                char *p,*p0;
142                unsigned len,bk;
143                count++;
144
145                obuf[j]='\0';
146                p0=p=obuf;
147                p = findTag(p, tagName, &type, &len);
148                if (insideTag) {
149                    if (p == NULL) {
150                        len = strlen(p0);
151                    } else {
152                        if (type != 1) { /* close */
153                            fatal("nested tag not supported");
154                        }
155                        p += len;
156                        insideTag = 0;
157                        closeFound = 1;
158                        len = p - p0;
159                        if (*p != '\0') {
160                            bk = (unsigned)((obuf + j) - p + nlSize);
161                              if (bk > nlSize) {
162                                iptr -= bk;
163                                n1 += bk;
164                            }
165                        }
166                    }
167                } else {
168                    if (p == NULL) {
169                        len = 0;
170                    } else {
171                        if (type == 0) { /* open */
172                            p0 = p;
173                            p += len;
174                            insideTag = 1;
175                            newInstance = 1;
176
177                            p = findTag(p, tagName, &type, &len);
178                            if (p == NULL) {
179                                len = strlen(p0);
180                            } else {
181                                if (type != 1) { /* close */
182                                    fatal("nested tag not supported");
183                                }
184                                p += len;
185                                insideTag = 0;
186                                closeFound = 1;
187                                len = p - p0;
188                                if (*p != '\0') {
189                                    bk = (unsigned)((obuf + j) - p + nlSize);
190                                    if (bk > nlSize) {
191                                        iptr -= bk;
192                                        n1 += bk;
193                                    }
194                                }
195                            }
196                        } else if (type == 2) { /* openclose */
197                            p0 = p;
198                            p += len;
199                            insideTag = 0;
200                            newInstance = 1;
201                            closeFound = 1;
202                            if (*p != '\0') {
203                                bk = (unsigned)((obuf + j) - p + nlSize);
204                                if (bk > nlSize) {
205                                    iptr -= bk;
206                                    n1 += bk;
207                                }
208                            }
209                        } else {
210                            fatal("invalid tag");
211                        }
212                    }
213                }
214                if (len) {
215                    if (newInstance) {
216                        if (ubu <= 7) fatal("ubu <= 7");
217                        sprintf(batchp,"d1<1 0>"); batchp+=7;
218                        ubu-=7;
219                        newInstance = 0;
220                    }
221
222                    if (len >= ubu) fatal("len >= ubu");
223                    memcpy(batchp,p0,len); batchp+=len;
224                    ubu-=len;
225
226                    if (closeFound) {
227                        if (ubu <= 4) fatal("ubu <= 4");
228                        sprintf(batchp,"</1>");
229                        batchp+=4;
230                        ubu-=4;
231                    } else {
232#if PC
233                        if (ubu < 1) fatal("ubu < 1");
234                        sprintf(batchp,"\r"); batchp+=1;
235                        ubu-=1;
236#endif
237                        if (ubu < 1) fatal("ubu < 1");
238                        sprintf(batchp,"\n"); batchp+=1;
239                        ubu-=1;
240                    }
241                } else if (insideTag) {
242#if PC
243                    if (ubu < 1) fatal("ubu < 1");
244                    sprintf(batchp,"\r"); batchp+=1;
245                    ubu-=1;
246#endif
247                    if (ubu < 1) fatal("ubu < 1");
248                    sprintf(batchp,"\n"); batchp+=1;
249                    ubu-=1;
250                }
251                if (closeFound) {
252                    rc=1; break;
253                } else {
254                    j=0;
255                }
256            } //end if eol
257        } // end while
258    } // end if obufsiz
259
260    /* save
261    */
262    fdp[0]=fd;
263    n1p[0]=n1;
264    iptrp[0]=iptr;
265    countp[0]=count;
266
267    return rc;
268}
269#endif /* XML_FILE */
270
271/* ------------------------------ fxl0.c ---------------------------------- */
272//int read(int handle, void *buf, unsigned len);
273//The maximum number of bytes that read can read is UINT_MAX -1, because UINT_MAX is the same as -1, the error return indicator.
274//On successful completion, read returns an integer indicating the number of bytes placed in the buffer.
275//On end-of-file, read returns 0. On error, read returns -1 and sets the global variable errno to one of the following values:
276
277int recfgetseq(char *seqfile, char c, int parmseqlog, char *ibuf, unsigned ibufsiz, char *obuf, unsigned obufsiz, char *ubuf, unsigned ubufsiz, int *fdp, unsigned *n1p, char **iptrp, LONGX *countp);
278
279int recfgetseq(char *seqfile, char c, int parmseqlog, char *ibuf, unsigned ibufsiz, char *obuf, unsigned obufsiz, char *ubuf, unsigned ubufsiz, int *fdp, unsigned *n1p, char **iptrp, LONGX *countp)
280{
281    int fd=fdp[0];
282    unsigned n1=n1p[0];
283    char *iptr=iptrp[0];
284    LONGX count=countp[0];
285
286    unsigned j=0;  /* indice em obuf */
287    int eol=0;
288    int rc=0;
289
290    if (!c) c='|';                                         // default dlm
291    *ubuf='\0';                                            // null update comand
292
293    if (!iptr) {                                           // close/open file
294        if (fd) CLOSE(fd);
295        dbxopt_fatal=0; fd=dbxopen(NULL,seqfile,NULL);
296        if (fd < 0) return(fd);
297        n1=0; iptr=""; //force read
298        rc=fd;
299    }
300
301    /* read lines
302    */
303    if (obufsiz) {
304        while (n1 >= 0) {
305            char *jptr;
306            unsigned jn=0;
307            if (n1 == 0) {                                 // le buffer
308                n1=read(fd,ibuf,ibufsiz-1);
309                if (n1 <= 0) {  // if (j) ;
310                    rc=EOF; break;                         // EOF
311                }
312                ibuf[n1]='\0';
313                iptr=ibuf;
314            }
315            jptr=iptr;
316    #if PC
317            while (n1 && *iptr != '\r') { jn++; iptr++; n1--; }
318            if (*iptr == '\r') { iptr++; n1--; }
319    #else
320            while (n1 && *iptr != '\n') { jn++; iptr++; n1--; }
321    #endif
322            if (*iptr == '\n') { iptr++; n1--; eol=1; }
323            if (jn) {
324                if (j+jn >= obufsiz) jn=(obufsiz-1)-j;
325                memcpy(obuf+j,jptr,jn); j+=jn;
326            }
327            if (eol) {
328                int tag=1;
329                char *p,*p0,*batchp;
330                unsigned len,u,ubu=ubufsiz-20;
331                count++;
332                obuf[j]=c; obuf[j+1]='\0';
333                for (batchp=ubuf, p=obuf; *p; p++, tag++) {
334                    p0=p; p=strchr(p0,c); if (p) *p='\0'; len=strlen(p0);
335                    if (len) {
336                        if (len >= ubu) len=0;
337                        sprintf(batchp,"H%d %d ",tag,len); batchp+=(u=strlen(batchp));
338                        memcpy(batchp,p0,len+1); batchp+=len;
339                        ubu-=(u+len);
340                    }
341                }
342                rc=1; break;
343            } //end if eol
344        } // end while
345    } // end if obufsiz
346
347    /* save
348    */
349    fdp[0]=fd;
350    n1p[0]=n1;
351    iptrp[0]=iptr;
352    countp[0]=count;
353
354    return rc;
355
356    //if (j != 0) erro("ultimo registro nao tem LF em ",seqfile);
357    //exit(0);
358}
359
360#if 0
361erro(s1,s2)     /* imprime mensagem de erro e morre */
362char *s1,*s2;
363{
364    fprintf(stderr,
365        "mx: %s%s\n",s1,s2);
366    breakout();
367    exit(1);
368}
369
370writbsiz()                                                          /*
371---------                                                           */
372{
373    int n2;
374    unsigned char *p,*q;
375    int loop;
376
377    if (n2free >= obufsize) {
378        memcpy(bufout+i2free,obuf,obufsize);
379        n2free-=obufsize;
380        i2free+=obufsize;
381    }
382    else {
383        memcpy(bufout+i2free+,obuf,n2free);
384        n2=write(f2,bufout,MBUFSIZ);
385        if (n2 < MBUFSIZ) erro("writbsiz - ","erro na gravacao");
386        i2free=obufsize-n2free;
387        memcpy(bufout,obuf+n2free,i2free);
388        n2free=MBUFSIZ-i2free;
389    }
390}
391
392breakout()                                                      /*
393---------                                                       */
394{
395    int n2;
396    if (i2free) if (f2) {
397        n2=write(f2,bufout,i2free);
398        if (n2 < i2free) {
399            fprintf(stderr,"breakout - erro na gravacao\n");
400        exit(1);
401    }
402    }
403}
404
405                                                                /*
406---------                                                       */
407#endif //0
408
409
410
411
412
413void mxsyntax(char *x, unsigned xibufsiz, LONGX xptabcategories, int xptabwidth);
414void mxsyntax(x, xibufsiz, xptabcategories, xptabwidth)
415char *x;
416unsigned xibufsiz;
417LONGX xptabcategories;
418int xptabwidth;
419{
420        printf("%s",cicopyr("Utility MX"));
421        printf("\n");
422        printf("mx ");
423#if CIPAR
424        printf("[cipar=<file>] ");
425#endif
426        printf("[{");
427#if OPEN30
428        printf("files|");
429#endif
430#if BEFORE20060120
431        printf("mfrl|fmtl|load}=<n>] [cgi={mx|<v2000_fmt>}] \n");
432#else
433        printf("mfrl|load}=<n>] [cgi={mx|<v2000_fmt>}] [in=<file>] \n");
434#endif
435        printf(" %s{[db=]<db>| \n",x);
436/*
437        printf(" %s seq[/blk:%"_LD_"/fi:<x>]=<file>| \n",x,(LONGX)xibufsiz);
438*/
439        printf(" %s seq[/%"_LD_"m]=<file>[<fldDelim>]| \n",x,(LONGX)xibufsiz);
440#if DIR_FILE
441        printf(" %s list={./|<dir>}| \n",x);
442#endif
443#if XML_FILE
444        printf(" %s xml[/%"_LD_"m]=<file>,<element>| \n",x,(LONGX)xibufsiz);
445#endif
446        printf(" %s iso[={marc|<n>}]=<isofile> [isotag1=<tag>]| \n",x);
447        printf(" %s dict=<if>[,<keytag>[,<posttag>[/<postsperrec>]]] [k{1|2}=<key>]} \n",x);
448        printf(" \n");
449        printf("options: \n");
450        printf(" %sfrom|to|loop|count|tell|btell=<n> \n",x);
451        printf(" %stext[/show]=<text> \n",x);
452        printf(" %s[bool=]{<bool_expr>|@<file>}  ",x);
453#if INVXBOOL
454        printf("[invx=<tag%d_mf>] ",MFQTXTAG);
455#endif
456#if CIB71
457        printf("[tmpx=<tmp_mf>] ");
458#else /* CIB71 */
459#if LIND || CIB64
460        printf("[tmpx=<tmp_mf>] ");
461#else
462        printf("[tmpx=<tmp_mf>] ");
463#endif
464#endif /* CIB71 */
465        printf(" \n");
466        printf(" \n");
467#if RECXPND
468        printf(" %sgetdir=<tag>,<dlm> \n",x);
469#endif
470#if RECGIZM
471        printf(" %sgizmo=<gizmo_mf>[,<taglist>]  ",x);
472#if MXGIZP
473        printf("[gizp[/h]=<out_mfx>] ");
474#endif
475#if RECDECO
476        printf("[decod=<mf>]");
477#endif
478#else /* RECGIZM */
479#if RECDECO
480        printf(" decod=<mf>");
481#endif
482#endif /* RECGIZM */
483        printf(" \n");
484        printf(" \n");
485        printf(" %sjoin=<mf>[:<offset>][,<taglist>]=<mfn=_fmt>\n",x);
486        printf(" %sjoin=<db>[:<offset>][,<taglist>]=<upkey_fmt>",x);
487        printf(" [jmax=<n>]\n");
488        printf(" %sjchk=<if>[+<stwfile>]=<upkey_fmt>",x);
489        printf(" \n");
490#if SHOWJDICMD || 1
491        printf(" %sjdi[/<options>]=<db>=<jdi_fmt>\n",x);
492        printf(" %s    /lines:1000/width:60\n",x);
493        printf(" %s    /tab:2/occ:50\n",x);
494        printf(" %s    /tab:2\n",x);
495        printf(" %s    /wmin:0.05/vmin:0.05/nmin:2\n",x);
496        printf(" %s    /sort:{w|v|n}{1|2|3|4}\n",x);
497        printf(" %s    /top:10\n",x);
498        printf(" %s    /55\n",x);
499        printf(" %s    /show\n",x);
500        printf(" \n");
501#endif
502        printf(" %sproc=[<proc_fmt>|@<file>] \n",x);
503/*
504        case 'X': ok
505        case 'F':
506        case 'Z':
507        case 'Y':
508        case 'T':
509        case 'C':
510*/
511        printf(" \n");
512        printf(" %s      D{<tag>[/<occ>]|*} \n",x);
513        printf(" %s      A<tag><delim><data><delim> \n",x);
514        printf(" %s      H<tag> <length> <data> \n",x);
515        printf(" %s      <TAG[ <stripmarklen>[ <minlen>]]><data></TAG> \n",x);
516        printf(" \n");
517        printf(" %s      S[<tag>] \n",x);
518        printf(" %s      R<mf>,<mfn> \n",x);
519        printf(" %s      G<gizmo_mf>[,<taglist>] \n",x);
520        printf(" %s      Gsplit[/clean]=<tag>[={<char>|words|letters|numbers|trigrams}] \n",x);
521//        printf(" %s      Gsplit[/clean]=<tag>[={<char>|words|letters|numbers}] \n",x);
522//        printf(" %s      Gsplit=<tag> \n",x);
523//        printf(" %s      Gsplit=<tag>={trigrams|wtrig} \n",x);
524        printf(" %s      Gsplit=<tag>=6words[/if=<if>] \n",x);
525#if GCC
526        printf(" %s      Gload[/<tag>][/nonl][/xml][/socket][/head][={<url>|<file>|dir=<dir>}]\n",x);
527#else
528        printf(" %s      Gload[/<tag>][/nonl][=<file>] \n",x);
529#endif
530        printf(" %s      Gmark[/<tag>]{/<elem>|/keys|/decs|/<mf>,<otag>[,<ctag>]}=<if> \n",x);
531        printf(" %s      Gmarx[/<tag>]/<elem>[@<att>=\"x\"] =<tag>[:&[<att>]|/c[=224]|/i]\n",x);
532        printf(" %s      Gdump[/<tag>][/nonl][/xml][=<file>] \n",x);
533#if PROCXSLT
534        printf(" %s      Gxsl[#<rec_mode>][/<tag>|:<file>]=[[@]<xsl_spec>] \n",x);
535#endif /* PROCXSLT */
536        printf(" %s      =<mfn> \n",x);
537        printf(" %s      X[append=]<mf> \n",x);
538/*
539        printf(" %s      Gport[/<tag>][=<port>] \n",x);
540        printf(" %s      Gdump[/<tag>][/x]{/socket=<url>|=<file>} \n",x);
541*/
542        printf(" \n");
543#if MXFST
544        printf(" %sconvert=ansi [uctab={<file>|ansi}]         [actab={<file>|ansi}] \n",x);
545        printf(" %sfst[/h]={<fst>|@[<file>]}                  [stw=@[<file>]] \n",x);
546#endif
547#if RECXPND
548        printf(" %sputdir=<tag>,<dlm> \n",x);
549#endif
550        printf(" \n");
551        printf(" %s",x);
552#if MULTI
553        printf("[mono|mast|full] ");
554#endif
555        printf("{create|copy|append|merge|updatf}=<out_mf> \n");
556        printf(" %s[out]iso[={marc|<n>}]=<out_isofile>        [outisotag1=<tag>] \n",x);
557#if LIND
558#if MXFULLINV
559        printf(" %sfullinv[/dict][/keep][/ansi]=<out_if>      [maxmfn=<n>|master=<mf>] \n",x);
560#endif
561#else /* LIND */
562#if BEFORE20060711
563#if MXIFUPD
564#if MXFULLINV
565        printf(" %s{ifupd[/create][/dict]|fullinv[/dict][/m][/ansi]}=<out_if> [-reset] \n",x);
566#else
567        printf(" %sifupd[/create][/dict]=<out_if> \n",x);
568#endif
569#endif //BEFORE20060711
570#else /* MXIFUPD */
571#if MXFULLINV
572        printf(" %sfullinv[/dict][/m][/ansi]=<out_if> [-reset] \n",x);
573#endif
574#endif /* MXIFUPD */
575#endif /* LIND */
576        printf(" %sln{1|2}=<out_file>                         [+fix[/m]] \n",x);
577        printf(" %sfix=<out_file> tbin=<tag> \n",x);
578#if SHOWTABCMD || 1
579        printf(" %stab[/lines:%"_LD_"/width:%"_LD_"/tab:<tag>]=<tab_fmt> \n",x,(LONGX)xptabcategories,(LONGX)xptabwidth);
580#endif
581        printf(" %sprolog|pft|epilog={<diplay_fmt>|@<file>}   [lw={<n>|0}] [pftout=<file>]\n",x);
582        printf(" \n");
583        printf(" %s{+|-}control|leader|xref|dir|fields|all    [now] [mfrl] \n",x);
584        printf(" \n");
585}
586
587
588#if MXFUN
589int cisis_mx(stringp)
590char *stringp;
591{
592#define MAXARGS1 512
593    int argc=0;
594    char *argv[MAXARGS1+1];
595    char *p,*q,c1,c2;
596    int strip;
597    int rc;
598    for (argv[argc++]="mx", p=stringp; *p; ) {
599        while (isspace(*p)) p++;
600        c1='\r'; c2='\n'; if (*p == '"') { p++; c1=c2='"'; }
601        argv[argc++]=p;
602        for (strip=0, q=p; *p; ) {
603            if (*p == c1) { *p++='\0'; if (*p == c2) p++; break; }
604            if (*p == c2) { *p++='\0'; if (*p == c1) p++; break; }
605            /* if (*p == '\\') p++; dbn... */
606            if (*p) { *q++ = *p++; strip++; }
607        }
608#if BEFORE401R2 /* because (still) need keep trailing space in "seq=x " */
609        if (c1 != '"') while (strip--) if (isspace(*(q-1))) q--; else break;
610#endif
611        *q='\0';
612    }
613    argv[argc]=NULL;
614    rc=mxexec(argc,argv);
615    return(rc);
616}
617#endif /* MXFUN */
618
619
620#if MXFUN
621#define FATLOCK {                           \
622        fprintf(stderr,                     \
623        "*** record %s#%"_LD_" is been update by another user!\n",  \
624        VRDBname(upcrec),MFRmfn);               \
625        mxexit(xmxp,1); /* DELOCK/EWLOCK */             \
626       return(1);                                     \
627    }
628#else /* MXFUN */
629#define FATLOCK {                           \
630        fprintf(stderr,                     \
631        "*** record %s#%"_LD_" is been update by another user!\n",  \
632        VRDBname(upcrec),MFRmfn);               \
633        mxexit(xmxp,1); /* DELOCK/EWLOCK */             \
634    }
635#endif /* MXFUN */
636
637#if MXFUN
638#define MXEXIT(rc) { mxexit(xmxp,rc); /* DELOCK/EWLOCK */ return(rc); }
639#else /* MXFUN */
640#define MXEXIT(rc)   mxexit(xmxp,rc); /* DELOCK/EWLOCK */
641#endif /* MXFUN */
642
643#if BEFORE20000323           /* because some BRM's GCC - ask rpiva */
644extern FILE *cistderr;  /* 20/05/98 (Asael!) */
645#else
646#define cistderr stderr
647#endif
648
649/* function mxexec(argc,argv) derived from the original mx.c source code
650
651   - declares xmxp and mxinit it
652   - uses xmxp as 1st parm of call all mx functions
653   - #if MXFUN then uses MXFUN_XMX struct and mxrun.h #defines
654
655   AOT, 21/02/2001
656*/
657
658int mxexec(argc,argv_1)
659int argc;
660char *argv_1[];
661
662{
663#if CIAPI
664#if !MXFUN
665    void *ciapip = NULL;
666#endif /* !MXFUN */
667#endif /* CIAPI */
668
669    void *xmxp; /* mandatory for #defines in mxrun.h (#if !MXFUN) */
670
671    RECSTRU *recp; /* mandatory for defines REC RDB MF0 MFR DIR, FIELDP */
672
673
674    //char *seqfile;     // seq= using recfgetseq()
675    int parmseqlog=0;    // recfgetseq
676    char *ibuf;          // input buffer
677    unsigned ibufsiz=1*1024*1024;    // dedicated 1Mbyte-buffer
678    char *obuf;          // line buffer
679    unsigned obufsiz;
680    char *ubuf;          // fldupdat buffer
681    unsigned ubufsiz;
682    int n1fdseq=0;       // file descriptor
683    int n1fdxml=0;       // file descriptor
684    unsigned n1left=0;   // bytes left
685    char *n1iptr=NULL;   // next char
686    LONGX n1count=0;      // lines read
687
688    int parmtabtg=0;     // parmtabula
689
690#define TB        1
691#define TBISNEW   0
692
693#if TB
694    int ntagbin=0;
695    UWORD vtagbin[MAXTBIN];
696    UWORD tagbin;
697    int itagbin;
698    int fdtagbin;
699#endif /* TB */
700
701    char *dbnp=NULL;
702    LONGX crec,irec,mfn;
703
704    char *p,*q,parmxseq,*isxp=NULL;
705    int i,n,xfd;
706    int level,jchk;
707    int isfix,lrfix,isfox,lrfox;
708    unsigned int parmisildrtag=0;
709    unsigned int parmisoldrtag=0;
710
711#define MXCOMMENT 1
712#if MXCOMMENT
713    int incomment=0;
714#endif
715
716    int argnext=1;
717    LONGX nbytes,maxmfrl=MAXMFRL;
718    char *parmtextp=NULL;
719    char *parmsysp=NULL;
720    char *parmsysa=NULL;
721    int parmsyss=0;
722    char *shp;
723
724    UWORD utag;
725    int xdir;
726    UCHR *batchp;
727
728    int parmcontrol=0,parmleader=0,parmxref=0,parmdir=0,parmfields=1;
729    LONGX parmfrom=0,parmto=0,parmloop=1,parmcount=LONGX_MAX,count=0;
730    LONGX countdict1002=LONGX_MAX;
731    int parmwait=1;
732    int parmhits=0;
733    LONGX /*UWORD*/ parmmfrl=0;
734    int minus1=0,plus1=0;
735    LONGX ld;
736
737#if INVXBOOL
738    int loop;
739    LONGX irecx;
740#endif
741
742#if RECGIZM
743    VGIZPSTRU *gizmap;
744#endif
745
746#if MXIFUPD
747    int ifcreate=0;
748    DBXSTRU *ifndbxp;
749#endif
750
751#if MXIFUPD || MXFULLINV
752    char *parmmaster=NULL;
753    int parmmenosreset=0;
754#endif
755
756#if MXFST
757    int parmfstup=1;
758    LONGX qtylk1,qtylk2;
759#endif
760
761#if IFUPDATE
762    LONGX brec=0L;
763    int parmmfbw=0;
764#endif
765
766    char *mi_gidbnp=NULL;               /* dbn.par */
767
768    int parmoutmfntag=0;                /* multiple output records, accorging pft= */
769
770    char *parmkdbnp=NULL;
771    char *parmk1p=NULL;
772    char *parmk2p=NULL;
773    char  parmk2a[LE2+1];
774    UWORD parmktag1=1;
775    UWORD parmktag2=2;
776    int parmkpostings=0;
777    LONGX parmkkeep2=LONGX_MAX;
778    LONGX parmkcount=0L;
779    int xgo;
780
781/* iso=mark= */
782    int ismarc=0;
783    unsigned char parmisoxfs=ISOXFS;
784    unsigned char parmisoxgs=ISOXGS;
785
786/* convert= */
787    unsigned char *tabconvp=NULL;
788
789    LONGX itrm;
790    LONGX itrm2;
791    TRMSTRU *trmp=NULL;
792    TRMSTRU *trmp1=NULL;
793    TRMSTRU *trmp2=NULL;
794    int xti;
795    char *xtp;
796    LONGX xtl1,xtl2;
797
798//AOT, 09/12/2008
799/* tab/ jdi:<tempesos_db>= */
800#define JDISORTW1 1
801#define JDISORTW2 2
802#define JDISORTW3 3
803#define JDISORTW4 4
804#define JDISORTV1 5
805#define JDISORTV2 6
806#define JDISORTV3 7
807#define JDISORTV4 8
808#define JDISORTN1 7
809#define JDISORTN2 8
810#define JDISORTN3 9
811#define JDISORTN4 10
812
813    char    *parmtabjdip=NULL;
814    LONGX     jdiclass=1000;   /*xptabcategories/3;*/
815    int      jdiwidth=LE2;    /*xptabwidth;*/ 
816    LONGX     jditabtg=2;
817    LONGX     jditaboc=50;
818    int      jdisort=JDISORTW1;
819    int      jdisstop=10;
820    int      jdipshow=0;
821    int      jdiadd55=55;
822    int      jdiaddfm=2;
823    float    jdisminw=0.05;
824    float    jdisminv=0.05;
825    LONGX     jdisminn=2;
826
827    char    *jditable=NULL;
828    LONGX    jdicategories;
829    LONGX    jdimaxprim;
830
831    float    jditotalw=0.0;
832    float    jditotalv=0.0;
833    LONGX     jditotaln=0;
834    LONGX     jdintabs=0;
835    LONGX     jditotal1=0;
836    float   *jdiSUM0w=NULL;  /* n(t) */
837    float   *jdiSUM0v=NULL;  /* n(t) */
838    LONGX    *jdiSUM0n=NULL;  /* n(t) */
839    LONGX    *jdiFREQ1=NULL;  /* n(t) */
840
841    char    *jdiSBUF=NULL;   /* sort keys area */
842    LONGX    *jdiSBUH=NULL;   /* sort hidx area */
843    char    *jdiSBUFx=NULL;  /* sort tmp key  */
844    int      jdislen=0;   /* 9+jdiwidth+1  */
845
846    RECSTRU *jdirecp=NULL;
847    TRMSTRU *jditrmp=NULL;
848#if CICPP
849#else /* CICPP */
850    LONGX     jdirec_prat=(-1L);
851    LONGX     jditrm_prat=(-1L);
852#endif /* CICPP */
853
854    FMT_CODE *jdipgmp=NULL;
855    char     *jdifmtarea=NULL;
856    LONGX     jdifmtlw=0;
857    LONGX     jdifmtasize=MAXMFRL;
858
859
860    /* ............................................... directory listing */
861#if DIR_FILE
862    DIR *direntdp=NULL;
863    struct dirent *direntep;
864#endif
865
866
867    /* ............................................... get cgi parameters */
868#define MAXARGS 512
869    char *argv[MAXARGS+1];
870    char *argv_0[MAXARGS+1];
871
872/* mxaotx.c
873*/
874//CICGI
875#if CICGI
876    int ii,ix;
877    char *xp;
878    LONGX rc;
879#if !CIAPI
880    int cgitrace=0;
881#endif /* !CIAPI */
882
883    char *cgispecp=NULL;
884    char *cgipfxp="tag";
885    UWORD cgitag=2000;
886
887    /* int cicgi0(int *argc, char *argv[], char **wwwp, UWORD taghxsub, char *taghpfxp); */
888    char *wwwp=NULL;
889    char *infop;
890
891#endif
892
893
894//CICGI
895#if MXFUN
896    if (mxinit(&xmxp)) return(1);
897    if (xmxp == NULL) return(2);
898#if CIAPI
899    ciapip = cisisApplication( MAXNREC,MAXNTRM );/* mandatory for CIAPI definitions */
900#endif /* CIAPI */
901#else /* MXFUN */
902    xmxp=NULL;
903#endif /* MXFUN */
904
905
906#if CICGI
907#if CIAPI
908    cgitrace=0;
909#endif /* CIAPI */
910    argv_0[ix=0]=argv_1[0];
911#define TRACX 0
912#if TRACX
913cgitrace=1;
914printf("Content-type: text/plain\n\n");
915printf("PATH_INFO=%s\n",getenv("PATH_INFO"));
916printf("PATH_TRANSLATED=%s\n",getenv("PATH_TRANSLATED"));
917printf("SCRIPT_NAME=%s\n",getenv("SCRIPT_NAME"));
918printf("argv_0[0]=%s\n",argv_0[0]);
919#endif
920
921    infop=getenv("PATH_INFO"); /* PATH_INFO=/cgi=mx */
922    if (infop) {
923        xp=strstr(infop,"cgi="); if (!xp) xp=strstr(infop,"cgi~");
924        if (xp) if (*xp) {
925            cgixpok=argv_0[++ix]=strdup(xp);
926            xp=cgixpok+strlen(xp)-1; if (*xp == '/') *xp='\0';
927#if TRACX
928printf("argv_0[1]=%s\n",argv_0[1]);
929#endif
930        }
931    }
932
933    /* disable PATH_INFO=/cgi= */
934    if (cgixpok)
935        for (i=1; i < argc; i++)
936            if (strcmp(argv_1[i],"cgi=null") == 0) { ix--; cgixpok=NULL; break; }
937
938    argc+=ix; for (ii=1; ii < argc; ) argv_0[++ix]=argv_1[ii++]; argv_0[++ix]=NULL;
939    for (ii=0, i=1; i < argc; i++) if (strncmp(argv_0[i],"cgi",3) == 0) { ii=1; break; }
940    if (ii) { //some cgii
941        /*putenv("REQUEST_METHOD=GET");*/
942        /*putenv("QUERY_STRING=db~cds&pft~mfn,x1,v24/&count~2&now&btell~0&bool~plants*water");*/
943        for (i=0; i < argc; i++) if (strcmp(argv_0[i],"cgitrace") == 0) cgitrace=1;
944        RECORD(wwrec1=nrecs,"null",1L); RECrc=RCNORMAL; MFRstatus=ACTIVE;
945        RECORD(wwrec2=nrecs,"null",1L); xp=(char *)MFX; /* current */
946        for (ii=0, i=0; i < argc; i++) {
947            if (strncmp(argv_0[i],"cgi",3) != 0) argv[ii++]=argv_0[i];
948            else {
949                if (strncmp(argv_0[i],"cgitag=",7) == 0 || strncmp(argv_0[i],"cgitag~",7) == 0) {
950                    cgitag=(UWORD)atol(argv_0[i]+7); continue;
951                }
952                if (strncmp(argv_0[i],"cgipfx=",7) == 0 || strncmp(argv_0[i],"cgipfx~",7) == 0) {
953                    cgipfxp=argv_0[i]+7; continue;
954                }
955                if (strncmp(argv_0[i],"cgi=",4) == 0 || strncmp(argv_0[i],"cgi~",4) == 0) {
956                    cgispecp=argv_0[i]+4;
957                    if (cgitrace) printf("+++ cgispecp=%s.\n",cgispecp);
958                    if (strcmp(cgispecp,"null") == 0) continue;
959                    if (strcmp(cgispecp,"mx") == 0) {
960                        p=NULL;
961                        if (!p) {
962                            sprintf(xp,"@%s",argv_0[0]);
963                            if (strcmp((q=xp+strlen(xp)-4),".EXE") == 0) *q='\0';
964                            if (strcmp((q=xp+strlen(xp)-4),".exe") == 0) *q='\0';
965                        }
966                        cgispecp=strdup(strcat(xp,".pft"));
967                        if (cgitrace) printf("+++ cgispecp=mx=(%s)\n",cgispecp);
968                    }
969                    if (cgitrace) printf("+++ REQUEST_METHOD=%s.\n",getenv("REQUEST_METHOD"));
970                    if (cgitrace) printf("+++ QUERY_STRING=%s.\n",getenv("QUERY_STRING"));
971                    wwwp=NULL; cicgi0(&ii, argv, &wwwp, cgitag, cgipfxp);
972                    if (!wwwp) wwwp="";
973                    if (cgitrace) printf("+++ wwwp=%s.\n",wwwp);
974                    sprintf(xp,"D%"_LD_,(LONGX)cgitag); fldupdat(wwrec1,xp);
975                    p=fldupdat(wwrec1,wwwp); if (p) fatal(p);
976                    rc=recfmt(wwrec1,RECnbytes,cgispecp,p=xp,RECnbytes);
977                    if (rc < 0) fatal(argv_0[i]/*cgispecp*/);
978                    while (*p) {
979                        for (ix=0, q=p; *p; p++)
980                           if (*p == '\r' || *p == '\n') {
981                               *p++='\0'; if (*p == '\n') *p++='\0'; break;
982                           } else ix++;
983                        if (ix) argv[ii++] = strdup(q);
984                    }
985                    continue;
986                } /* end if */
987            } /* end if else */
988        } /* end for */
989        argc=ii; argv[argc]=NULL;
990        if (cgitrace) {
991         printf("Content-type: text/html\n\n");
992         printf("%s/cgi produced %d parameters:<br>\n",argv[0],argc-1);
993         printf("<ul>\n");
994         for(ix=1; ix < argc; ix++) printf("<li><pre>%s</pre>\n",argv[ix]);
995         printf("</ul>\n");
996        }
997    }
998    else { //some cgii
999/*
1000REQUEST_METHOD=GET
1001QUERY_STRING=cicgi~mx&db~cds&pft~mfn,x1,v24/&count~2&now&btell~0&bool~plants*water
1002*/
1003        for (i=0; i < argc; i++) if (strcmp(argv_0[i],"trace=cgi") == 0) cgitrace=1;
1004        for (ii=0, i=0; i < argc; i++) if (strcmp(argv_0[i],"trace=cgi")) argv[ii++]=argv_0[i];
1005        argc=ii;
1006        if (cicgi0(&argc, argv, NULL, 0, NULL)) {
1007if (cgitrace) {
1008 printf("Content-type: text/html%c%c",10,10);
1009 printf("%s/CICGI produced the following %d parameters:<p>%c",argv[0],argc-1,10);
1010 printf("<ul>%c",10);
1011 for(ix=1; ix < argc; ix++) printf("<li> <code>%s</code>%c",argv[ix],10);
1012 printf("</ul>%c",10);
1013}
1014        }
1015    } //some cgii
1016#endif /* CICGI */
1017//CICGI
1018
1019    argnext=1;
1020    if (argc > 1)
1021        if (*argv[1] == '?' || *argv[1] == '=') {
1022            for (i=0; i < argc; i++)
1023                printf("argv[%d]: %c%s%c\n",i,OPENFCHR,argv[i],CLOSFCHR);
1024            MXEXIT(0);
1025        }
1026
1027#define WHATISNEW 00
1028#if WHATISNEW
1029    if (argc > 1)
1030        if (strcmp(argv[1],"whatisnew") == 0) {
1031            printf("summary \n\n");
1032//CICGI
1033#if CICGI
1034            printf("    CGI data        get mx parameter from cgi environment \n\n");
1035            printf(" set REQUEST_METHOD=GET \n");
1036            printf(" set QUERY_STRING=db~cds&count~2&now&btell~0&bool~plants*water&pft~mfn/ \n");
1037            printf(" mx cgi=mx \n");
1038            printf(" 000004 \n");
1039            printf(" 000011 \n\n");
1040#endif /* CICGI */
1041            printf("    I/F keys        read I/F keys as mx input records \n\n");
1042            printf(" mx dict=cds k1=africa \"k2=african languages\" now  \n");
1043            printf(" mfn=     1  \n");
1044            printf("   1  �AFRICA^l1^s6^t5^k1� \n");
1045            printf(" mfn=     2  \n");
1046            printf("   1  �AFRICAN LANGUAGES^l2^s17^t1^k2� \n");
1047            printf(" \n");
1048            printf("    I/F postings    read I/F keys and postings as mx input records \n\n");
1049            printf(" mx dict=cds,1,2/3 k1=africa count=2 now  \n");
1050            printf(" mfn=     1  \n");
1051            printf("   1  �AFRICA^l1^s6^t5^k1� \n");
1052            printf("   2  �^m97^t69^o1^c9^p1^k1� \n");
1053            printf("   2  �^m115^t24^o1^c3^p2^k1� \n");
1054            printf("   2  �^m115^t69^o1^c3^p3^k1� \n");
1055            printf(" mfn=     2  \n");
1056            printf("   1  �AFRICA^l1^s6^t5^k1� \n");
1057            printf("   2  �^m119^t69^o1^c7^p4^k1� \n");
1058            printf("   2  �^m125^t69^o1^c4^p5^k1� \n");
1059            printf(" \n");
1060            printf("    field add       field add w/ markup strip \n\n");
1061            printf(" mx null \"proc='<10>x<mark>y</mark>z</10>'\" \n");
1062/*          printf(" mfn=     1 \n"); */
1063            printf("  10  �xyz� \n\n");
1064            printf("    procedures      up to %d proc= parameters, including fst, read, write, I/F update \n\n",MAXNPPP);
1065            printf(" mx cds \"proc='T99 2 (v69/)'\" \n");
1066/*          printf(" mfn=     1 \n"); */
1067            printf("  69  �Paper on: <plant physiology><plant transpiration><measurement and instruments>� \n");
1068            printf("  99  �PLANT PHYSIOLOGY^m1^o1^c1^l2� \n");
1069            printf("  99  �PLANT TRANSPIRATION^m1^o1^c2^l2� \n");
1070            printf("  99  �MEASUREMENT AND INSTRUMENTS^m1^o1^c3^l2� \n\n");
1071            printf(" mx null proc='Rcds,1' \n");
1072            printf(" mfn=     1 \n");
1073            printf("  44  �Methodology of plant eco-physiology: proceedings of the Montpellier Sympoium� \n");
1074            printf("  50  �Incl. bibl.� \n");
1075            printf("  69  �Paper on: <plant physiology><plant transpiration><measurement and instrumnts>� \n");
1076            printf("  24  �Techniques for the measurement of transpiration of individual plants� \n");
1077            printf("  26  �^aParis^bUnesco^c-1965� \n");
1078            printf("  30  �^ap. 211-224^billus.� \n");
1079            printf("  70  �Magalhaes, A.C.� \n");
1080            printf("  70  �Franco, C.M.� \n\n");
1081            printf(" mx null proc='a10/1/' proc='Xdbn1' \n");
1082            printf(" mx dbn1 \n");
1083            printf(" mfn= 1 \n");
1084            printf(" 10 �1� \n\n");
1085            printf(" del lilacs_year_*.mst \n");
1086            printf(" del lilacs_year_*.xrf \n");
1087            printf(" mx lilacs proc='Xappend=lilacs_year_',v64.4 \n\n");
1088            printf(" mx null proc='a1/x/' to=3 \"proc='Yy,,,1 0 v1'\" \"pft='npost='f(npost(['y']'x'),1,0)/\" \n");
1089            printf(" npost=1 \n");
1090            printf(" npost=2 \n");
1091            printf(" npost=3 \n\n");
1092            printf(" mx cds -all now proc='Xx' proc='Zx' \n");
1093            printf(" ifupd x fst=@cds.fst tell=1 \n");
1094            printf(" 0 records updated \n");
1095            printf(" 0+0=0 postings added \n");
1096            printf(" 0+0=0 postings deleted \n\n");
1097            printf(" del lilacs_year_*.12 \n");
1098            printf(" mx lilacs proc='Fappend=lilacs_year_',v64.4,'.12',v1'-'v2/ \n\n");
1099#if MORE1
1100            printf(" mx null proc='a10/1/' create=x \n");
1101            printf(" mfn=     1 \n");
1102            printf("  10  �1� \n");
1103            printf(" mx null proc='a20/2/' append=x \n");
1104/*            printf(" mfn=     1 \n"); */
1105            printf("  20  �2� \n");
1106            printf(" mx null proc='Rx,1' proc='Rx,2' \n");
1107/*            printf(" mfn=     1 \n"); */
1108            printf("  10  �1� \n");
1109            printf("  20  �2� \n\n");
1110
1111            printf(" mx null proc='a10/1/' proc='Xdbn1' proc='a20/2/' proc='Xdbn2' \n");
1112            printf(" mx dbn1 \n");
1113            printf(" mfn=     1 \n");
1114            printf("  10  �1� \n");
1115            printf(" mx dbn2 \n");
1116            printf(" mfn=     1 \n");
1117            printf("  10  �1� \n");
1118            printf("  20  �2� \n\n");
1119            printf(" @echo 'd*a32701~',,mstname,,'^m',,f(mfn,8,0),,'~',, >p0 \n");
1120            printf(" @echo '=',,ref(['mstxrf']1,f(maxmfn,1,0)) >p1 \n");
1121            printf(" @echo if l(['mstxrf']v32701)=0 then 'Xmstxrf' fi >p2 \n");
1122            printf(" @echo if l(['mstxrf']v32701)=0 then 'Ymstxrf,mstxrf,32701 0 v32701' fi >p3 \n");
1123            printf(" mx full x -all now proc=@p0 proc=@p1 proc=@p2 proc=@p3 \n\n");
1124#endif /* MORE1 */
1125            /* printf("    cipar           ci_tempdir, maxmfrl, ci_fststrip \n\n"); */
1126            printf("    cipar           set directory for temporary files \n\n");
1127            printf(" echo ci_tempdir=c:\\work >xcip \n");
1128            printf(" mx cipar=xcip cdromdb \n\n");
1129            printf("    cipar           set max master file record length \n\n");
1130            printf(" @echo maxmfrl=32000 >xcip \n");
1131            printf(" mx cipar=xcip bigrecs \n\n");
1132#define CIFS 1
1133#if CIFS
1134            printf("    cipar           strip <markup> marks during fst \n\n");
1135            printf(" set echo ci_fststrip=32000 >xcip \n");
1136            printf(" mx cds \n");
1137            printf("  69  �Paper on: <plant physiology><plant transpiration><measurement and instruments>� \n");
1138            printf(" mx cipar=xcip cds \"fst=690 4 v69\" \n");
1139            printf("  69  �Paper on:                                                                     � \n");
1140            printf(" 690  �PAPER^m1^o1^c1^l1� \n");
1141            printf(" 690  �ON^m1^o1^c2^l1� \n\n");
1142#endif /* CIFS */
1143            printf("    fst             indexing technique to extract text within <mark> and </mark> \n\n");
1144            printf(" mx null \"fst=1 2000 '#<B>#','text <B>text1</B> text <B>text2</B> text'\" \n");
1145            printf("   1  �TEXT1TEXT2^m1^o1^c1^l1� \n\n");
1146            printf("    format          read a stdin input line as a new field occurrence \n\n");
1147            printf(" mx null to=2 \"pft=if mfn=1 then _10,putenv('TAG10='v10) fi,,mfn,x1,getenv('TAG10'),/ \n");
1148            printf(" input line \n");
1149            printf(" 000001 input line \n");
1150            printf(" 000002 input line \n\n");
1151            printf("    format          get the contents of a specified cgi variable \n\n");
1152            printf(" set REQUEST_METHOD=GET \n");
1153            printf(" set QUERY_STRING=db~cds&bool~plants*water \n");
1154            printf(" mx null pft=getenv('cgi=db') \n");
1155            printf(" cds \n\n");
1156            printf("    format          get a temporary empty file name \n\n");
1157            printf(" mx null pft=getenv('tmp=') \n");
1158            printf(" TMP1.$$$ \n\n");
1159#if DOS32BITS
1160            printf("    platform        32-bit memory support \n\n");
1161            printf(" mx null count=1 sys='mx what' \n");
1162            printf(" CISIS Interface v4.01/fmtold/PC32/M/30000/10/30/I - Utility MX \n");
1163            printf(" CISIS Interface v4.01/fmtold/.iy0/Z/4GB/GIZ/DEC/ISI/UTL/FAT/CIP/CGI \n");
1164            printf(" Copyright (c)BIREME/PAHO 2000. All rights reserved. \n\n");
1165#endif /* DOS32BITS */
1166#if CICGI
1167            printf("[cgitag=<tag>] [cgipfx=<pfx>] cgi={<fmt>|mx}^uy^hget mx calling parameters from CGI^xx \n\n");
1168            printf("    cgitag=<tag>    tag for ^n^v pairs [%"_LD_"]\n",cgitag);
1169            printf("    cgipfx=<pfx>    tag naming prefix [%s] \n",cgipfxp);
1170            printf("    cgi=<fmt>       specify mx parameters via <fmt> \n");
1171#if 0
1172            printf("    cgi=mx          specify mx parameters via "); /* built-in specification */
1173for (xp=argv_0[0], ix=(strcmp(xp+strlen(xp)-4,".EXE") == 0)?strlen(xp)-4:strlen(xp); ix--; xp++) printf("%c",*xp);
1174printf(".pft \n\n");
1175#else
1176            printf("    cgi=mx          specify mx parameters by corresponding names \n\n"); /* built-in specification */
1177#endif
1178            printf("    store CGI name/value pairs as repeatable field %"_LD_" \n",cgitag);
1179            printf("    and take each line produced by format <fmt> (or mx.pft) as an additional mx parameter \n\n");
1180            printf(" set REQUEST_METHOD=GET \n");
1181            printf(" set QUERY_STRING=db~cds&count~2&now&btell~0&bool~plants*water&pft~mfn/ \n");
1182            printf(" mx cgi=mx \n");
1183            printf(" 000004 \n");
1184            printf(" 000011 \n\n");
1185            printf(" <html> \n");
1186            printf(" <body> \n");
1187            printf(" <form action=\"/cgi-bin/mx.exe/cgi=mx\" method=\"post\"> \n");
1188            printf(" Run MX with 'bool=' and 'count=' parameters assigned to the following values:<hr> \n");
1189            printf(" Search expression:    <input type=\"text\" name=\"bool\"  value=\"$\"><br> \n");
1190            printf(" Max #records to show: <input type=\"text\" name=\"count\" value=\"10\"><br> \n");
1191            printf(" <input type=\"submit\" value=\"search & display\"> \n");
1192            printf(" <input type=\"hidden\" name=\"db\" value=\"D:\\Users\\www\\isis\\data\\cds\"> \n");
1193            printf(" <input type=\"hidden\" name=\"pft\" value=\"lw(8000),newline('<br>'),@D:\\Users\\www\\isis\\data\\cds.pft\"> \n");
1194            printf(" <input type=\"hidden\" name=\"now\"> \n");
1195            printf(" <input type=\"hidden\" name=\"btell\" value=\"0\"> \n");
1196            printf(" </form> \n");
1197            printf(" </body> \n");
1198            printf(" </html> \n\n");
1199#endif /* CICGI */
1200            printf("dict=<ifn>[,<ktag>[,<ptag>[/<pmax>]]] [k{1|2}=<key>]^hread I/F keys as mx input records^xx \n\n");
1201            printf("    <ifn>           I/F dictionary \n");
1202            printf("    <ktag>          tag for I/F key [1] \n");
1203            printf("    <ptag>          tag for I/F posting \n");
1204            printf("    <pmax>          max postings per record [all] \n");
1205            printf("    k1=<key>        initial key \n");
1206            printf("    k2=<key>        final key \n\n");
1207            printf("    read I/F keys from <ifn> as mx input records with field <ktag> \n");
1208            printf("    with key and ^l=lex ^s=keylength ^t=totalpostings ^k=keyorder \n\n");
1209            printf("    if <ptag> is specified, combine I/F keys and corresponding postings \n");
1210            printf("    as mx input records having up to <pmax> postings each; \n");
1211            printf("    <ptag> has the form ^m=mfn ^t=tag ^o=occ ^c=cnt ^ppstorder ^kkeyorder \n\n");
1212            printf(" mx dict=cds k1=africa \"k2=african languages\" now  \n");
1213            printf(" mfn=     1  \n");
1214            printf("   1  �AFRICA^l1^s6^t5^k1� \n");
1215            printf(" mfn=     2  \n");
1216            printf("   1  �AFRICAN LANGUAGES^l2^s17^t1^k2� \n\n");
1217            printf(" mx dict=cds,1,2 k1=africa count=1 now  \n");
1218            printf(" mfn=     1  \n");
1219            printf("   1  �AFRICA^l1^s6^t5^k1� \n");
1220            printf("   2  �^m97^t69^o1^c9^p1^k1� \n");
1221            printf("   2  �^m115^t24^o1^c3^p2^k1� \n");
1222            printf("   2  �^m115^t69^o1^c3^p3^k1� \n");
1223            printf("   2  �^m119^t69^o1^c7^p4^k1� \n");
1224            printf("   2  �^m125^t69^o1^c4^p5^k1� \n\n");
1225            printf(" mx dict=cds,1,2/3 k1=africa count=2 now  \n");
1226            printf(" mfn=     1  \n");
1227            printf("   1  �AFRICA^l1^s6^t5^k1� \n");
1228            printf("   2  �^m97^t69^o1^c9^p1^k1� \n");
1229            printf("   2  �^m115^t24^o1^c3^p2^k1� \n");
1230            printf("   2  �^m115^t69^o1^c3^p3^k1� \n");
1231            printf(" mfn=     2  \n");
1232            printf("   1  �AFRICA^l1^s6^t5^k1� \n");
1233            printf("   2  �^m119^t69^o1^c7^p4^k1� \n");
1234            printf("   2  �^m125^t69^o1^c4^p5^k1� \n\n");
1235            printf(" mx dict=cds,1,2/1 k1=africa count=5 now  \n");
1236            printf(" mfn=     1  \n");
1237            printf("   1  �AFRICA^l1^s6^t5^k1� \n");
1238            printf("   2  �^m97^t69^o1^c9^p1^k1� \n");
1239            printf(" mfn=     2  \n");
1240            printf("   1  �AFRICA^l1^s6^t5^k1� \n");
1241            printf("   2  �^m115^t24^o1^c3^p2^k1� \n");
1242            printf(" mfn=     3  \n");
1243            printf("   1  �AFRICA^l1^s6^t5^k1� \n");
1244            printf("   2  �^m115^t69^o1^c3^p3^k1� \n");
1245            printf(" mfn=     4  \n");
1246            printf("   1  �AFRICA^l1^s6^t5^k1� \n");
1247            printf("   2  �^m119^t69^o1^c7^p4^k1� \n");
1248            printf(" mfn=     5  \n");
1249            printf("   1  �AFRICA^l1^s6^t5^k1� \n");
1250            printf("   2  �^m125^t69^o1^c4^p5^k1� \n\n");
1251#if TBISNEW
1252            printf("tb=<tag>^hsave data fields as individual files^xx \n\n");
1253            printf("    <tag>           field tag \n\n");
1254            printf("    save the contents of field <tag> into binary file MFRmfn.<tag> \n");
1255            printf("    if <tag> is zero save whole data segment into file MFRmfn.dat \n\n");
1256            printf(" mx cds tb=30 tb=70 \"pft=mfn,x2,v30,x2,v70+|; |/\" \n");
1257            printf(" 000001  ^ap. 211-224^billus.  Magalhaes, A.C.; Franco, C.M. \n");
1258            printf(" /****************************************************** \n");
1259            printf(" 1.30 \n");
1260            printf(" ******************************************************/ \n");
1261            printf(" ^ap. 211-224^billus. \n");
1262            printf(" /****************************************************** \n");
1263            printf(" 1.70 \n");
1264            printf(" ******************************************************/ \n");
1265            printf(" Magalhaes, A.C.Franco, C.M. \n");
1266#endif /* TB */
1267            printf("proc=<<tag>[ <marklen>[ <fldlen>]]><text></<tag>>^uy^hproc=< to add text between <marks>^xx \n\n");
1268            printf("    <tag>           field tag \n");
1269            printf("    <marklen>       max mark length [<text> length] \n");
1270            printf("    <fldlen>        min resulting field length to add a new occ of field <tag> [0] \n\n");
1271            printf("    add <text> as a new occurrence of field <tag> \n");
1272            printf("    <marks> up to <marklen> chars are stripped from <text> \n");
1273            printf("    do not add a new occurrence of field <tag> if the resulting text is shorter than <fldlen> chars \n\n");
1274#if MELHOR
1275ver se altercao acima nao estorou linha do browser
1276C:\cid>mx null count=1 "proc='<10>x<mark>y</mark>z</10>'"
1277mfn=     1
1278 10  xyz
1279
1280C:\cid>mx null count=1 "proc='<10 0>x<mark>y</mark>z</10>'"
1281mfn=     1
1282 10  x<mark>y</mark>z
1283
1284C:\cid>mx null count=1 "proc='<10 5>x<mark>y</mark>z</10>'"
1285mfn=     1
1286 10  x<mark>y</mark>z
1287
1288C:\cid>mx null count=1 "proc='<10 6>x<mark>y</mark>z</10>'"
1289mfn=     1
1290 10  xy</mark>z
1291
1292C:\cid>mx null count=1 "proc='<10 7>x<mark>y</mark>z</10>'"
1293mfn=     1
1294 10  xyz
1295#endif
1296            printf(" mx null \"proc='<10>text</10>'\" \n");
1297            printf(" mfn=     1 \n");
1298            printf("  10  �text� \n\n");
1299            printf(" mx null \"proc='<10>x<mark>y</mark>z</10>'\" \n");
1300            printf(" mfn=     1 \n");
1301            printf("  10  �xyz� \n\n");
1302            printf(" mx null \"proc='<10 99 3>x<mark>y</mark>z</10>'\" \n");
1303            printf(" mfn=     1 \n");
1304            printf("  10  �xyz� \n");
1305            printf(" mx null \"proc='<10 99 4>x<mark>y</mark>z</10>'\" \n");
1306            printf(" mfn=     1 \n\n");
1307#if GENPROCT
1308            printf("proc=T[/h=]<fst>^hproc=T to add fst results^xx \n\n");
1309            printf("    <fst>           field select table specification \n\n");
1310            printf("    apply <fst> to MFR adding generated links as data fields \n");
1311            printf("    command T/h=<fst> stands for full-length key extraction \n\n");
1312            printf(" mx cds \"proc='T99 0 (v70/)'\" \n");
1313            printf(" mfn=     1 \n");
1314            printf("  70  �Magalhaes, A.C.� \n");
1315            printf("  70  �Franco, C.M.� \n");
1316            printf("  99  �MAGALHAES, A.C.^m1^o1^c1^l2� \n");
1317            printf("  99  �FRANCO, C.M.^m1^o1^c2^l2� \n\n");
1318            printf(" mx cds \"proc='T/h=0 0 (v70/)'\" \n");
1319            printf(" mfn=     1 \n");
1320            printf(" 32767  �Magalhaes, A.C. \n");
1321            printf(" Franco, C.M. \n");
1322            printf(" � \n\n");
1323            printf(" echo PLANT PHYSIOLOGY>x \n");
1324            printf(" echo PLANT TRANSPIRATION>>x \n");
1325            printf(" mx seq=x -all now \"fst=1 0 v1\" ifupd/create=thes \n");
1326/*            printf(" mx cds \"proc='T99 2 (v69/)'\" \"proc=(if l(['thes']v99^*)=0 then 'a999|'v99^*'|' fi)\" \"pft=(if p(v999) then 'not in thes: 'v999/ fi)\" \n");
1327*/
1328            printf(" mx cds \"proc='T99 2 (v69/)'\" \"pft=(if l(['thes']v99^*)=0 then 'not in thes: 'v99^*/ fi)\" \n");
1329            printf(" mfn=     1 \n");
1330            printf("  69  �Paper on: <plant physiology><plant transpiration><measurement and instruments>� \n");
1331            printf("  99  �PLANT PHYSIOLOGY^m1^o1^c1^l2� \n");
1332            printf("  99  �PLANT TRANSPIRATION^m1^o1^c2^l2� \n");
1333            printf("  99  �MEASUREMENT AND INSTRUMENTS^m1^o1^c3^l2� \n");
1334            printf(" not it thes: MEASUREMENT AND INSTRUMENTS \n\n");
1335#endif /* GENPROCT */
1336            printf("proc=R<dbn>,<mfn>^hproc=R to add data of another record^xx \n\n");
1337            printf("    <dbn>           input master file name \n");
1338            printf("    <mfn>           master file record number \n\n");
1339            printf("    add to MFR all data fields of active record <dbn>,<mfn> \n\n");
1340            printf(" mx null proc='a10/1/a20/1/' create=x \n");
1341/*            printf(" mfn=     1 \n"); */
1342            printf("  10  �1� \n");
1343            printf("  20  �1� \n");
1344            printf(" mx null proc='a20/2/' append=x \n");
1345/*            printf(" mfn=     1 \n"); */
1346            printf("  20  �2� \n");
1347            printf(" mx null proc='Rx,1' proc='Rx,2' \n");
1348            printf(" mfn=     1 \n");
1349            printf("  10  �1� \n");
1350            printf("  20  �1� \n");
1351            printf("  20  �2� \n\n");
1352            printf("proc=X[{create|copy|append|merge}=]<out_dbn>^hproc=X to write an output record^xx \n\n");
1353            printf("    <out_dbn>       output master file name \n\n");
1354            printf("    create <out_dbn> if does not exist \n");
1355            printf("    write MFR to <out_dbn> as record MFRmfn or \n");
1356            printf("    append MFR to <out_dbn> or \n");
1357            printf("    merge MFR to <out_dbn> \n\n");
1358            printf(" mx null proc='a10/1/' proc='Xdbn1' proc='a20/2/' proc='=3' proc='Xdbn2' \n");
1359            printf(" mx dbn1 \n");
1360            printf(" mfn=     1 \n");
1361            printf("  10  �1� \n");
1362            printf(" mx dbn2 \n");
1363            printf(" mfn=     3 \n");
1364            printf("  10  �1� \n");
1365            printf("  20  �2� \n\n");
1366            printf(" echo replace(replace(s(v70[1].8),',','-'),' ','+') >xfile.pft \n");
1367            printf(" mx cds proc='Xappend='@xfile.pft, pft=mfn,x1,v70[1]/ \n");
1368            printf(" 000001 Magalhaes, A.C. \n");
1369            printf(" 000002 Bosian, G. \n");
1370            printf(" 000003 Bosian, G. \n");
1371            printf(" mx Magalhae pft=mfn,x1,v70[1]/ \n");
1372            printf(" 000001 Magalhaes, A.C. \n");
1373            printf(" mx Bosian-+ pft=mfn,x1,v70[1]/ \n");
1374            printf(" 000002 Bosian, G. \n");
1375            printf(" 000003 Bosian, G. \n\n");
1376            printf("proc=Y[create=]<out_ifn>,[<dbn>],[<mfn>],<fst>^hproc=Y to update an I/F^xx \n\n");
1377            printf("    <out_ifn>       output inverted file name \n");
1378            printf("    <dbn>           master file name, or 'null' \n");
1379            printf("    <mfn>           master file record number \n");
1380            printf("    <fst>           field select table specification \n\n");
1381            printf("    if <dbn> is 'null' or omitted update <out_ifn> applying <fst> to MFR \n");
1382            printf("    assign <mfn> [MFRmfn] to components TRMpmfn of generated postings \n");
1383            printf("    otherwise update <out_ifn> applying <fst> to record <mfn> [MFRmfn] of <dbn> \n");
1384            printf("    does not reset any IFupdPending flag \n\n");
1385/*          printf("    reset corresponding flag IFupdPending if exist <out_ifn>.mst \n\n"); */
1386            printf(" @echo Procedure to create a centralized index for a set of data bases \n");
1387            printf(" @echo Setup sample data base MF1, MF1.fst and MF1.pft.. \n");
1388            printf(" @echo 100 0 v1/,v2/,v1'/'v2/ >MF1.fst \n");
1389            printf(" @echo '[MF1] 'mfn/,' 1='v1/,' 2='v2/ >MF1.pft \n");
1390            printf(" @mx null count=1 \"proc='a1~master 1~a2~registro 1~'\" create=MF1 pft=@MF1.pft \n");
1391            printf(" @mx null count=1 \"proc='a1~master 1~a2~registro 2~'\" append=MF1 pft=@MF1.pft \n");
1392            printf(" @echo Setup sample data base MF2, MF2.fst and MF2.pft.. \n");
1393            printf(" @echo 200 0 v10/,v20/,v10'/'v20/ >MF2.fst \n");
1394            printf(" @echo '[MF2] 'mfn/,' 10='v10/,' 20='v20/ >MF2.pft \n");
1395            printf(" @mx null count=1 \"proc='a10~master 2~a20~registro 1~'\" create=MF2 pft=@MF2.pft \n");
1396            printf(" @echo And init centralized record number M/F and all indexes I/F.. \n");
1397            printf(" mx null count=0 create=mstxrf ifupd/create=mstxrf \n");
1398            printf(" @pause \n");
1399            printf(" @echo Load MF1 and MF2 into same mstxrf and index them.. \n");
1400            printf(" @rem setup centralized record numbering procs \n");
1401            printf(" @echo 'd*a32701~',mstname'^m'f(mfn,8,0)'~' >p1 \n");
1402            printf(" @echo if l(['mstxrf']v32701)=0 then '='ref(['mstxrf']1,f(maxmfn,1,0)),,'X','mstxrf' fi >p2a \n");
1403            printf(" @echo if l(['mstxrf']v32701)=0 then 'Y','mstxrf,null,,32701 0 v32701' fi >p2b \n");
1404            printf(" @echo 'Z',v32701^*','f(val(v32701^m),1,0) >p2c \n");
1405            printf(" @rem setup centralized index update procs \n");
1406            printf(" @echo 'R',v32701^*','f(val(v32701^m),1,0) >p3a \n");
1407            printf(" @echo 'Y','mstxrf,null,'f(l(['mstxrf']v32701),1,0)',@'v32701^*'.fst' >p3b \n");
1408            printf(" @echo 'Z',v32701^*','f(val(v32701^m),1,0) >p3c \n");
1409            printf(" @rem fldupdat() commands 'R', 'X', 'Y' and 'Z' may occur just once per 'proc=' or 'proc()'^iy^xx \n");
1410            printf(" @rem otherwise two or more of these procs could be put together in a single 'proc=' file^iy^xx \n");
1411            printf(" @rem p1 \n");
1412            printf(" @rem 'd*a32701~',mstname'^m'f(mfn,8,0)'~' \n");
1413            printf(" @rem p2a \n");
1414            printf(" @rem if l(['mstxrf']v32701)=0 then '='ref(['mstxrf']1,f(maxmfn,1,0)),,'X','mstxrf' fi \n");
1415            printf(" @rem p2b \n");
1416            printf(" @rem if l(['mstxrf']v32701)=0 then 'Y','mstxrf,null,,32701 0 v32701' fi \n");
1417            printf(" @rem p2c \n");
1418            printf(" @rem 'Z',v32701^*','f(val(v32701^m),1,0) \n");
1419            printf(" @rem p3a \n");
1420            printf(" @rem 'R',v32701^*','f(val(v32701^m),1,0) \n");
1421            printf(" @rem p3b \n");
1422            printf(" @rem 'Y','mstxrf,null,'f(l(['mstxrf']v32701),1,0)',@'v32701^*'.fst' \n");
1423            printf(" @rem p3c \n");
1424            printf(" @rem 'Z',v32701^*','f(val(v32701^m),1,0) \n");
1425            printf(" @rem \n");
1426            printf(" mx %1 MF1 now proc=@p1 proc=@p2a proc=@p2b proc=@p2c proc=@p3a proc=@p3b proc=@p3c \n");
1427            printf(" @rem mfn=     1 \n");
1428            printf(" @rem 32701  �MF1^m       1� \n");
1429            printf(" @rem   1  �master 1� \n");
1430            printf(" @rem   2  �registro 1� \n");
1431            printf(" @rem mfn=     2 \n");
1432            printf(" @rem 32701  �MF1^m       1� \n");
1433            printf(" @rem   1  �master 1� \n");
1434            printf(" @rem   2  �registro 2� \n");
1435            printf(" @rem \n");
1436            printf(" mx %1 MF2 now proc=@p1 proc=@p2a proc=@p2b proc=@p2c proc=@p3a proc=@p3b proc=@p3c \n");
1437            printf(" @rem mfn=     3 \n");
1438            printf(" @rem 32701  �MF2^m       1� \n");
1439            printf(" @rem  10  �master 2� \n");
1440            printf(" @rem  20  �registro 1� \n");
1441            printf(" @rem \n");
1442            printf(" @pause \n");
1443            printf(" @echo Create default display format for centralized record number M/F.. \n");
1444            printf(" @rem setup header and read original record \n");
1445            printf(" @echo '[mstxrf 'mfn'] ',v32701/, >mstxrf.pft \n");
1446            printf(" @echo proc('R'v32701^*,',',v32701^m), >>mstxrf.pft \n");
1447            printf(" @echo proc('='f(val(v32701^m),1,0)), >>mstxrf.pft \n");
1448            printf(" @rem setup original display format selection \n");
1449            printf(" @echo if v32701^*='MF1' then @MF1.pft, fi, >>mstxrf.pft \n");
1450            printf(" @echo if v32701^*='MF2' then @MF2.pft, fi, >>mstxrf.pft \n");
1451            printf(" @echo And test it.. \n");
1452            printf(" mx mstxrf \"bool=registro 1\" pft=@ now \n");
1453            printf(" @rem \n");
1454            printf(" @rem mx mstxrf \"bool=registro 1\" pft=@ now \n");
1455            printf(" @rem       2       2  REGISTRO 1 \n");
1456            printf(" @rem       2       2  Set #000001 \n");
1457            printf(" @rem Hits=2 \n");
1458            printf(" @rem [mstxrf 000001] MF1^m       1 \n");
1459            printf(" @rem [MF1] 000001 \n");
1460            printf(" @rem  1=master 1 \n");
1461            printf(" @rem  2=registro 1 \n");
1462            printf(" @rem 100= \n");
1463            printf(" @rem [mstxrf 000003] MF2^m       1 \n");
1464            printf(" @rem [MF2] 000001 \n");
1465            printf(" @rem  10=master 2 \n");
1466            printf(" @rem  20=registro 1 \n");
1467            printf(" @rem 200= \n");
1468            printf(" @rem \n");
1469            printf(" type mstxrf.pft \n");
1470            printf(" @rem '[mstxrf 'mfn'] ',v32701/, \n");
1471            printf(" @rem proc('R'v32701^*,',',v32701^m), \n");
1472            printf(" @rem proc('='f(val(v32701^m),1,0)), \n");
1473            printf(" @rem if v32701^*='MF1' then @MF1.pft, fi, \n");
1474            printf(" @rem if v32701^*='MF2' then @MF2.pft, fi, \n");
1475            printf(" @rem \n");
1476            printf(" @rem mz mstxrf -control now \n");
1477            printf(" @rem  + MASTER 1  : 1/9/0 \n");
1478            printf(" @rem    #1/2: mfn=1 tag=100 occ=1 cnt=1 \n");
1479            printf(" @rem    #2/2: mfn=2 tag=100 occ=1 cnt=1 \n");
1480            printf(" @rem  + MASTER 1/REGISTRO 1           : 1/23/0 \n");
1481            printf(" @rem    #1/1: mfn=1 tag=100 occ=1 cnt=3 \n");
1482            printf(" @rem  + MASTER 1/REGISTRO 2           : 1/51/0 \n");
1483            printf(" @rem    #1/1: mfn=2 tag=100 occ=1 cnt=3 \n");
1484            printf(" @rem  + MASTER 2  : 1/65/0 \n");
1485            printf(" @rem    #1/1: mfn=3 tag=200 occ=1 cnt=1 \n");
1486            printf(" @rem  + MASTER 2/REGISTRO 1           : 1/79/0 \n");
1487            printf(" @rem    #1/1: mfn=3 tag=200 occ=1 cnt=3 \n");
1488            printf(" @rem  + MF1^M       1                 : 1/2/0 \n");
1489            printf(" @rem    #1/1: mfn=1 tag=32701 occ=1 cnt=1 \n");
1490            printf(" @rem  + MF1^M       2                 : 1/30/0 \n");
1491            printf(" @rem    #1/1: mfn=2 tag=32701 occ=1 cnt=1 \n");
1492            printf(" @rem  + MF2^M       1                 : 1/58/0 \n");
1493            printf(" @rem    #1/1: mfn=3 tag=32701 occ=1 cnt=1 \n");
1494            printf(" @rem  + REGISTRO 1: 1/16/0 \n");
1495            printf(" @rem    #1/2: mfn=1 tag=100 occ=1 cnt=2 \n");
1496            printf(" @rem    #2/2: mfn=3 tag=200 occ=1 cnt=2 \n");
1497            printf(" @rem  + REGISTRO 2: 1/44/0 \n");
1498            printf(" @rem    #1/1: mfn=2 tag=100 occ=1 cnt=2 \n");
1499            printf(" @rem \n\n");
1500            printf("proc=Z<out_dbn>[,<mfn>]^hproc=Z to reset IFupdPending^xx \n\n");
1501            printf("    <out_dbn>       master file name \n");
1502            printf("    <mfn>           master file record number \n\n");
1503            printf("    reset flag IFupdPending corresponding to <mfn> [MFRmfn] from <out_dbn> \n\n");
1504            printf(" mx cds -all now proc='Xx' proc='Zx' \n");
1505            printf(" ifupd x fst=@cds.fst tell=1 \n");
1506            printf(" 0 records updated \n");
1507            printf(" 0+0=0 postings added \n");
1508            printf(" 0+0=0 postings deleted \n\n");
1509            printf("proc=F[{create|append}=]<out_file>,<text>^hproc=F to write a text to a file^xx \n\n");
1510            printf("    <out_file>      output file name \n");
1511            printf("    <text>          null terminated text \n\n");
1512            printf("    create <out_file> if does not exist \n");
1513            printf("    append <text> to <out_file> \n\n");
1514            printf(" echo replace(replace(s(v70[1].8),',','-'),' ','+') >xfile.pft \n");
1515            printf(" mx cds proc='Fappend='@xfile.pft,',',v24.68,'.' pft=mfn,x1,v70[1]/ \n");
1516            printf(" 000001 Magalhaes, A.C. \n");
1517            printf(" 000002 Bosian, G. \n");
1518            printf(" /****************************************************** \n");
1519            printf(" Magalhae \n");
1520            printf(" ******************************************************/ \n");
1521            printf(" Techniques for the measurement of transpiration of individual plants. \n");
1522            printf(" /****************************************************** \n");
1523            printf(" Bosian-+ \n");
1524            printf(" ******************************************************/ \n");
1525            printf(" <The> Controlled climate in the plant chamber and its influence upon. \n\n");
1526            printf("cipar: ci_tempdir=<path>^uy^cy^hcipar/ci_tempdir: set directory for temporary files^xx \n\n");
1527            printf("    <path>          drive and/or directory name \n\n");
1528            printf("    defined in cipar or environment \n");
1529            printf("    create temporary files in directory <path> \n");
1530            printf("    (if ci_tempdir is not set temporary files are created in directory \n");
1531            printf("    defined by the environment variable TEMP or by TMP) \n\n");
1532            printf(" echo ci_tempdir=c:\\work >xcip \n");
1533            printf(" mx cipar=xcip cdromdb \n\n");
1534            printf(" @set ci_tempdir=c:\\work \n");
1535            printf(" mx cdromdb \n\n");
1536            printf("cipar: maxmfrl=<nbytes>^hcipar/maxmfrl: set max master file record length^xx \n\n");
1537            printf("    <nbytes>        number of bytes \n\n");
1538            printf("    defined in cipar \n");
1539            printf("    specify the default MFRmfrl (master file record length) [%"_LD_"]\n",rec_maxmfrl);
1540#if CICPP
1541            printf("    (the maximum MFRmfrl is %"_LD_", however the configured maximum value for <nbytes> is %"_LD_") \n\n",(LONGX)MFRL_MAX,(LONGX)(ALLOMAXV-RECHSIZE));
1542#else
1543            printf("    (the maximum MFRmfrl is %"_LD_", however the configured maximum value for <nbytes> is %"_LD_") \n\n",(LONGX)MFRL_MAX,(LONGX)ALLOMAXV);
1544#endif
1545            printf(" echo maxmfrl=32767 >xcip \n");
1546            printf(" mx cipar=xcip bigrecsdb \n\n");
1547#if CIFS
1548            printf("cipar: ci_fststrip=<maxlen>^hcipar/ci_fststrip: strip <markup> marks during fst^xx \n\n");
1549/*          printf("cipar: ci_fststrip=<maxlen>[,<tags>] \n\n"); */
1550            printf("    <maxlen>        max mark length \n\n");
1551/*          printf("    <tags>          tag or comma separated tag list \n\n"); */
1552            printf("    defined in cipar or environment \n");
1553            printf("    strip any marks as <text> or </text> up to <maxlen> chars from all data fields \n");
1554            printf("    at the beggining of a FST execution (data fields are padded with blanks) \n\n");
1555            printf(" echo ci_fststrip=21 >xcip\n");
1556            printf(" mx cds \n");
1557            printf(" mfn=     1 \n");
1558            printf("  69  �Paper on: <plant physiology><plant transpiration><measurement and instruments>� \n");
1559            printf(" mx cipar=xcip cds \"fst=690 4 v69\" \n");
1560            printf(" mfn=     1 \n");
1561            printf("  69  �Paper on: <measurement and instruments>                                       � \n");
1562            printf(" 690  �PAPER^m1^o1^c1^l1� \n");
1563            printf(" 690  �ON^m1^o1^c2^l1� \n");
1564            printf(" 690  �MEASUREMENT^m1^o1^c3^l2� \n");
1565            printf(" 690  �AND^m1^o1^c4^l1� \n");
1566            printf(" 690  �INSTRUMENTS^m1^o1^c5^l2� \n");
1567#endif /* CIFS */
1568            printf("fst=<id> 2000+<it> <fmt>^uy^hfst/IT 2000 to extract text within <mark> and </mark>^xx \n\n");
1569            printf("    <id>            tag component \n");
1570            printf("    <it>            indexing technique 2000+IT (IT=0..8, 1000..1008) \n");
1571            printf("    <fmt>           format specification generating <dlm><mark><dlm><mark><text></mark> \n\n");
1572            printf("    apply indexing technique IT to text embedded in marks <mark> and </mark> \n\n");
1573            printf(" mx null \"fst=2 2004 '#<B>#','xxx <B>word1 word2</B> xxx'\" \n");
1574            printf(" mfn=     1 \n");
1575            printf("   2  �WORD^m1^o1^c1^l1� \n");
1576            printf("   2  �WORD^m1^o1^c2^l1� \n\n");
1577            printf("pft=_<tag>^uy^hpft=_ to input data from stdin^xx \n\n");
1578            printf("    <tag>           field tag \n\n");
1579            printf("    read a stdin input line and add the input data as a new occurrence of field <tag> \n\n");
1580            printf(" mx null \"proc=if mfn=1 then _10,putenv('TAG10='v10) fi\" pft=mfn,x1,getenv('TAG10'),/ to=2 \n");
1581            printf(" input line \n");
1582            printf(" 000001 input line \n");
1583            printf(" 000002 input line \n\n");
1584            printf("pft=getenv('cgi=',<varfmt>)^hpft=getenv('cgi='var) to get CGI data^xx \n\n");
1585            printf("    <varfmt>        format specification generating a cgi variable name \n\n");
1586            printf("    output the contents of the specified cgi variable \n");
1587            printf("    multiple occurrences are separeted by a %c char \n\n",'%');
1588            printf(" set REQUEST_METHOD=GET \n");
1589            printf(" set QUERY_STRING=db~cds&bool~plants*water&bool~another \n");
1590            printf(" mx null pft=getenv('cgi=db')/getenv('cgi=bool')/ \n");
1591            printf(" cds \n");
1592            printf(" plants*water%another \n\n");
1593            printf("pft=getenv('tmp=',[<pathfmt>])^hpft=getenv('tmp=') to get a temporary file name^xx \n\n");
1594            printf("    <pathfmt>       format specification generating a path name \n\n");
1595            printf("    get a temporary empty file name in the current working directory or in the specified path \n");
1596            printf("    if 'ci_tempdir' is specified then path is obtained from the following environment variables: ci_tempdir, temp, tmp \n\n");
1597            printf(" mx null pft=getenv('tmp=') \n");
1598            printf(" TMP1.$$$ \n\n");
1599            printf(" mx null pft=getenv('tmp=','ci_tempdir') \n");
1600            printf(" C:\\windows\\TEMP\\TMP1.$$$ \n\n");
1601            printf(" set ci_tempdir=C:\\work \n");
1602            printf(" mx null pft=getenv('tmp=','ci_tempdir') \n");
1603            printf(" C:\\work\\TMP1.$$$ \n\n");
1604            printf(" echo ci_tempdir=C:\\work2 >xcip \n");
1605            printf(" mx cipar=xcip null pft=getenv('tmp=','ci_tempdir') \n");
1606            printf(" C:\\work2\\TMP1.$$$ \n\n");
1607/*          printf("fst={<fst_spec>|@[<file>]} \n\n");
1608            printf("    <fst_spec>      fstspec or semicolon separated fstspec list \n");
1609            printf("    @               fstspec from standard file <dbn>.fst \n");
1610            printf("    @<file>         fstspec from file <file> \n\n");
1611            printf("    add extracted key+posting elements to data fields \n");
1612            printf("    tagged according fstspec specification \n\n");
1613*/
1614            printf("syntax^uy^hsyntax^xx \n\n");
1615            printf(" mx \n");
1616            mxsyntax("", ibufsiz/(1024*1024), ptabcategories/3, ptabwidth);
1617            MXEXIT(0);
1618        }
1619#endif /* WHATISNEW */
1620
1621    if (argc == 2 && strcmp(argv[1],"what") == 0) {
1622        printf("%s",cicopyr("?Utility MX"));
1623#if BEFORE20010109
1624        printf("\n");
1625        printf("MFRL=%"_LD_" FMT=%"_LD_" ",maxmfrl,fmtasize);
1626#endif
1627        printf("\n");
1628        MXEXIT(0);
1629    }
1630
1631    if (argc == 1) {
1632        mxsyntax("  ", ibufsiz/(1024*1024), ptabcategories/3, ptabwidth);
1633        MXEXIT(0);
1634    }
1635
1636
1637    p=argv[argnext];
1638    if (sscanf(p,"files=%2d",&n) == 1) {
1639#if OPEN30
1640    d33_regs.h.ah = 0x67;   /* Set handle count */
1641        d33_regs.x.bx = n;      /* no of handles */
1642#if 1 /* DOS32BITS */
1643        newax=intdosx(&d33_regs,&d33_regs,&d33_sregs);
1644#else
1645    newax=intdos(&d33_regs,&d33_regs);
1646#endif
1647        if (d33_regs.x.cflag)
1648            fprintf(stderr,"AX = %04x [%02d]\n",newax,n);
1649#endif
1650    argnext++;
1651    }
1652
1653#if DBXMSTXL
1654    p=NULL;
1655    for (i=argnext; i < argc; i++) if (strncmp(argv[i],"mstxl?",6) == 0 || strncmp(argv[i],"mstxl=",6) == 0) { p=argv[i]; break; }
1656    if (p) {
1657    }
1658#endif
1659
1660#if CIWTF                                /* WTFUN support */
1661    p=NULL;
1662    for (i=argnext; i < argc; i++) if (strncmp(argv[i],"cipar?",6) == 0 || strncmp(argv[i],"cipar=",6) == 0) { p=argv[i]; break; }
1663    /* setup wtfnew
1664    */
1665    if (!ciawtfp) if (p) if (*(p+6)) if (dbxciset(p+6)) fatal(p);
1666    if (!ciawtfp) if (dbxciset("mx.cip")) dbxciset(NULL); // optional mx.cip
1667    if (!ciawtfp) fatal("mx/ciawtfp");
1668    if (ciawtfp) maxmfrl=rec_maxmfrl; //maxmfrl local //fmt_fsiz set by dbxinit
1669#else //CIWTF
1670    /* forca carga de rec_maxmfrl */
1671    p=dbxcipar(NULL,"maxmfrl",'=');
1672    if (dbxcipok) { sscanf(p,"%"_LD_,&rec_maxmfrl); maxmfrl=rec_maxmfrl; }
1673    fmt_fsiz=maxmfrl;
1674/* printf("+++maxmfrl=%"_LD_"\n",maxmfrl); */
1675#endif //CIWTF
1676
1677    /*
1678        Parsing
1679    */
1680    for (i=argnext; (i < argc) || fpprm; ) {
1681
1682        /* get parameter */
1683
1684        if (fpprm) {
1685            p=fgets(prmbuff,PRMSIZE-1,fpprm);
1686            if (p) p[strlen(p)-1]='\0';  /* strip \n */
1687            else {
1688                fclose(fpprm);
1689                fpprm = (nfpprms-- > 0) ? vfpprm[nfpprms] : NULL;
1690                if (parmtrace) if (fpprm) printf("+++ in/pop= %p\n",fpprm);
1691                continue;
1692            }
1693        }
1694        else {
1695            if (i >= argc) fatal("i >= argc");
1696            p=argv[i++];
1697        }
1698
1699        n=strlen(p);
1700        q=p+n-1;
1701        for (; n; n--, p++) if (!isspace(*p)) break;                    /* leading */
1702        if (strncmp(p,"seq?",4) == 0 || strncmp(p,"seq=",4) == 0 || strncmp(p,"seq/",4) == 0) ;      /* "seq=x " */
1703        else for (; n; n--, q--) if (isspace(*q)) *q='\0'; else break;  /* trailing */
1704        if (n < 0) fatal("bug/parm");
1705        if (n == 0) continue;
1706#if MXCOMMENT
1707        if (*p == '/')   if (*(p+1) == '*')       { p+=2;  incomment=1; }
1708        if (incomment) {
1709            n=0;
1710            q=strstr(p,"*/");
1711            if (q) { p=q+2; incomment=0; n=strlen(p); }
1712            if (n == 0) continue;
1713        }
1714#endif /* MXCOMMENT */
1715        if (parmtrace) printf("+++ parm=%s !\n",p);
1716
1717
1718        if (nprms >= MAXNPRM) fatal("MAXNPRM overflow");
1719        if ((vprmp[nprms]=(PRMSTRU *)ALLOC((ALLOPARM)sizeof(PRMSTRU)))
1720                        == (PRMSTRU *)ALLONULL) fatal("ALLOC/prm/stru");
1721        vprmp[nprms]->plen=strlen(p);
1722        if ((vprmp[nprms]->p=(char *)ALLOC((ALLOPARM)(vprmp[nprms]->plen+1)))
1723                                == (char *)ALLONULL) fatal("ALLOC/prm/p");
1724        memcpy(vprmp[nprms]->p,p,vprmp[nprms]->plen+1); /* '\0' */
1725
1726        p=vprmp[nprms++]->p;
1727
1728
1729        /* in= parameter */
1730
1731        if (strncmp(p,"in?",3) == 0 || strncmp(p,"in=",3) == 0) {
1732            q=p+3;
1733            if (fpprm) {
1734                if (parmtrace) printf("+++ in/push=%p\n",fpprm);
1735                if (nfpprms >= MAXNFPRM) fatal(p);
1736                vfpprm[nfpprms++]=fpprm;
1737            }
1738            if (parmtrace) printf("+++ in/open=%s\n",q);
1739            if ((fpprm=fopen(dbxcipar(NULL,q,'='),"r")) == NULL)
1740                fatal(p);
1741            continue;
1742        }
1743
1744
1745        /* setup parameters */
1746
1747#if MXFULLINV || MXIFUPD
1748        if (strcmp(p,"-reset") == 0) {
1749            parmmenosreset=1;
1750            continue;
1751        }
1752#endif
1753#if MXFULLINV
1754        if (strcmp(p,"-balan") == 0) {
1755            fullinv_balan=0;
1756            continue;
1757        }
1758#endif
1759
1760        if (*p == '-') {
1761            minus1++;
1762            if (minus1 == 1) {
1763                parmcontrol=parmleader=parmxref=parmdir=parmfields=1;
1764            }
1765        }
1766        if (strcmp(p,"-all") == 0) {
1767            parmcontrol=parmleader=parmxref=parmdir=parmfields=0;
1768            continue;
1769        }
1770        if (strcmp(p,"-control") == 0) {
1771            parmcontrol=0;
1772            continue;
1773        }
1774        if (strcmp(p,"-leader") == 0) {
1775            parmleader=0;
1776            continue;
1777        }
1778        if (strcmp(p,"-xref") == 0) {
1779            parmxref=0;
1780            continue;
1781        }
1782        if (strcmp(p,"-dir") == 0) {
1783            parmdir=0;
1784            continue;
1785        }
1786        if (strcmp(p,"-fields") == 0) {
1787            parmfields=0;
1788            continue;
1789        }
1790
1791        if (strcmp(p,"+hits") == 0) {
1792            parmhits=1;
1793            continue;
1794        }
1795#if MXFST
1796        if (strcmp(p,"+fix") == 0) {
1797            cifstfix=1;
1798            continue;
1799        }
1800        if (strcmp(p,"+fix/m") == 0) {
1801            cifstfix=cifstfim=1;
1802            continue;
1803        }
1804#endif
1805        if (*p == '+') {
1806            plus1++;
1807            if (plus1 == 1)
1808                parmcontrol=parmleader=parmxref=parmdir=parmfields=0;
1809        }
1810        if (strcmp(p,"+all") == 0) {
1811            parmcontrol=parmleader=parmxref=parmdir=parmfields=1;
1812            continue;
1813        }
1814        if (strcmp(p,"+control") == 0) {
1815            parmcontrol=1;
1816            continue;
1817        }
1818        if (strcmp(p,"+leader") == 0) {
1819            parmleader=1;
1820            continue;
1821        }
1822        if (strcmp(p,"+xref") == 0) {
1823            parmxref=1;
1824            continue;
1825        }
1826        if (strcmp(p,"+dir") == 0) {
1827            parmdir=1;
1828            continue;
1829        }
1830        if (strcmp(p,"+fields") == 0) {
1831            parmfields=1;
1832            continue;
1833        }
1834        if (strncmp(p,"from?",5) == 0 || strncmp(p,"from=",5) == 0) {
1835            if (sscanf(p+5,"%"_LD_,&parmfrom) != 1)
1836                fatal(p);
1837            continue;
1838        }
1839        if (strncmp(p,"to?",3) == 0 || strncmp(p,"to=",3) == 0) {
1840            if (sscanf(p+3,"%"_LD_,&parmto) != 1)
1841                fatal(p);
1842            continue;
1843        }
1844        if (strncmp(p,"loop?",5) == 0 || strncmp(p,"loop=",5) == 0) {
1845            if (sscanf(p+5,"%"_LD_,&parmloop) != 1)
1846                fatal(p);
1847            continue;
1848        }
1849        if (strncmp(p,"count?",6) == 0 || strncmp(p,"count=",6) == 0) {
1850            if (sscanf(p+6,"%"_LD_,&parmcount) != 1)
1851                fatal(p);
1852            continue;
1853        }
1854        if (strncmp(p,"tell?",5) == 0 || strncmp(p,"tell=",5) == 0) {
1855            if (sscanf(p+5,"%"_LD_,&parmtell) != 1)
1856                fatal(p);
1857            continue;
1858        }
1859
1860        if (strcmp(p,"trace") == 0) {
1861            parmtrace=1;
1862            continue;
1863        }
1864        if (strcmp(p,"trace=dbx") == 0) {
1865            dbxtrace=1;
1866            continue;
1867        }
1868        if (strcmp(p,"trace=rec") == 0) {
1869            rectrace=dectrace=1;
1870            continue;
1871        }
1872        if (strcmp(p,"trace=dec") == 0) {
1873            dectrace=1;
1874            continue;
1875        }
1876        if (strcmp(p,"trace=trm") == 0) {
1877            trmtrace=1;
1878            continue;
1879        }
1880#if CIB71
1881        if (strcmp(p,"trace=b70") == 0) {
1882            b70trace=1;
1883            continue;
1884        }
1885#else /* CIB71 */
1886#if LIND || CIB64
1887        if (strcmp(p,"trace=b50") == 0) {
1888            b50trace=1;
1889            continue;
1890        }
1891#else
1892        if (strcmp(p,"trace=b40") == 0) {
1893
1894            b40trace=1;
1895            continue;
1896        }
1897#endif
1898#endif /* CIB71 */
1899        if (strcmp(p,"trace=fmt") == 0) {
1900            fmttrace=1;
1901            continue;
1902        }
1903        if (strcmp(p,"trace=fst") == 0) {
1904            fsttrace=1;
1905            continue;
1906        }
1907        if (strcmp(p,"trace=all") == 0) {
1908            parmtrace=dbxtrace=rectrace=trmtrace=
1909#if CIB71
1910        b70trace=
1911#else /* CIB71 */
1912#if LIND || CIB64
1913            b50trace=
1914#else
1915            b40trace=
1916#endif
1917#endif /* CIB71 */
1918        fmttrace=fsttrace=1;
1919            continue;
1920        }
1921
1922        if (strncmp(p,"cipar?",6) == 0 || strncmp(p,"cipar=",6) == 0) {
1923#if CIWTF                                /* WTFUN support */
1924#else //CIWTF
1925            if ((dbxcipfp=fopen(p+6,"r")) == NULL) fatal(p);
1926            /* forca carga de rec_maxmfrl */
1927            p=dbxcipar(NULL,"maxmfrl",'=');
1928            if (dbxcipok) { sscanf(p,"%"_LD_,&rec_maxmfrl); maxmfrl=rec_maxmfrl; }
1929            fmt_fsiz=maxmfrl;
1930#endif //CIWTF
1931            continue;
1932        }
1933
1934        if (strcmp(p,"mfrl") == 0) {
1935            parmmfrl=LEADER-1;
1936            continue;
1937        }
1938        if (strncmp(p,"mfrl?",5) == 0 || strncmp(p,"mfrl=",5) == 0) {
1939            if (sscanf(p+5,"%"_LD_,&maxmfrl) != 1)
1940                fatal(p);
1941#if CIWTF                                /* WTFUN support */
1942            if (maxmfrl < (LONGX)MSNVSPLT || (RECHSIZE+maxmfrl) > ALLOMAXV) maxmfrl=MAXMFRL;
1943            rec_maxmfrl=maxmfrl; // mx only
1944            fmt_fsiz=maxmfrl;    // mx only
1945#else //CIWTF
1946            if (maxmfrl > rec_maxmfrl) rec_maxmfrl=maxmfrl;
1947            fmt_fsiz=maxmfrl;
1948#endif //CIWTF
1949            continue;
1950        }
1951
1952#if BEFORE20060120 || 1  // tem que aceitar
1953        if (strncmp(p,"fmtl?",5) == 0 || strncmp(p,"fmtl=",5) == 0) {
1954            if (sscanf(p+5,"%"_LD_,&fmtasize) != 1)
1955                fatal(p);
1956            continue;
1957        }
1958#endif //BEFORE20060120
1959
1960        if (strncmp(p,"load?",5) == 0 || strncmp(p,"load=",5) == 0) {
1961            if (sscanf(p+5,"%"_LD_,&parmload) != 1)
1962                fatal(p);
1963            if (parmload > ALLOMAXV) {
1964                parmload = ALLOMAXV;
1965                fprintf(stderr,"+++ load=%"_LD_"\n",parmload);
1966            }
1967            continue;
1968        }
1969
1970        if (strncmp(p,"pages?",6) == 0 || strncmp(p,"pages=",6) == 0) {
1971            /* NXPAGES */
1972            p=p+6;
1973            for (level=0; level < MAXLIV; level++)
1974                if (*p)
1975                    if (atoi(p)) {
1976                        NXPAGES[level]=atoi(p);
1977                        if (parmtrace)
1978                            printf("+++ level %d = %d pages\n",
1979                                level,NXPAGES[level]);
1980                        while (isdigit(*p)) p++;
1981                        if (*p == ',') p++;
1982                    }
1983            continue;
1984        }
1985
1986#if CIB71
1987        if (strncmp(p,"b70?",4) == 0 || strncmp(p,"b70=",4) == 0 ||
1988            strncmp(p,"b50?",4) == 0 || strncmp(p,"b50=",4) == 0 ||
1989            strncmp(p,"b40?",4) == 0 || strncmp(p,"b40=",4) == 0 ||
1990            strncmp(p,"tmpx?",5) == 0 || strncmp(p,"tmpx=",5) == 0) {
1991#endif /* CIB71 */
1992            /* mxbool/b40 query data base */
1993            if (strncmp(p,"tmpx?",5) == 0 || strncmp(p,"tmpx=",5) == 0) booldbnp=p+5; else booldbnp=p+4;
1994            if (strncmp(booldbnp,"create=",7) == 0) {
1995                booldbnp+=7;
1996                recisis0(booldbnp);
1997            }
1998            continue;
1999        }
2000#if CIB71
2001#else /* CIB71 */
2002#if LIND || CIB64
2003        if (strncmp(p,"nb1?",4) == 0 || strncmp(p,"nb1=",4) == 0) {
2004            /* mxbool/b62 nbytes1 parm [b5irxbytes=nbytes1;] */
2005            if (sscanf(p+4,"%"_LD_,&boolnby1) != 1)
2006                fatal(p);
2007            continue;
2008        }
2009        if (strncmp(p,"nbb?",4) == 0 || strncmp(p,"nbb=",4) == 0) {
2010            /* mxbool/b62 b6bufferp->bufsiz parm [b6_hballoc(bufsiz,&b6bufferp);] */
2011            if (sscanf(p+4,"%"_LD_,&boolnbyb) != 1)
2012                fatal(p);
2013            continue;
2014        }
2015        if (strncmp(p,"nb0?",4) == 0 || strncmp(p,"nb0=",4) == 0) {
2016            /* mxbool/b62 b5maxbyts0 parm [if (b5maxbyts0) b5maxbyts=b5maxbyts0;] */
2017            if (sscanf(p+4,"%"_LD_,&boolnby0) != 1)
2018                fatal(p);
2019            continue;
2020        }
2021#else
2022        if (strncmp(p,"nb2?",4) == 0 || strncmp(p,"nb2=",4) == 0) {
2023            /* mxbool/b40 nbytes2 parm */
2024            if (sscanf(p+4,"%"_LD_,&boolnby2) != 1)
2025                fatal(p);
2026            continue;
2027        }
2028#endif
2029#endif /* CIB71 */
2030        if (strncmp(p,"btell?",6) == 0 || strncmp(p,"btell=",6) == 0) {
2031            /* mxbool/b40 tell parm */
2032            if (sscanf(p+6,"%"_LD_,&booltell) != 1)
2033                fatal(p);
2034            continue;
2035        }
2036#if CIB71
2037#else /* CIB71 */
2038#if LIND || CIB64
2039#if 000
2040        if (strncmp(p,"b50t?",5) == 0 || strncmp(p,"b50t=",5) == 0) {
2041            /* mxbool/b5_run() tmp file name */
2042            strcpy(b5_tmpnam,p+5);
2043            continue;
2044        }
2045#endif
2046#else
2047        if (strncmp(p,"b40t?",5) == 0 || strncmp(p,"b40t=",5) == 0) {
2048            /* mxbool/b4_run() tmp file name */
2049            strcpy(b4_tmpnam,p+5);
2050            continue;
2051        }
2052#endif
2053#endif /* CIB71 */
2054        if (strncmp(p,"b40u?",5) == 0 || strncmp(p,"b40u=",5) == 0) {
2055            /* loaductb(mi_gidbnp,isisuctab,p+5); */
2056            if (!loaductb(mi_gidbnp,isisuctab,p+5)) fatal(p); /* AOT, 02/04/2001 */
2057            continue;
2058        }
2059
2060        if (strncmp(p,"uctab?",6) == 0 || strncmp(p,"uctab=",6) == 0) {
2061            if (strcmp(p+6,"ansi") == 0) {
2062                memcpy(isisuctab,ansiuctab,256/*sizeof(ansiuctab)*/);
2063            } else {
2064                /* loaductb(mi_gidbnp,isisuctab,p+6); */
2065                if (!loaductb(mi_gidbnp,isisuctab,p+6)) fatal(p); /* AOT, 02/04/2001 */
2066            }
2067            continue;
2068        }
2069        if (strncmp(p,"actab?",6) == 0 || strncmp(p,"actab=",6) == 0) {
2070            memset(isiswctab,0x00,256);
2071            if (strcmp(p+6,"ansi") == 0) {
2072                for (isiswctot=0; ansiactab[isiswctot]; isiswctot=isiswctot+1)
2073                    isiswctab[ansiactab[isiswctot]]=1;
2074            } else {
2075                unsigned char ubuffup[256];
2076                /* loadactb(mi_gidbnp,ubuffup,p+6); */
2077                if (!loadactb(mi_gidbnp,ubuffup,p+6)) fatal(p); /* AOT, 02/04/2001 */
2078                for (isiswctot=0; ubuffup[isiswctot]; isiswctot=isiswctot+1)
2079                    isiswctab[ubuffup[isiswctot]]=1;
2080            }
2081            continue;
2082        }
2083
2084        if (strncmp(p,"dupr?",5) == 0 || strncmp(p,"dupr=",5) == 0 ||
2085            strncmp(p,"dupl?",5) == 0 || strncmp(p,"dupl=",5) == 0) {
2086            parmdupp=p+5;
2087            parmdupx=DUPPRIGHT;
2088            if (strncmp(p,"dupl",5-1) == 0)
2089                parmdupx=DUPPLEFT;
2090            continue;
2091        }
2092
2093        if (strncmp(p,"p1?",3) == 0 || strncmp(p,"p1=",3) == 0) {
2094            prompt1p=p+3;
2095            continue;
2096        }
2097        if (strncmp(p,"p2?",3) == 0 || strncmp(p,"p2=",3) == 0) {
2098            prompt2p=p+3;
2099            continue;
2100        }
2101
2102        if (strcmp(p,"nowait") == 0 || strcmp(p,"now") == 0) {
2103            parmwait=0;
2104            continue;
2105        }
2106
2107#if BEFORE20000323           /* because some BRM's GCC - ask rpiva */
2108        if (strcmp(p,"stderr=off") == 0) {
2109            cistderr=stdout;
2110            continue;
2111        }
2112#endif
2113
2114#if MULTI
2115        if (strcmp(p,"mono") == 0) {
2116            cipnetws=MONONETS;
2117            continue;
2118        }
2119        if (strcmp(p,"mast") == 0) {
2120            cipnetws=MASTNETS;
2121            continue;
2122        }
2123        if (strcmp(p,"full") == 0) {
2124            cipnetws=FULLNETS;
2125            continue;
2126        }
2127#endif
2128        if (strncmp(p,"k1=",3) == 0) {
2129            parmk1p=p+3;
2130            continue;
2131        }
2132        if (strncmp(p,"k2=",3) == 0) {
2133            parmk2p=p+3;
2134            continue;
2135        }
2136
2137
2138#if CIWTF
2139#else //CIWTF
2140        /* setup alloc
2141        */
2142        q=dbxcipar(NULL,"maxmfrl",'='); if (dbxcipok) sscanf(q,"%"_LD_,&maxmfrl);
2143        if (maxmfrl < (LONGX)MSNVSPLT || (RECHSIZE+maxmfrl) > ALLOMAXV) maxmfrl=MAXMFRL;
2144        rec_maxmfrl=maxmfrl;
2145        fmt_fsiz=maxmfrl;
2146#endif //CIWTF
2147
2148
2149        /* positional parameters */
2150
2151        if (!dbnp) {
2152
2153            /* allocate global buffer (former buffup, which is defined by mxrun.h) */
2154            nbytes = (mx_buplen) ? mx_buplen: maxmfrl+maxmfrl;
2155            if (nbytes > ALLOMAXV) nbytes=ALLOMAXV;
2156            mx_buplen=nbytes;
2157            if (parmtrace) printf("+++ mx_bup=%"_LD_" bytes\n",mx_buplen);
2158            if ((mx_bup=(char *)ALLOC((ALLOPARM)nbytes)) == (char *)ALLONULL)
2159                fatal("ALLOC/mx_bup");
2160
2161            recallok((crec=nrecs),(LONGX)sizeof(M0STRU));
2162            recallok((irec=nrecs),maxmfrl); /* b40 */
2163
2164            if (strncmp(p,"db=",3) == 0) p+=3;
2165            if (strncmp(p,"dbn=",4) == 0) p+=4;
2166
2167            /* allow mx <dbn>.mst */
2168            if (strlen(p)>strlen(mx1extp)) {
2169                int len=strlen(p);
2170                int n=strlen(mx1extp);
2171                if (memicmp(p+len-n,mx1extp,n) == 0) p[len-n]='\0';
2172            }
2173
2174#if DIR_FILE
2175            if (strncmp(p,"list=",5) == 0) {
2176                char *directory=p+5;
2177              //char *pattern=NULL,*q,c='\0';
2178              //for (q=directory; *q; q++) if (*q='/') pattern=q+1;
2179              //if (pattern) if (!*pattern) pattern=NULL; 
2180              //if (pattern) { c=(*pattern); *pattern='\0'; }
2181                direntdp = opendir (directory);
2182              //if (pattern) *pattern=c;
2183                if (direntdp != NULL)
2184                {
2185                    //char *q; int n,x;
2186                  //while ((direntep = readdir (direntdp)) != NULL)
2187                  //{
2188                //    int x=1;
2189                //    if (pattern) {
2190                //      char *q=(char *)direntep->d_name;
2191                //      int n=strlen(q);
2192                //      if (strcmp(q+n-strlen(".mak"),".mak")) x=0;
2193                //    }
2194                //    if (x)
2195                  //  puts (direntep->d_name);
2196                  //}
2197                  //(void) closedir (direntdp);
2198                }
2199                else
2200                //fatal("Couldn't open the directory");
2201                  fatal(p);
2202                tmpseq=1;
2203            }
2204#endif
2205
2206            if (strncmp(p,"dict=",5) == 0) {
2207                xtp=p; p+=5;
2208                parmkdbnp=p; p="null";
2209                if ((q=strchr(parmkdbnp,',')) != NULL) {
2210                    *q++='\0';
2211                    if (sscanf(q,"%"_LD_,&xtl1) != 1) fatal(xtp);
2212                    parmktag1=(UWORD)xtl1;
2213                    while (isdigit(*q)) q++;
2214                    if (*q) {
2215                        if (*q++ != ',') fatal(xtp);
2216                        if (sscanf(q,"%"_LD_,&xtl2) != 1) fatal(xtp);
2217                        parmktag2=(UWORD)xtl2;
2218                        while (isdigit(*q)) q++;
2219                        if (*q == '/') { q++;
2220                            if (sscanf(q,"%"_LD_,&parmkkeep2) != 1) fatal(xtp);
2221                            if (parmkkeep2 < 1) fatal(xtp);
2222                            /*while (isdigit(*q)) q++; */
2223                        }
2224                        parmkpostings=1;
2225                    }
2226                }
2227            }
2228
2229            if (strcmp(p,"tmp") == 0) {
2230                tmpseq=1;
2231            }
2232            else {
2233                if (strncmp(p,"seq?",4) == 0 || strncmp(p,"seq=",4) == 0 || strncmp(p,"seq/",4) == 0) {
2234                    unsigned blass=0;
2235                    unsigned blas2=0;
2236                    q=p+4;
2237                    if (strncmp(p,"seq/",4) == 0) {
2238                        p+=3; //skip seq
2239                        while (*p == '/') {
2240                            if (strncmp(p,"/fi:"   ,4) == 0) { for (p+=4; isdigit(*p); p++) blas2=blas2*10+((int)(*p)-(int)'0'); continue; }
2241                            for (p++; isdigit(*p); p++) blass=blass*10+((int)(*p)-(int)'0');
2242                            if (*p=='k')   p++;
2243                            if (*p=='m') { p++; blass*=1024; }
2244                        } /* while /option */
2245                        if (*p == '?' || *p == '=') p++; else fatal(q-4);
2246                        if (parmtrace) printf("+++ ibufsiz=%"_LD_" Kbytes log=%"_LD_"\n",(LONGX)blass,(LONGX)blas2);
2247                        if (blass>=1) ibufsiz=blass*1024;
2248                        if (blas2>=1) parmseqlog=blas2;
2249                        q=p;
2250                    }
2251                    strcpy(line,q);
2252                    q=line+strlen(line)-1; parmxseq='\0';
2253                    if (strlen(line) > 1) {
2254                        if (*(q-1) == '\\') { parmxseq= *q; if (*q == 'n') parmxseq='\n'; *(q-1)='\0'; }
2255                    }
2256                    if (!parmxseq) if (!isalnum(*q)) {parmxseq= *q; *q='\0';}
2257                    if (parmtrace) printf("+++ %s|=%02x=%c\n",line,parmxseq,parmxseq);
2258                    tmpseq=1;
2259                    if (strcmp(line,"con") == 0) fpseq=stdin; else
2260#if BEFORE20060308
2261                    if ((fpseq=fopen(dbxcipar(NULL,line,'='),"r")) == NULL) fatal(p);
2262#else
2263                    {
2264                        n1fdseq=0;
2265                        n1left=0;
2266                        n1iptr=NULL;
2267                        n1count=0;
2268                        /* allocate input buffer */
2269                        obufsiz=(mx_buplen-4-BUFSIZ)/2;  ubufsiz=obufsiz+BUFSIZ;
2270                        obuf=mx_bup; ubuf=obuf+obufsiz+2;
2271                        if (parmtrace) printf("+++ ibuf=%"_LD_" bytes\n",(LONGX)ibufsiz);
2272                        if ((ibuf=(char *)ALLOC((ALLOPARM)ibufsiz+1)) == (char *)ALLONULL) fatal("ALLOC/ibuf");
2273                        if (recfgetseq(line, parmxseq, parmseqlog, ibuf, ibufsiz, obuf,       0, ubuf, ubufsiz, &n1fdseq, &n1left, &n1iptr, &n1count) <= 0) fatal(p);
2274                    }
2275#endif
2276                }
2277#if XML_FILE
2278                else {
2279                    if (strncmp(p,"xml?",4) == 0 || strncmp(p,"xml=",4) == 0 || strncmp(p,"xml/",4) == 0) {
2280                        unsigned blass=0;
2281                        unsigned blas2=0;
2282                        q=p+4;
2283                        if (strncmp(p,"xml/",4) == 0) {
2284                            p+=3; //skip seq
2285                            while (*p == '/') {
2286                                if (strncmp(p,"/fi:"   ,4) == 0) { for (p+=4; isdigit(*p); p++) blas2=blas2*10+((int)(*p)-(int)'0'); continue; }
2287                                for (p++; isdigit(*p); p++) blass=blass*10+((int)(*p)-(int)'0');
2288                                if (*p=='k')   p++;
2289                                if (*p=='m') { p++; blass*=1024; }
2290                            } /* while /option */
2291                            if (*p == '?' || *p == '=') p++; else fatal(q-4);
2292                            if (parmtrace) printf("+++ ibufsiz=%"_LD_" Kbytes log=%"_LD_"\n",(LONGX)blass,(LONGX)blas2);
2293                            if (blass>=1) ibufsiz=blass*1024;
2294                            if (blas2>=1) parmseqlog=blas2;
2295                            q=p;
2296                        }
2297                        p = strchr(p, ',');
2298                        if (!p) fatal("missing ,");
2299                        *p = '\0'; p++;
2300                        strcpy(tagName, p);
2301                        strcpy(line,q);
2302                        q=line+strlen(line)-1; parmxseq='\0';
2303                        if (strlen(line) > 1) {
2304                            if (*(q-1) == '\\') { parmxseq= *q; if (*q == 'n') parmxseq='\n'; *(q-1)='\0'; }
2305                        }
2306                        if (!parmxseq) if (!isalnum(*q)) {parmxseq= *q; *q='\0';}
2307                        if (parmtrace) printf("+++ %s|=%02x=%c\n",line,parmxseq,parmxseq);
2308                        tmpseq=1;
2309                        n1fdxml=0;
2310                        n1left=0;
2311                        n1iptr=NULL;
2312                        n1count=0;
2313                        /* allocate input buffer */
2314                        obufsiz=(mx_buplen-4-BUFSIZ)/2;  ubufsiz=obufsiz+BUFSIZ;
2315                        obuf=mx_bup; ubuf=obuf+obufsiz+2;
2316                        if (parmtrace) printf("+++ ibuf=%"_LD_" bytes\n",(LONGX)ibufsiz);
2317                        if ((ibuf=(char *)ALLOC((ALLOPARM)ibufsiz+1)) == (char *)ALLONULL) fatal("ALLOC/ibuf");
2318                        if (recfgetxml(line, ibuf, ibufsiz, obuf,       0, ubuf, ubufsiz, &n1fdxml, &n1left, &n1iptr, &n1count) <= 0) fatal(p);
2319                    }
2320#endif /* XML_FILE */
2321                else {
2322                    if (strncmp(p,"iso?",4) == 0 || strncmp(p,"iso=",4) == 0) {
2323                        q=p+4;
2324                        if (strchr(q,'=')) {
2325                            if (strncmp(q,"marc=",5) == 0) {  /* AOT, 06/06/2005 */
2326                                q+=5;
2327                                isfix=(-1);    /*  no CRLF */
2328                                lrfix=ISOBSIZ; /* set to max line len */
2329                                iso_ismarc=1;
2330                            }
2331                            else
2332                            if (strncmp(q,"0=",2) == 0) {    /* AOT, 06/06/2005 */
2333                                q+=2;
2334                                isfix=0;      /*  single line */
2335                                lrfix=ISOBSIZ;
2336                            }
2337                            else {
2338                                if (sscanf(q,"%d=%s",&lrfix,line) != 2) fatal(p);
2339                                q=strchr(q,'=')+1;
2340                                isfix=1;
2341                            }
2342                        }
2343                        else
2344#if MPE
2345                            { isfix=1; lrfix=80; }
2346#else
2347                            { isfix=0; lrfix=80; }
2348#endif
2349                        if (iso_open(NULL,q,0,lrfix,isfix) <= 0) fatal(p);
2350                        parmiso1=1;
2351                        tmpseq=1;
2352                    }
2353                    else if (parmkdbnp) {
2354                             mi_gidbnp=parmkdbnp; dbnp="null";
2355                         }
2356                         else mi_gidbnp=dbnp=p;
2357                }
2358#if XML_FILE
2359                }
2360#endif /* XML_FILE */
2361            }
2362
2363#if DELETETMPSEQ
2364            if (tmpseq) recisis0(dbnp="tmpseq");
2365#else
2366            if (tmpseq) dbnp="null";
2367#endif
2368
2369            if (parmload) mstsetup(dbnp,parmload,parmload);        /* invsetup is called in mxbol()/mj_join() */
2370
2371            if (parmtrace) printf("+++ RECORD %"_LD_" = %s#%"_LD_" \n",crec,dbnp,0L);
2372            RECORD(crec,dbnp,0L);
2373
2374            if (parmtrace) printf("+++ RECORD %"_LD_" = %s#%"_LD_" \n",irec,dbnp,1L);
2375            RECORD(irec,dbnp,1L);
2376
2377            continue;
2378
2379        } /* end okdbnp */
2380
2381
2382
2383        /* processing parameters */
2384
2385        if (!dbnp) fatal(p);
2386
2387#if IFUPDATE
2388        if (strcmp(p,"mfbw") == 0) { parmmfbw=1; continue; }
2389#endif
2390
2391#if TB
2392        if (strncmp(p,"tb?",3) == 0 || strncmp(p,"tb=",3) == 0 ||
2393            strncmp(p,"tbin?",5) == 0 || strncmp(p,"tbin=",5) == 0) {
2394            if (strncmp(p,"tb?",3) == 0 || strncmp(p,"tb=",3) == 0) q=p+3; else q=p+5;
2395            if (sscanf(q,"%"_LD_,&ld) != 1) fatal(p);
2396             if (ntagbin >= MAXTBIN) fatal(p);
2397            tagbin=(UWORD)ld; vtagbin[ntagbin++]=tagbin;
2398            continue;
2399        }
2400#endif /* TB */
2401
2402        if (strncmp(p,"join?",5) == 0 || strncmp(p,"join=",5) == 0 ||
2403            strncmp(p,"jchk?",5) == 0 || strncmp(p,"jchk=",5) == 0 ||
2404            strncmp(p,"jch0?",5) == 0 || strncmp(p,"jch0=",5) == 0 ||
2405            strncmp(p,"jch1?",5) == 0 || strncmp(p,"jch1=",5) == 0) {
2406
2407            jchk=0;
2408            if (strncmp(p,"jchk",5-1) == 0)
2409                jchk=1;
2410            if (strncmp(p,"jch0",5-1) == 0)
2411                jchk= -1;
2412            if (strncmp(p,"jch1",5-1) == 0)
2413                jchk= -2;
2414
2415            *line='\0';
2416            for (q=p+5, n=0; *q; q++, n++)
2417                if (*q == '?' || *q == '=') {
2418                    memcpy(line,p+5,n); line[n]='\0';
2419                    break;
2420                }
2421            if (!*line || !*(q+1))
2422                fatal(p);
2423            if (mj_scan(xmxp,dbnp,line,q+1,jchk)) MXEXIT(1);
2424            continue;
2425        }
2426        if (strncmp(p,"jmax?",5) == 0 || strncmp(p,"jmax=",5) == 0) {
2427            /* mj_join() */
2428            if (sscanf(p+5,"%"_LD_,&mj_jmax) != 1)
2429                fatal(p);
2430            continue;
2431        }
2432        if (strncmp(p,"jtag?",5) == 0 || strncmp(p,"jtag=",5) == 0) {
2433            /* mj_join() */
2434            if (sscanf(p+5,"%"_LD_,&ld) != 1)
2435                fatal(p);
2436            mj_jtag=(UWORD)ld;
2437            continue;
2438        }
2439
2440        if (strncmp(p,"xxxx?",5) == 0 || strncmp(p,"xxxx=",5) == 0 ||
2441            strncmp(p,"proc?",5) == 0 || strncmp(p,"proc=",5) == 0) {
2442            q=p+5;
2443            if (!*q)
2444                fatal(p);
2445            if (mp_scan(xmxp,dbnp,q)) MXEXIT(1);
2446            continue;
2447        }
2448
2449        if (strncmp(p,"convert?",8) == 0 || strncmp(p,"convert=",8) == 0) {
2450            if (strcmp(p+8,"ansi") == 0) {
2451                tabconvp=ansimctab; /* asc2ansi */
2452                memcpy(isisuctab,ansiuctab,256/*sizeof(ansiuctab)*/);
2453                for (isiswctot=0; ansiactab[isiswctot]; isiswctot=isiswctot+1)
2454                    isiswctab[ansiactab[isiswctot]]=1;
2455                continue;
2456            }
2457            if (strcmp(p+8,"arab") == 0) {
2458                tabconvp=arabmctab; /* 708_1256 */
2459                continue;
2460            }
2461            fatal(p);
2462        }
2463
2464#if RECDECO
2465        if (strncmp(p,"decod?",6) == 0 || strncmp(p,"decod=",6) == 0) {
2466            recdecod(irec,p+6,(upirec)?upirec:(upirec=nrecs));
2467            continue;
2468        }
2469#endif
2470
2471#if RECGIZM
2472#if MXGIZP
2473        if (strncmp(p,"gizp?",5) == 0 || strncmp(p,"gizp=",5) == 0) {
2474            parmgizp=p+5;
2475            continue;
2476        }
2477        if (strncmp(p,"gizp/h?",7) == 0 || strncmp(p,"gizp/h=",7) == 0) {
2478            parmgizp=p+7;
2479            parmgizhp=1;
2480            continue;
2481        }
2482#endif
2483        if (strncmp(p,"gizmo?",6) == 0 || strncmp(p,"gizmo=",6) == 0 ||
2484            strncmp(p,"giz1?",5) == 0 || strncmp(p,"giz1=",5) == 0 ||
2485            strncmp(p,"giz2?",5) == 0 || strncmp(p,"giz2=",5) == 0) {
2486            if (strncmp(p,"gizmo?",6) == 0 || strncmp(p,"gizmo=",6) == 0)
2487                q=p+6;
2488            else
2489                q=p+5;
2490            if (!*q) fatal(p);
2491
2492            if (RDBvgzrp) {     /* gizmo already defined */
2493                for (gizmap=RDBvgzrp; gizmap->nextp; )
2494                    gizmap=gizmap->nextp;
2495                gizmread(q,&gizmap->nextp,(upirec)?upirec:(upirec=nrecs));
2496                gizmap=gizmap->nextp;
2497            }
2498            else {              /* first gizmo definition */
2499                gizmread(q,&RDBvgzrp,(upirec)?upirec:(upirec=nrecs));
2500            }
2501
2502            if (parmtrace) {
2503                for (gizmap=RDBvgzrp; gizmap; gizmap=gizmap->nextp)
2504                    printf("+++ gizmo=%s \n",gizmap->gdbnp);
2505            }
2506            continue;
2507        }
2508#endif /* RECGIZM */
2509
2510#if RECXPND
2511        if (strncmp(p,"putdir?",7) == 0 || strncmp(p,"putdir=",7) == 0) {
2512            if (sscanf(p+7,"%d,%d",&parmxpn01,&parmxpn02) != 2)
2513                fatal(p);                       /* recxpn00() tag,dlm */
2514            continue;
2515        }
2516        if (strncmp(p,"getdir?",7) == 0 || strncmp(p,"getdir=",7) == 0) {
2517            if (sscanf(p+7,"%d,%d",&RDBxpn01,&RDBxpn02) != 2)
2518                fatal(p);                       /* recxpnmo() */
2519            continue;
2520        }
2521#endif
2522
2523        if (strncmp(p,"sys?",4) == 0 || strncmp(p,"sys=",4) == 0 ||
2524            strncmp(p,"sys/show?",9) == 0 ||
2525            strncmp(p,"sys/show=",9) == 0) {
2526            p+=4;
2527            if (strncmp(p,"show",5-1) == 0) {
2528                p+=5; parmsyss=1;
2529            }
2530            parmsysp=loadfile(dbnp,'@',p,NULL,fmtasize+1,'\0');
2531        if (!parmsysp) fatal(p);
2532            parmfields=0;
2533            continue;
2534        }
2535
2536        if (strncmp(p,"text?",5) == 0 || strncmp(p,"text=",5) == 0 ||
2537            strncmp(p,"text/show?",10) == 0 ||
2538            strncmp(p,"text/show=",10) == 0) {
2539            p+=5;
2540            if (strncmp(p,"show",5-1) == 0) {
2541                p+=5;
2542                mxtext_pshow=1; parmfields=0;
2543            }
2544            parmtextp=p;
2545            continue;
2546        }
2547
2548        if (strncmp(p,"outmfntag?",10) == 0 || strncmp(p,"outmfntag=",10) == 0) {
2549            if (sscanf(p+10,"%d",&parmoutmfntag) != 1)
2550                fatal(p);
2551            continue;
2552        }
2553        if (strncmp(p,"lw?",3) == 0 || strncmp(p,"lw=",3) == 0) {
2554            if (sscanf(p+3,"%"_LD_,&fmtlw) != 1)
2555                fatal(p);
2556            continue;
2557        }
2558
2559        if (strncmp(p,"pft?",4) == 0 || strncmp(p,"pft=",4) == 0 ||
2560            strncmp(p,"tab?",4) == 0 || strncmp(p,"tab=",4) == 0 || strncmp(p,"tab/",4) == 0) {
2561            int parmtabula=0;
2562            q=p+4;
2563            if (strncmp(p,"tab?",4) == 0 || strncmp(p,"tab=",4) == 0 || strncmp(p,"tab/",4) == 0) {
2564                parmtabula=1; fmtlw=0; //5.2
2565                if (strncmp(p,"tab/",4) == 0) {
2566                    unsigned class=0;
2567                    unsigned width=0;
2568                    unsigned tabtg=0;
2569                    p+=3; //skip tab
2570                    while (*p == '/') {
2571                        if (strncmp(p,"/lines:",7) == 0) { for (p+=7; isdigit(*p); p++) class=class*10+((int)(*p)-(int)'0'); if (class<1) fatal(p); }
2572                        else
2573                        if (strncmp(p,"/width:",7) == 0) { for (p+=7; isdigit(*p); p++) width=width*10+((int)(*p)-(int)'0'); if (width<1) fatal(p); }
2574                        else
2575                        if (strncmp(p,"/tab:"  ,5) == 0) { for (p+=5; isdigit(*p); p++) tabtg=tabtg*10+((int)(*p)-(int)'0'); if (tabtg<1) fatal(p); }
2576                        else fatal(q-4);
2577                    } /* while /option */
2578                    if (*p == '?' || *p == '=') p++; else fatal(q-4);
2579                    if (parmtrace) printf("+++ tab class=%"_LD_" width=%"_LD_"\n",(LONGX)class,(LONGX)width);
2580                    if (class > 0) ptabcategories=(LONGX)class*3; // hashing;
2581                    if (width > 0) ptabwidth=(int)width;
2582                    if (tabtg > 0) parmtabtg=tabtg;
2583                    q=p;
2584                }
2585                if (parmtrace) printf("+++ tab class=%"_LD_" width=%"_LD_" tabtg=%"_LD_"\n",(LONGX)ptabcategories,(LONGX)ptabwidth,(LONGX)parmtabtg);
2586            }
2587            if (strcmp(q,"@") == 0) sprintf(q=mx_bup,"@%s.pft",dbnp);
2588            fmtarea=loadfile(dbnp,'@',q,fmtarea,fmtasize+1,'\0');
2589            if (!fmtarea) fatal(q);
2590            q=fmtarea;
2591            if (parmtrace) {
2592                printf("+++ fmt=%c",OPENFCHR); printf("%s",q);
2593                printf("%c ..",CLOSFCHR); if (getchar() != '\n') MXEXIT(0);
2594            }
2595            if (!*q) fatal(p);
2596            if (fmt_gener(&pgmp,q)) {
2597                fprintf(stderr,"*** fmt_error=%"_LD_"\n",fmt_error);
2598                fatal(q+fmt_errof);
2599            }
2600            parmfields=0;
2601            if (parmtabula) {
2602                /* calculate maxprim and allocate/zero hash table */
2603                LONGX maxprim;
2604                ptabtable=hashalloc(ptabcategories,ptabwidth,&maxprim);
2605                ptabmaxprim=maxprim;
2606                if (parmtrace) printf("+++ hash=%"_LD_"\n",ptabmaxprim);
2607                /* allocate/zero frequencies */
2608                ptabCOUNT=     (LONGX *) loadfile(NULL,'@',"",NULL, ptabmaxprim*sizeof(LONGX),   '\0');
2609            }
2610            continue;
2611        }
2612
2613
2614        if (strncmp(p,"jdi?",4) == 0 || strncmp(p,"jdi=",4) == 0 || strncmp(p,"jdi/",4) == 0) {
2615            p+=3; //skip jdi
2616            while (*p == '/') {
2617                q=p;
2618                if (isdigit(*(p+1))            ) { for (p+=1, jdiadd55=0; isdigit(*p); p++) jdiadd55=jdiadd55*10+((int)(*p)-(int)'0'); if (jdiadd55<0) fatal(p); }
2619                else
2620                if (strncmp(p,"/lines:",7) == 0) { for (p+=7, jdiclass=0; isdigit(*p); p++) jdiclass=jdiclass*10+((int)(*p)-(int)'0'); if (jdiclass<1) fatal(p); }
2621                else
2622                if (strncmp(p,"/width:",7) == 0) { for (p+=7, jdiwidth=0; isdigit(*p); p++) jdiwidth=jdiwidth*10+((int)(*p)-(int)'0'); if (jdiwidth<1) fatal(p); }
2623                else
2624                if (strncmp(p,"/tab:"  ,5) == 0) { for (p+=5, jditabtg=0; isdigit(*p); p++) jditabtg=jditabtg*10+((int)(*p)-(int)'0'); if (jditabtg<1) fatal(p); }
2625                else
2626                if (strncmp(p,"/occ:"  ,5) == 0) { for (p+=5, jditaboc=0; isdigit(*p); p++) jditaboc=jditaboc*10+((int)(*p)-(int)'0'); if (jditaboc<1) fatal(p); }
2627                else
2628                if (strncmp(p,"/top:"  ,5) == 0) { for (p+=5, jdisstop=0; isdigit(*p); p++) jdisstop=jdisstop*10+((int)(*p)-(int)'0'); if (jdisstop<1) fatal(p); }
2629                else
2630                if (strncmp(p,"/nmin:" ,6) == 0) { for (p+=6, jdisminn=0; isdigit(*p); p++) jdisminn=jdisminn*10+((int)(*p)-(int)'0'); if (jdisminn<1) fatal(p); }
2631                else
2632                if (strncmp(p,"/wmin:"    ,6) == 0) { p+=6; if (sscanf(p,"%f",&jdisminw) != 1) fatal(p); while (isdigit(*p) || *p=='.') p++; }
2633                else
2634                if (strncmp(p,"/vmin:"    ,6) == 0) { p+=6; if (sscanf(p,"%f",&jdisminv) != 1) fatal(p); while (isdigit(*p) || *p=='.') p++; }
2635                else
2636                if (strncmp(p,"/show"     ,5) == 0) { p+=5; jdipshow=1; parmfields=0; }
2637                else
2638                if (strncmp(p,"/sort:w1"  ,8) == 0) { p+=8; jdisort=JDISORTW1; }
2639                else
2640                if (strncmp(p,"/sort:w2"  ,8) == 0) { p+=8; jdisort=JDISORTW2; }
2641                else
2642                if (strncmp(p,"/sort:w3"  ,8) == 0) { p+=8; jdisort=JDISORTW3; }
2643                else
2644                if (strncmp(p,"/sort:w4"  ,8) == 0) { p+=8; jdisort=JDISORTW4; }
2645                else
2646                if (strncmp(p,"/sort:v1"  ,8) == 0) { p+=8; jdisort=JDISORTV1; }
2647                else
2648                if (strncmp(p,"/sort:v2"  ,8) == 0) { p+=8; jdisort=JDISORTV2; }
2649                else
2650                if (strncmp(p,"/sort:v3"  ,8) == 0) { p+=8; jdisort=JDISORTV3; }
2651                else
2652                if (strncmp(p,"/sort:v4"  ,8) == 0) { p+=8; jdisort=JDISORTV4; }
2653                else
2654                if (strncmp(p,"/sort:n1"  ,8) == 0) { p+=8; jdisort=JDISORTN1; }
2655                else
2656                if (strncmp(p,"/sort:n2"  ,8) == 0) { p+=8; jdisort=JDISORTN2; }
2657                else
2658                if (strncmp(p,"/sort:n3"  ,8) == 0) { p+=8; jdisort=JDISORTN3; }
2659                else
2660                if (strncmp(p,"/sort:n4"  ,8) == 0) { p+=8; jdisort=JDISORTN4; }
2661                else fatal(q);
2662            } /* while /option */
2663            if (*p == '?' || *p == '=') p++; else fatal(p); parmtabjdip=p; 
2664            q=p+1; p=strchr(q,'?'); if (!p) p=strchr(q,'='); if (!p) fatal(parmtabjdip); *p++='\0';
2665            if (parmtrace) printf("+++ jdi parmtabjdip=%s\n",parmtabjdip);
2666            q=p; if (strcmp(q,"@") == 0) sprintf(q=mx_bup,"@%s.pft",parmtabjdip);
2667            jdifmtarea=loadfile(parmtabjdip,'@',q,jdifmtarea,jdifmtasize+1,'\0');
2668            if (!jdifmtarea) fatal(q); q=jdifmtarea;
2669            if (!*q) fatal(p);
2670            if (parmtrace) {
2671                printf("+++ fmt=%c",OPENFCHR); printf("%s",q);
2672                printf("%c ..",CLOSFCHR); if (getchar() != '\n') MXEXIT(0);
2673            }
2674            if (fmt_gener(&jdipgmp,q)) {
2675                fprintf(stderr,"*** fmt_error=%"_LD_"\n",fmt_error);
2676                fatal(q+fmt_errof);
2677            }
2678            //parmfields=0;
2679            if (parmtabjdip) {
2680                jdislen=(9+jdiwidth+1);
2681                /* calculate maxprim and allocate/zero hash table */
2682                jdicategories=(LONGX)jdiclass*3; // hashing;
2683                if (parmtrace) printf("+++ jdi width=%d categories=%"_LD_"\n",jdiwidth,(LONGX)jdicategories);
2684                jditable=hashalloc(jdicategories,jdiwidth,&jdimaxprim);
2685                if (parmtrace) printf("+++ jdi hash=%"_LD_"\n",jdimaxprim);
2686                /* allocate/zero frequencies */
2687                jdiSUM0w=     (float *) loadfile(NULL,'@',"",NULL, jdimaxprim           *sizeof(float), '\0');
2688                jdiSUM0v=     (float *) loadfile(NULL,'@',"",NULL, jdimaxprim           *sizeof(float), '\0');
2689                jdiSUM0n=     (LONGX  *) loadfile(NULL,'@',"",NULL, jdimaxprim           *sizeof(LONGX ), '\0');
2690                jdiFREQ1=     (LONGX  *) loadfile(NULL,'@',"",NULL, jdimaxprim           *sizeof(LONGX ), '\0');
2691                /* allocate/zero sort area - jdiclass */
2692                jdiSBUF=      (char  *) loadfile(NULL,'@',"",NULL, jdimaxprim*jdislen*sizeof(char ), '\0');
2693                jdiSBUH=      (LONGX  *) loadfile(NULL,'@',"",NULL, jdimaxprim           *sizeof(LONGX ), '\0');
2694                jdiSBUFx=     (char  *) loadfile(NULL,'@',"",NULL,            jdislen*sizeof(char ), '\0');
2695            }
2696            //alloc jdi term
2697#if CICPP
2698            try { jditrmp=new TRMSTRU(cisisxp); }
2699            catch (BAD_ALLOC) { fatal("mx/jdi/reftrm/next"); }
2700#else /* CICPP */
2701            for (jditrm_prat=maxntrm; jditrm_prat--; ){
2702                if (!vtrmp[jditrm_prat]) /* ja' decrementado */
2703                    break;
2704            }
2705            if (!jditrm_prat) fatal("mx/jdi/reftrm/next");
2706#endif /* CICPP */
2707            //alloc jdi record
2708#if CICPP
2709            try { jdirecp=new RECSTRU(cisisxp); }
2710            catch (BAD_ALLOC) { fatal("mx/jdi/refrec/next"); }
2711#else /* CICPP */
2712            for (jdirec_prat=maxnrec; jdirec_prat--; ){
2713                if (!vrecp[jdirec_prat]) /* ja' decrementado */
2714                    break;
2715            }
2716            if (!jdirec_prat) fatal("mx/jdi/refrec/next");
2717#endif /* CICPP */
2718            //open
2719#if CICPP
2720            jditrmp->term(parmtabjdip,"A");
2721#else
2722            jditrmp=vtrmp[term(jditrm_prat,parmtabjdip,"A")];
2723#endif
2724#if CICPP
2725            jdirecp->record(parmtabjdip,1L);
2726#else
2727            jdirecp=vrecp[record(jdirec_prat,parmtabjdip,1L)];
2728#endif
2729            continue;
2730        }
2731
2732
2733#if INVXBOOL
2734        if (strncmp(p,"invx?",5) == 0 || strncmp(p,"invx=",5) == 0) {
2735            /* mxbool/b40 tl_irec */
2736            if (booltlir == 0) {
2737#if BEFORE20020128
2738                record(booltlir=nrecs,dbnp,VMF0nxtmfn(crec)); /* alloc/init */
2739                VMFRstatus(booltlir)=ACTIVE;                  /* fmt */
2740                VMFRmfn(booltlir)=1L;                         /* good */
2741#else
2742            /* b7_run faz "trirecp=vrep[tlirec]" */
2743            if (!booltlir) record(booltlir=nrecs,"null",1L);
2744#endif
2745            }
2746            record(irecx=nrecs,p+5,1L);
2747            *(batchp=mx_bup)='\0';
2748            while (VRECrc(irecx) != RCEOF) {
2749                if (VRECrc(irecx) == RCNORMAL)
2750                    for (xdir=0, loop=VMFRnvf(irecx); loop--; xdir++)
2751                        if (VDIRtag(irecx,xdir) == MFQTXTAG) {
2752                            sprintf(batchp,"H%d %d ",
2753                                        MFQTXTAG,VDIRlen(irecx,xdir));
2754                            batchp+=strlen(batchp);
2755                            memcpy(batchp,
2756                                VFIELDP(irecx,xdir),VDIRlen(irecx,xdir));
2757                            batchp+=VDIRlen(irecx,xdir);
2758                            *batchp='\0';
2759                        }
2760                record(irecx,VRDBname(irecx),VMFRmfn(irecx)+1);
2761            }
2762#if BEFORE20020128
2763#else
2764            dbxflush(VRDBname(irecx)); /* libera x101 */
2765#endif
2766            if (fldupdat(booltlir,mx_bup)) fatal(mx_bup);
2767#if CIAPI
2768            FREE(vrecp[irecx]); vrecp[irecx]=NULL; nrecs-=1;
2769#else /* CIAPI */
2770            FREE(vrecp[irecx]); vrecp[irecx]=NULL; nrecs--;
2771#endif /* CIAPI */
2772
2773            if (parmtrace) prtfields(vrecp[booltlir],VMFRmfn(booltlir));
2774            continue;
2775        }
2776#endif
2777
2778
2779//#if CICGI
2780        if (strncmp(p,"pftout?",7) == 0 || strncmp(p,"pftout=",7) == 0) {
2781            parmpftoutp=p+7;
2782            if ((parmpftoutfp=fopen(dbxcipar(NULL,parmpftoutp,'='),"w")) == NULL)
2783                fatal(p);
2784            continue;
2785        }
2786        if (strncmp(p,"prolog?",7) == 0 || strncmp(p,"prolog=",7) == 0) {
2787            parmprologp=p+7;
2788            continue;
2789        }
2790        if (strncmp(p,"epilog?",7) == 0 || strncmp(p,"epilog=",7) == 0) {
2791            parmepilogp=p+7;
2792            irecepilog=irec;
2793            continue;
2794        }
2795//#endif /* CICGI */
2796
2797        /* output parameters */
2798
2799        if (strncmp(p,"iso?",4) == 0 || strncmp(p,"iso=",4) == 0 ||
2800            strncmp(p,"outiso?",7) == 0 || strncmp(p,"outiso=",7) == 0) {
2801            if (strncmp(p,"iso?",4) == 0 || strncmp(p,"iso=",4) == 0) q=p+4; else q=p+7;
2802                if (strchr(q,'=')) {
2803                    if (strncmp(q,"marc=",5) == 0) {  /* AOT, 06/06/2005 */
2804                        q+=5;
2805                        lrfox=ISOBSIZ; /* set to max line len */
2806                        isfox=(-1);    /*  no CRLF */
2807                        parmisoxfs=ISOXFSMARC;
2808                        parmisoxgs=ISOXGSMARC;
2809                        iso_ismarc=ismarc=1;
2810                    }
2811                    else
2812                    if (strncmp(q,"0=",2) == 0) {    /* AOT, 06/06/2005 */
2813                        q+=2;
2814                        lrfox=ISOBSIZ; /* set to max line len */
2815                        isfox=0;       /*  with [CR]LF */
2816                        parmisoxfs=ISOXFSMARC;
2817                        parmisoxgs=ISOXGSMARC;
2818                    }
2819                    else {
2820                        if (sscanf(q,"%d=%s",&lrfox,line) != 2) fatal(p);
2821                        if (lrfox > ISOBSIZ) fatal(p);
2822                        q=strchr(q,'=')+1;
2823                        isfox=1;    /* test ok */
2824                    }
2825                }
2826                else {
2827#if MPE
2828                    isfox=1;
2829#else
2830                    isfox=0;
2831#endif
2832                    lrfox=80;
2833                }
2834            if (iso_creat(NULL,q,0,lrfox,isfox) <= 0) fatal(p);
2835            parmiso2=1;
2836            continue;
2837        }
2838
2839        if (strncmp(p,"isotag1?",8) == 0 || strncmp(p,"isotag1=",8) == 0) {
2840            if (sscanf(p+8,"%u",&parmisildrtag) != 1)
2841                fatal(p);
2842            continue;
2843        }
2844        if (strncmp(p,"outisotag1?",11) == 0 || strncmp(p,"outisotag1=",11) == 0) {
2845            if (sscanf(p+11,"%u",&parmisoldrtag) != 1)
2846                fatal(p);
2847            continue;
2848        }
2849
2850        if (strncmp(p,"fix?",4) == 0 || strncmp(p,"fix=",4) == 0) {
2851            q=p+4;
2852            if ((fpfix=fopen(dbxcipar(NULL,q,'='),"w")) == NULL) fatal(p);
2853            parmiso2=2;
2854            continue;
2855        }
2856
2857#if MXFST
2858        if (strncmp(p,"ln1?",4) == 0 || strncmp(p,"ln1=",4) == 0) {
2859#if MXIFUPD
2860            if (ifnp) fatal(p);
2861#endif
2862             if (strcmp(p+4,"void") == 0) {
2863                parmfstup=0;
2864            }
2865            else    /* 21/05/98 */
2866                if (fst_open(NULL,p+4,0) <= 0) fatal(p);
2867            continue;
2868        }
2869        if (strncmp(p,"ln2?",4) == 0 || strncmp(p,"ln2=",4) == 0) {
2870#if MXIFUPD
2871            if (ifnp) fatal(p);
2872#endif
2873             if (strcmp(p+4,"void") == 0) {
2874                parmfstup=0;
2875            }
2876            else    /* 21/05/98 */
2877                if (fst_open(NULL,p+4,1) <= 0) fatal(p);
2878            continue;
2879        }
2880
2881        if (strncmp(p,"fst?",4) == 0 || strncmp(p,"fst=",4) == 0 ||
2882            strncmp(p,"fst/h?",6) == 0 || strncmp(p,"fst/h=",6) == 0) {
2883            if (strncmp(p,"fst/h",5) == 0) {
2884                q=p+6;
2885                fst_hdrp=(char *)ALLOC((ALLOPARM)(fst_hdrx=1000));
2886                if (fst_hdrp == ALLONULL) fatal("ALLOC/fst_hdrp");
2887            }
2888            else q=p+4;
2889            if (strcmp(q,"@") == 0) sprintf(q=line,"@%s.fst",dbnp);
2890            if (!loadfile(mi_gidbnp,'@',q,mx_bup,mx_buplen,'\n')) fatal(q);
2891            fst_gener(&fstpgmp,mx_bup);
2892            if (parmtrace) printf("%s.\n",mx_bup); 
2893            if (fst_error) {
2894                printf("\n*** FST error#%"_LD_" at line %"_LD_"\n",fst_error,fst_errl);
2895                if (fst_error == FSTERRF)
2896                    printf("\n*** FMT error#%"_LD_" at offset %"_LD_"\n",
2897                                                fmt_error,fmt_errof);
2898                fatal(fst_errp);
2899            }
2900            continue;
2901        }
2902
2903        if (strncmp(p,"stw?",4) == 0 || strncmp(p,"stw=",4) == 0) {
2904            q=p+4;
2905            if (*q++ != '@') fatal(p);
2906            if (!*q) sprintf(q=line,"%s.stw",dbnp);
2907        stwp=loadstw(mi_gidbnp,q,stwp=NULL,0L,&n);
2908        if (!stwp) fatal(p);
2909            if (parmtrace) {
2910                for (q=stwp; *q; q+=LE1+1) printf("%s/",q);
2911                printf("=%d\n",n);
2912            }
2913            continue;
2914        }
2915#endif
2916
2917#if MXFULLINV
2918        if (strncmp(p,"fullinv",7) == 0) {
2919            if (!fstpgmp) fatal(p);
2920#if MXIFUPD
2921            if (ifnp) fatal(p);
2922#endif
2923            q=p+7;
2924            /* fullinv[/dict][/keep][/m][/ansi]=<ifn> */
2925            if (strncmp(q,"/dict",5) == 0) {q+=5; fullinv_pstflag=IFUPDICT;
2926                                                  ciiflfim=1;
2927                                                  cifstfix=cifstfim=1;
2928                                           }
2929            if (strncmp(q,"/keep",5) == 0) {q+=5; fullinv_keep=1;}
2930#if LIND
2931            ciiflfim=1;
2932            cifstfix=cifstfim=1;
2933#endif
2934            if (strncmp(q,"/m" ,2)   == 0) {q+=2; ciiflfim=1;
2935                                                  cifstfix=cifstfim=1;
2936                                           }
2937            if (strncmp(q,"/ansi",5) == 0) {q+=5;
2938                memcpy(isisuctab,ansiuctab,256/*sizeof(ansiuctab)*/);
2939                for (isiswctot=0; ansiactab[isiswctot]; isiswctot=isiswctot+1)
2940                    isiswctab[ansiactab[isiswctot]]=1;
2941            }
2942            if (strncmp(q,"?",1) == 0 || strncmp(q,"=",1) == 0) q+=1; else fatal(p);
2943            if (!*q) fatal(p);
2944            fullinv_ifnp=q;
2945            parmfstup=0;
2946            cifstfix=1;                                           /* +fix */
2947            parmcontrol=parmleader=parmxref=parmdir=parmfields=0; /* -all */
2948            parmwait=0;                                           /* now */
2949            if (!fst_fd[0]) {
2950                sprintf(mx_bup,"%s.ln1",fullinv_ifnp);
2951                if (fst_open(NULL,mx_bup,0) <= 0) fatal(p);
2952            }
2953            if (!fst_fd[1]) {
2954                sprintf(mx_bup,"%s.ln2",fullinv_ifnp);
2955                if (fst_open(NULL,mx_bup,1) <= 0) fatal(p);
2956            }
2957            continue;
2958        }
2959#if LIND
2960        if (strncmp(p,"maxmfn?",7) == 0 || strncmp(p,"maxmfn=",7) == 0) {
2961            if (sscanf(p+7,"%"_LD_,&fullinv_maxmfn) != 1) fatal(p);
2962            continue;
2963        }
2964#endif
2965#endif /* MXFULLINV */
2966
2967
2968#if MXFULLINV || MXIFUPD
2969        if (strncmp(p,"master?",7) == 0 || strncmp(p,"master=",7) == 0) {
2970            parmmaster=p+7; if (!*parmmaster) fatal(p);
2971            continue;
2972        }
2973#endif /* MXFULLINV || MXIFUPD */
2974
2975#if MXIFUPD
2976        if (strncmp(p,"ifupd",5) == 0) {
2977            if (ifnp) fatal(p);
2978            if (fst_fd[0] || fst_fd[1]) fatal(p);
2979            q=p+5;
2980            /* ifupd[/create][/dict]=<ifn> */
2981            if (strncmp(q,"/create",7) == 0) {q+=7; ifcreate=1;}
2982            if (strncmp(q,"/dict",5) == 0) {q+=5; pstflag=IFUPDICT;}
2983            if (strncmp(q,"?",1) == 0 || strncmp(q,"=",1) == 0) q+=1;
2984            else fatal(p);
2985            ifnp=q;
2986            if (!*ifnp) fatal(p);
2987            continue;
2988        }
2989        if (strncmp(p,"maxlk1?",7) == 0 || strncmp(p,"maxlk1=",7) == 0) {
2990            if (sscanf(p+7,"%d",&maxlk1) != 1)
2991                fatal(p);
2992            continue;
2993        }
2994        if (strncmp(p,"maxlk2?",7) == 0 || strncmp(p,"maxlk2=",7) == 0) {
2995            if (sscanf(p+7,"%d",&maxlk2) != 1)
2996                fatal(p);
2997            continue;
2998        }
2999#endif
3000
3001        if (strncmp(p,"copy?",5) == 0 || strncmp(p,"copy=",5) == 0 ||
3002            strncmp(p,"append?",7) == 0 || strncmp(p,"append=",7) == 0 ||
3003            strncmp(p,"updatf?",7) == 0 || strncmp(p,"updatf=",7) == 0 ||
3004            strncmp(p,"create?",7) == 0 || strncmp(p,"create=",7) == 0 ||
3005            strncmp(p,"merge?",6) == 0 || strncmp(p,"merge=",6) == 0) {
3006
3007            parmcopy=COPY;
3008            if (strncmp(p,"create",7-1) == 0) {                 /* create */
3009                p+=7;
3010                recisis0(p);
3011            }
3012            else {
3013                if (strncmp(p,"copy",5-1) == 0)                 /* copy */
3014                    p+=5;
3015                else
3016                    if (strncmp(p,"updatf",7-1) == 0)           /* update */
3017                    {
3018                        p+=7;
3019                        parmcopy=UPDATF;
3020                    }
3021                    else
3022                        if (strncmp(p,"append",7-1) == 0)       /* append */
3023                            {p+=7; parmcopy=APPEND;}
3024                        else
3025                            {p+=6; parmcopy=MERGE;}             /* merge */
3026                dbxopt_fatal=0; xfd=dbxopen(p,p,mx1extp);
3027                if (xfd <= 0) recisis0(p); else CLOSE(xfd);
3028            }
3029            recallok((upcrec=nrecs),(LONGX)sizeof(M0STRU));
3030            recallok((upirec=nrecs),maxmfrl); /* 18/11/91 */
3031#if MULTI
3032        if (strcmp(p,dbnp) == 0) /* dbxstorp has already set dbxnetws */
3033#if CIAPI
3034            dbnp_dbxnetws(p)=dbxcinet(p);
3035            if (dbnp_dbxnetws(p) != MONONETS) {
3036#else /* CIAPI */
3037            dbxstorp(p)->dbxnetws=dbxcinet(p);
3038            if (dbxstorp(p)->dbxnetws != MONONETS) {
3039#endif /* CIAPI */
3040                VREClock(upirec)=RLOCK;
3041                VREClock(upcrec)=DELOCK;
3042        }
3043#endif
3044            record(upcrec,p,0L);        /* append */    /* RLOCK */
3045#if MULTI
3046            if (VRECrc(upcrec) == RCLOCK) FATLOCK;
3047#endif
3048            continue;
3049        }
3050
3051        if (parmtextp) {
3052            if (tmpseq) fatal("text x tmpseq");
3053            fatal("text x bool");
3054        }
3055
3056        if (mxbool(xmxp,p,dbnp)) MXEXIT(1);
3057
3058    } /* end of argv[] */
3059
3060
3061    if (!dbnp) fatal("input missing");
3062
3063
3064#if MXFULLINV
3065    if (fullinv_ifnp) {
3066        if (parmmaster) fullinv_master=parmmaster;
3067        else {
3068            fullinv_master=dbnp;
3069            if (parmcopy) fullinv_master=VRDBname(upcrec);
3070        }
3071#if LIND
3072        fullinv_reset=0;  /* init=1 */
3073#else
3074        if (parmmenosreset) fullinv_reset=0;
3075        else
3076            if (!parmmaster)
3077                if (strcmp(fullinv_master,fullinv_ifnp)) fullinv_reset=0;
3078#endif
3079
3080#if 0
3081        if (!fst_fd[0]) fatal("fullinv/missing ln1=");
3082        if (!fst_fd[1]) fatal("fullinv/missing ln2=");
3083#endif
3084        trmisis0(fullinv_ifnp);
3085    }
3086#endif /* MXFULLINV */
3087
3088#if MXIFUPD
3089    if (ifnp) {
3090        if (parmmenosreset) ifupd_reset=0;
3091        parmfstup=0;
3092        if (ifcreate) trmisis0(ifnp);
3093        if (parmcopy) {
3094            mstcrec=upcrec; mstirec=upirec;
3095        }
3096        else {
3097            mstcrec=crec; mstirec=irec;
3098#if BEFORE20000831
3099            svdifupx++;
3100            upif_init(ifnp);
3101#else
3102            svdifupx=1;
3103#endif
3104        }
3105#if CIAPI
3106        ifndbxp=dbxstorp(ifnp);
3107        dbnp_dbxitrac(ifnp)=parmtrace;
3108#else /* CIAPI */
3109        (ifndbxp=dbxstorp(ifnp))->dbxitrac=parmtrace;
3110#endif /* CIAPI */
3111        endup = IFUPCORE;
3112#if MULTI
3113
3114#if CIAPI
3115        if (dbnp_dbxnetws(VRDBname(mstcrec)) != MONONETS) endup = IFUPWRIT;
3116#else /* CIAPI */
3117        if (dbxstorp(VRDBname(mstcrec))->dbxnetws != MONONETS) endup = IFUPWRIT;
3118#endif /* CIAPI */
3119
3120#endif
3121    }
3122#endif
3123
3124
3125
3126    /*
3127        Execution
3128    */
3129
3130    if (parmloop < 0) {  /* AOT, 26/07/2005 */
3131        if (!parmfrom) parmfrom = VMF0nxtmfn(crec) - 1;
3132        if (!parmto)   parmto=1;
3133    }
3134
3135    if (tmpseq)
3136        if (!parmfrom)
3137            parmfrom = (parmcopy) ? VMF0nxtmfn(upcrec) : 1L;
3138
3139    if (!parmfrom)
3140        parmfrom=1L;
3141
3142    if (!parmto)
3143        parmto=LONGX_MAX;
3144
3145    if (parmcontrol)
3146        prtcontrol(vrecp[crec],dbnp);
3147
3148    if (parmkdbnp) {
3149        if (parmk1p) {
3150            for (xtp=parmk1p, xti=LE2; *xtp && xti; xtp++, xti--) *xtp = isisuctab[(int)*xtp];
3151            *xtp='\0';
3152        }
3153        else parmk1p="!";
3154        memset(parmk2a,highv[0],LE2); parmk2a[LE2]='\0';
3155        if (parmk2p) {
3156            for (xtp=parmk2p, xti=LE2; *xtp && xti; xtp++, xti--) *xtp = isisuctab[(int)*xtp];
3157            *xtp='\0';
3158            memcpy(parmk2a,parmk2p,strlen(parmk2p));
3159        }
3160        itrm=ntrms;
3161        if (parmtrace) printf("+++ TERM %"_LD_" = %s,%s,%s \n",itrm,parmkdbnp,parmk1p,parmk2p);
3162#if LIND
3163        if (!parmkpostings) trmalloc(itrm,0L);  /* avoid opening .iyp */
3164        if (!parmkpostings) if (parmtrace) printf("+++ trmalloc(%"_LD_",0)\n",itrm);
3165#endif
3166        TERM(itrm,parmkdbnp,parmk1p); parmkcount=1;
3167        itrm2=ntrms; trmp1=trmp;
3168        if (parmtrace) printf("+++ TERM %"_LD_" = %s,%s,%s \n",itrm2,parmkdbnp,TRMkey,parmk2p);
3169#if LIND
3170        if (!parmkpostings) trmalloc(itrm2,0L);  /* avoid opening .iyp */
3171        if (!parmkpostings) if (parmtrace) printf("+++ trmalloc(%"_LD_",0)\n",itrm2);
3172#endif
3173        TERM(itrm2,parmkdbnp,TRMkey); trmp2=trmp;
3174        trmp=trmp1;
3175    }
3176
3177    if (parmprologp) {
3178#if CICGI
3179#if CIWTF
3180        if (ciahcgi) {
3181            if (fldupdat(irec,ciahcgi)) fatal(ciahcgi);
3182        }
3183#endif //CIWTF
3184#endif /* CICGI */
3185#define PROL1 1 // AOT 27/06/2009
3186#if PROL1
3187        if (1) {
3188            LONGX v31009=VMF0nxtmfn(crec);
3189            LONGX v31409=boolhits;
3190            sprintf(mx_bup,"a31009|%"_LD_"|a31409|%"_LD_"|",v31009,v31409);
3191            if (fldupdat(irec,mx_bup)) fatal(mx_bup);
3192        }
3193#endif //PROL1
3194        if (recfmt(irec,rec_maxmfrl,parmprologp,mx_bup,mx_buplen) < 0) {
3195            printf("Content-type: text/plain\n\nMX fatal: %s",parmprologp);
3196        }
3197        if (parmpftoutfp && 0) fprintf(parmpftoutfp,"%s",mx_bup); else
3198        printf("%s",mx_bup);
3199    }
3200#if CICGI
3201    else if (cgixpok) { printf("Content-type: text/html\n\n");
3202                        printf("<html><body>\n"); }
3203#endif /* CICGI */
3204
3205
3206    /*
3207        Loops throught...
3208    */
3209
3210LOOP:
3211
3212    for (mfn=parmfrom, boolh=0; ; mfn+=parmloop) {
3213
3214        LONGX xboolmfn;
3215
3216        if (boolqryp) { /* mxbool/boolh */
3217            if (boolh) {
3218                boolh+=parmloop;
3219                if (parmloop < 0) {                                                /* AOT, 26/07/2005 */
3220                    if (boolh < 1)        boolh=boolhits+1; /* end of hits */
3221                }
3222                else {
3223                    if (boolh > boolhits) boolh=boolhits+1; /* end of hits */
3224                }
3225            }
3226            else {
3227                if (parmloop < 0)                                                  /* AOT, 26/07/2005 */
3228                    boolh=boolhits;
3229                else
3230                    boolh=1;
3231            }
3232#if CIB71
3233            xboolmfn=b7_hit(cib7p,boolridx,boolh,b7setno);
3234#else /* CIB71 */
3235#if LIND || CIB64
3236#if BIGREC
3237            xboolmfn=b5_hit(boolridx,boolh,mx_bup);
3238#else
3239            xboolmfn=b6_hit(boolridx,boolh,b5setno,b6bufferp);
3240#endif
3241#else
3242            xboolmfn=b4_hit(boolridx,boolh);
3243#endif
3244#endif /* CIB71 */
3245            if (parmtrace) printf("+++ xboolmfn=%"_LD_"\n",xboolmfn);
3246            if (xboolmfn <= 0L) break;
3247
3248            if (parmloop < 0) {  /* AOT, 26/07/2005 */
3249                if (xboolmfn > parmfrom) continue;
3250                if (xboolmfn < parmto)   continue;
3251            }
3252            else {
3253                if (xboolmfn < parmfrom) continue;
3254                if (xboolmfn > parmto)   continue;
3255            }
3256            mfn=xboolmfn;
3257        } /* end if boolqryp */
3258
3259        if (parmloop < 0) {  /* AOT, 26/07/2005 */
3260            if (mfn < parmto) break;
3261        }
3262        else {
3263            if (mfn > parmto) break;
3264        }
3265
3266        if (count >= parmcount) break;
3267
3268        if (parmwait)
3269            if (count) {
3270                n=1;
3271                if (parmtextp && !mxtext_found) n=0;
3272                if (n) {
3273                    printf(prompt1p); isxp=gets(line); p=isxp;
3274                    if (ISX(p)) break;
3275                    if (p) if (*p) { if (mxbool(xmxp,p,dbnp)) MXEXIT(1); count=0; goto LOOP; }
3276                }
3277            }
3278
3279        ++count; /* in advance */
3280
3281        /* Sequential RECORD */
3282
3283        if (tmpseq) {
3284#if DIR_FILE
3285            if (direntdp) {
3286                if (direntep = readdir (direntdp))
3287                {
3288                    //puts (direntep->d_name);
3289                    RECORD(irec,dbnp,mfn);
3290                    RECrc=RCNORMAL; MFRmfn=mfn; MFRstatus=ACTIVE;
3291                    sprintf(mx_bup,"a1|%s|",direntep->d_name); 
3292                    if (fldupdat(irec,mx_bup)) fatal(mx_bup);
3293                    MFRmfn=mfn;
3294                }
3295                else {
3296                    (void) closedir (direntdp);
3297                    break; // end of directory listing
3298                }
3299            }
3300            else
3301#endif
3302            if (fpseq) {
3303            /* uses global mx_bup as input buffer */
3304                mx_bup[0]=parmxseq;
3305                if (recfgets(crec,irec,mx_bup,mx_buplen,fpseq) == EOF)
3306                    break;
3307                MFRmfn=mfn;
3308            }
3309            else
3310            if (n1fdseq) {
3311                if (recfgetseq(NULL, parmxseq, parmseqlog, ibuf, ibufsiz, obuf, obufsiz, ubuf, ubufsiz, &n1fdseq, &n1left, &n1iptr, &n1count) == EOF) break;
3312                RECORD(irec,dbnp,mfn);
3313                RECrc=RCNORMAL; MFRmfn=mfn; MFRstatus=ACTIVE;
3314                if (fldupdat(irec,ubuf)) fatal(ubuf);
3315                MFRmfn=mfn;
3316            }
3317#if XML_FILE
3318            else
3319            if (n1fdxml) {
3320                if (recfgetxml(NULL, ibuf, ibufsiz, obuf, obufsiz, ubuf, ubufsiz, &n1fdxml, &n1left, &n1iptr, &n1count) == EOF) break;
3321                RECORD(irec,dbnp,mfn);
3322                RECrc=RCNORMAL; MFRmfn=mfn; MFRstatus=ACTIVE;
3323                if (fldupdat(irec,ubuf)) fatal(ubuf);
3324                MFRmfn=mfn;
3325            }
3326#endif /* XML_FILE */
3327            else
3328                if (parmiso1) {
3329                    if (iso_read(crec,irec,parmisildrtag) == EOF) break;
3330                    MFRmfn=mfn;
3331                }
3332                else {                                          /* "tmp" */
3333                    RECORD(irec,dbnp,mfn);
3334                    RECrc=RCNORMAL; MFRmfn=mfn; MFRstatus=ACTIVE;
3335                }
3336#if RECXPND
3337            if (RDBxpn01) recxpnmo(irec);
3338#endif
3339#if RECGIZM
3340            for (gizmap=RDBvgzrp; gizmap; gizmap=gizmap->nextp)
3341                recgizmo(irec,gizmap);
3342#endif
3343#if RECDECO
3344            if (RDBvderp) recdecex(irec);
3345#endif
3346        }
3347
3348        else
3349        if (parmkdbnp) {
3350          sprintf(mx_bup,"D*"); if (fldupdat(irec,mx_bup)) fatal(mx_bup);
3351          sprintf(mx_bup,"=%"_LD_,mfn); if (fldupdat(irec,mx_bup)) fatal(mx_bup);
3352KLOOP:
3353          trmp=trmp2;
3354          if (TRMrc != RCEOF) {
3355            NXTERM(itrm2);
3356            if (TRMrc == RCEOF) {
3357              countdict1002=count;
3358              sprintf(mx_bup,"D1001D1002A1001/%"_LD_"/A1002/%"_LD_"/",count,countdict1002);
3359              if (fldupdat(irec,mx_bup)) fatal(mx_bup);
3360            } else {
3361              if (strcmp(TRMkey,parmk2a) > 0) {
3362                countdict1002=count;
3363                sprintf(mx_bup,"D1001D1002A1001/%"_LD_"/A1002/%"_LD_"/",count,countdict1002);
3364                if (fldupdat(irec,mx_bup)) fatal(mx_bup);
3365              }
3366            }
3367          }
3368          trmp=trmp1;
3369
3370          if (parmkpostings) TRMpmfn=posting(itrm,TRMpost+1);
3371#if 0
3372          if (count==1 || !parmkpostings || (parmkpostings && TRMpmfn <= 0)) { /* */
3373#endif
3374          xgo=0;
3375          if (count==1) xgo=1;
3376          if (!parmkpostings) xgo=1;
3377          if (parmkpostings) if (TRMpmfn <= 0) xgo=1;
3378          if (xgo) { /* */
3379            if (TRMrc == RCEOF) break;
3380            if (strcmp(TRMkey,parmk2a) > 0) break;
3381             if (count > 1L) {
3382                NXTERM(itrm);
3383                if (TRMrc == RCEOF) break;
3384                if (strcmp(TRMkey,parmk2a) > 0) break;
3385                if (parmkpostings) TRMpmfn=posting(itrm,TRMpost+1);
3386                parmkcount++;
3387            }
3388            for (xtp=TRMkey+(xti=(TRMlcase)?LE2:LE1)-1; xti--; ) if (*xtp == ' ') *xtp--='\0'; else break;
3389          } /* */
3390          if (parmtrace) { printf("+++ TRMkey:\n"); for (xtp=TRMkey, xti=LE2; xti--; xtp++) printf("%c=%02x ",*xtp,*xtp); printf("\n"); }
3391          if (!parmkpostings || TRMpost%parmkkeep2 == 1 || parmkkeep2 == 1) {
3392            sprintf(mx_bup,"H%9"_LD_" %9"_LD_" %s^l%d^s%"_LD_"^t%"_LD_"^k%"_LD_,(LONGX)parmktag1,0L,TRMkey,TRMlcase+1,(LONGX)strlen(TRMkey),TRMxytotp,parmkcount);
3393            sprintf(mx_bup+1+10,"%9"_LD_,(LONGX)strlen(mx_bup)-(1+10+10)); mx_bup[10+10]=' ';
3394            if (fldupdat(irec,mx_bup)) fatal(mx_bup);
3395          }
3396          if (parmkpostings && TRMpmfn > 0) { /* */
3397            sprintf(mx_bup,"A%"_LD_"/^m%"_LD_"^t%"_LD_"^o%"_LD_"^c%"_LD_"^p%"_LD_"^k%"_LD_"/",(LONGX)parmktag2,TRMpmfn,(LONGX)TRMptag,(LONGX)TRMpocc,(LONGX)TRMpcnt,TRMpost,parmkcount);
3398            if (fldupdat(irec,mx_bup)) fatal(mx_bup);
3399          } /* */
3400if ((parmkpostings && TRMpost < TRMxytotp) && (TRMpost%parmkkeep2 != 0)) goto KLOOP;
3401        }
3402
3403        else {
3404            RECORD(irec,dbnp,mfn);
3405            if (RECrc == RCEOF) break;
3406        }
3407
3408        if (parmhits) {
3409            if (boolqryp) /* mxbool/boolh */
3410                sprintf(mx_bup,"A1001/%"_LD_"/A1002/%"_LD_"/",boolh,boolhits);
3411            else
3412              if (parmkdbnp)
3413                sprintf(mx_bup,"A1001/%"_LD_"/A1002/%"_LD_"/",count,countdict1002);
3414              else
3415/*
3416                sprintf(mx_bup,"A1001/%"_LD_"/A1002/%"_LD_"/",MFRmfn,VMF0nxtmfn(crec)-1);
3417*/
3418                {
3419                    sprintf(mx_bup,"A1001/%"_LD_"/",MFRmfn-parmfrom+1);
3420                    if (MFRmfn == VMF0nxtmfn(crec)-1 ||
3421                        MFRmfn == parmto ||
3422                        count == parmcount)
3423                      sprintf(mx_bup+strlen(mx_bup),"A1002/%"_LD_"/",MFRmfn-parmfrom+1);
3424                }
3425            if (fldupdat(irec,mx_bup) != NULL) fatal(mx_bup);
3426        }
3427
3428        if (parmtextp) {
3429            if (mxtext(xmxp,irec,parmtextp)) MXEXIT(1);
3430            if (!mxtext_found)
3431                continue;
3432        }
3433
3434#if IFUPDATE
3435    if (parmmfbw) {
3436        if (MFRmfbwb == 0) continue;
3437        else {
3438          if (!brec) { brec=nrecs; record(brec,dbnp,mfn); }
3439          recreadb=MFRmfbwb; recreadp=MFRmfbwp;
3440          recread(vrecp[brec],MFRmfn);
3441          memcpy(MFX,VMFX(brec),VMFRmfrl(brec)); /* in trust.. */
3442        }
3443    }
3444#endif
3445
3446        if (parmtell)
3447            if ((count % parmtell) == 0)
3448                fprintf(stderr,"+++ %"_LD_" \n",count);
3449
3450        if (parmxref)   prtxref(recp,mfn);
3451
3452        if (parmleader) prtleader(recp,0L);
3453
3454        if (RECrc != RCNORMAL) {
3455
3456            if (parmdir)        prtdir(recp,mfn);
3457
3458            if (parmfields)     prtfields(recp,mfn);
3459
3460            if (parmcopy == COPY) if (!parmoutmfntag) {
3461
3462                record(upirec,VRDBname(upcrec),MFRmfn); /* RLOCK */
3463                if (VRECrc(upirec) == RCLOCK) FATLOCK;
3464                if (VRECrc(upirec) == RCNORMAL) {
3465#if MULTI
3466                    memcpy(VMFX(upirec),MFX,MFRmfrl);
3467#else
3468                    reccopy(upirec,upcrec,recp,MFRmfn);
3469#endif
3470                    recupdat(upcrec,upirec);
3471#if MXIFUPD
3472                    if (ifnp)
3473                        ifupdat(VRDBname(upcrec),MFRmfn,MFRmfn,
3474                           ifnp,fstpgmp,stwp,maxlk1,maxlk2,pstflag,endup);
3475#endif
3476
3477
3478                } /* end recupdat() */
3479#if MULTI
3480#if CIAPI
3481                if (dbnp_dbxnetws(p) != MONONETS) recunlck(upirec,RLOCK);
3482#else /* CIAPI */
3483                if (dbxstorp(p)->dbxnetws != MONONETS) recunlck(upirec,RLOCK);
3484#endif /* CIAPI */
3485#endif
3486            }
3487
3488            continue;
3489        }
3490
3491
3492        /* ACTIVE records */
3493
3494        if (MFRstatus != ACTIVE) fatal("mx/ACTIVE");
3495
3496        /* join */
3497        if (mj_n) if (mj_edit(xmxp,irec,0,mj_n-1,mj_jtag,NULL)) MXEXIT(1);
3498
3499        /* jdi */
3500        if (parmtabjdip) {
3501            /* tabulate generated lines */
3502            char delim=0x01; //'|';
3503            FFI len;
3504            char *p0=jdifmtarea;
3505            if (fmt_inter(jdipgmp,irec,(LONGX)jdifmtlw,jdifmtarea,(LONGX)fmtasize) < 0)
3506                fatal("mx/jdi/format execution error");
3507            for (len=0, p=p0; ; ) {
3508                /* next line */
3509                if (!*p || *p == '\r' || *p == '\n' || *p == delim) {
3510                    if (len) {
3511                        /* tabulate line */
3512                        LONGX jdimfn=0L;
3513                        char c=(*p);//save
3514                        *p='\0';
3515#if CICPP
3516                        jditrmp->term(parmtabjdip,p0);
3517                        if (jditrmp->trmrc == RCNORMAL) jdimfn=trmp->posting(1L);
3518#else
3519                        term(jditrm_prat,parmtabjdip,p0);
3520                        if (jditrmp->trmrc == RCNORMAL) jdimfn=posting(jditrm_prat,1L);
3521#endif
3522                        if (jdimfn > 0) {
3523#if CICPP
3524                          jdirecp->record(parmtabjdip,jdimfn);
3525#else
3526                          record(jdirec_prat,parmtabjdip,jdimfn);
3527#endif
3528                          if (jdirecp->recrc == RCNORMAL) {
3529                            RECSTRU *recp=jdirecp;//local
3530                            DIRSTRU *dirp=MFRdir;
3531                            int loop=MFRnvf;
3532                            int xocc=jditaboc;
3533                            int xdir=0;
3534                            unsigned char c,*cp;
3535                            float lastjdiw=0.0;
3536                           
3537                            // conta apenas 1 vez
3538                            jdintabs++;
3539                            for (; loop--; dirp++, xdir++) {
3540                                char *jp,*p;//local
3541                                int jlen=0,len;
3542                                float jdiw=0.0;
3543                                float jdiv=0.0;
3544                                LONGX  jdin=0;
3545                                if (dirp->tag != jditabtg) continue;
3546                                if (!xocc--) break;
3547                                jp=p=FIELDP(xdir);
3548                                len=dirp->len; cp=p+len; c=(*cp); p[len]='\0';
3549                                for (; len--; p++, jlen++) if (*p=='^') break;                               
3550                                if (jlen) for (; len-->2; p++) if (*p=='^') {
3551                                    if (*(p+1)=='w') { if (sscanf(p+2,"%f" ,&jdiw) != 1) jdiw=0.0; len-=2; p+=2; continue; } else
3552                                    if (*(p+1)=='v') { if (sscanf(p+2,"%f" ,&jdiv) != 1) jdiv=0.0; len-=2; p+=2; continue; } else                                   
3553                                    if (*(p+1)=='n') { if (sscanf(p+2,"%"_LD_,&jdin) != 1) jdin=0;   len-=2; p+=2; continue; }
3554                                }                               
3555                                if ((lastjdiw > 0) && (jdiw > lastjdiw)) {
3556                                    char aux[64];
3557                                    sprintf(aux, "mx/jdi/jdiw is not sorted. key=%s lastjdiw=%f jdiw=%f\n", jp, lastjdiw, jdiw);
3558                                    fatal(aux);
3559                                }
3560                                lastjdiw = jdiw;                               
3561                                *cp=c;
3562                                //tabulate jd
3563                                if (jdiw>0) {
3564                                    /* tabulate line */
3565                                    LONGX  hidx;
3566                                    int hwidth=(jdiwidth+1);
3567                                    int hfound;
3568                                    hidx=hashindex(jditable,jdimaxprim,jdiwidth,jp,jlen,&hfound,1);
3569                                    //if (hfound) if (!hfound) fatal("");
3570                                    jdiSUM0w[hidx]+=jdiw;
3571                                    jdiSUM0v[hidx]+=jdiv;
3572                                    jdiSUM0n[hidx]+=jdin;
3573                                    jdiFREQ1[hidx]++;
3574                                    jditotalw+=jdiw;
3575                                    jditotalv+=jdiv;
3576                                    jditotaln+=jdin;
3577                                    // conta 1 vez para cada tema
3578                                    //jdintabs++;
3579                                    jditotal1++;
3580                                    if (parmtrace) {
3581                                        char *h=jditable+hidx*hwidth;
3582                                        printf("[%9"_LD_"] %f,%f,%"_LD_"/%6"_LD_" %d,%s %d,",hidx,jdiSUM0w[hidx],jdiSUM0v[hidx],jdiSUM0n[hidx],jdiFREQ1[hidx],strlen(h),h,jlen);
3583                                        for (; jlen--; jp++) printf("%c",*jp); //getchar();
3584                                        printf("\n");
3585                                    }
3586                                }
3587                            }//end for dirp
3588                          }//end if RECORD
3589                        }//end if jdimfn
3590                        *p=c;//restore
3591                    }//end if len
3592                    /* move line ptr */
3593                    while (*p == '\r' || *p == '\n' || *p == delim) p++;
3594                    p0=p; len=0;
3595                    if (!*p0) break;
3596                }//if !*p || *p == '\r' || *p == '\n' || *p == delim
3597                else {
3598                    p++; len++;
3599                }//end if !*p || *p == '\r' || *p == '\n' || *p == delim
3600            } /* end for */
3601            //list and reinit
3602            if (jditotalw) {
3603                LONGX  hidx=0;
3604                char *h=jditable;
3605                int hwidth=(jdiwidth+1);
3606                float *w=jdiSUM0w;
3607                float *v=jdiSUM0v;
3608                LONGX  *n=jdiSUM0n;
3609                LONGX  *f=jdiFREQ1;
3610                LONGX  rev;
3611                int   sbufs=0;
3612                char *sbufp=jdiSBUF;
3613                int   s1u,s1,s2;
3614                char *p1,*p2;
3615                *(batchp=mx_bup)='\0';
3616                for (; hidx < jdimaxprim; hidx++, h+=hwidth, w++, v++, n++, f++) {
3617                    if (!*h) continue;
3618                    if (!*w) continue;
3619                    if (jdisminw) if (*w / *f < jdisminw) continue;
3620                    if (jdisminv) if (*v / *f < jdisminv) continue;
3621                    if (jdisminn) if (     *f < jdisminn) continue;
3622                    rev=999999999L;
3623                    if (jdisort == JDISORTW1) /* w1 */   rev-=(LONGX)( 100000*         *w / *f        );
3624                    if (jdisort == JDISORTW2) /* w2 */   rev-=(LONGX)( 100000*         *w / jdintabs  );
3625                    if (jdisort == JDISORTW3) /* w3 */   rev-=(LONGX)( 100000*         *w / jditotalw );
3626                    if (jdisort == JDISORTW4) /* w4 */   rev-=(LONGX)( 100000*         *w / jditotal1 );
3627                    if (jdisort == JDISORTV1) /* v1 */   rev-=(LONGX)( 100000*         *v / *f        );
3628                    if (jdisort == JDISORTV2) /* v2 */   rev-=(LONGX)( 100000*         *v / jdintabs  );
3629                    if (jdisort == JDISORTV3) /* v3 */   rev-=(LONGX)( 100000*         *v / jditotalv );
3630                    if (jdisort == JDISORTV3) /* v4 */   rev-=(LONGX)( 100000*         *v / jditotal1 );
3631                    if (jdisort == JDISORTN1) /* n1 */   rev-=(LONGX)(         (float) *n / *f        );
3632                    if (jdisort == JDISORTN2) /* n2 */   rev-=(LONGX)( 100000* (float) *n / jdintabs  );
3633                    if (jdisort == JDISORTN3) /* n3 */   rev-=(LONGX)( 100000* (float) *n / jditotaln );
3634                    if (jdisort == JDISORTN3) /* n4 */   rev-=(LONGX)( 100000* (float) *n / jditotal1 );
3635                    sprintf(sbufp,"%09"_LD_"%s",rev,h); sbufp+=jdislen; jdiSBUH[sbufs++]=hidx;
3636                } /* end hidx */
3637                /*if (sbufs>jdisstop) sbufs=jdisstop;*/
3638                for (s1=0, p1=jdiSBUF, s1u=sbufs-1; s1<s1u; s1++, p1+=jdislen) {
3639                    for (s2=s1+1, p2=jdiSBUF+jdislen*s2; s2<sbufs; s2++, p2+=jdislen) {
3640                        if (memcmp(p1,p2,jdislen) <= 0) continue;
3641                        memcpy(jdiSBUFx,p1  ,jdislen); 
3642                        memcpy(p1  ,p2  ,jdislen); 
3643                        memcpy(p2  ,jdiSBUFx,jdislen); 
3644                        hidx=jdiSBUH[s1]; jdiSBUH[s1]=jdiSBUH[s2]; jdiSBUH[s2]=hidx;
3645                    } /* end s2 */
3646                } /* end s1 */
3647                if (sbufs>jdisstop) sbufs=jdisstop;
3648                for (sbufp=jdiSBUF, s1=0; s1<sbufs; s1++, sbufp+=jdislen) {
3649                    sscanf(sbufp,"%09"_LD_,&rev); hidx=jdiSBUH[s1];
3650                    h=jditable+hidx*hwidth;;
3651                    w=jdiSUM0w+hidx;
3652                    v=jdiSUM0v+hidx;
3653                    n=jdiSUM0n+hidx;
3654                    f=jdiFREQ1+hidx;
3655                  //if (jdiadd55) { sprintf(batchp,"A%"_LD_"\001",(LONGX)jdiadd55); batchp+=strlen(batchp); }
3656                    if (jdiadd55) { sprintf(batchp,"<%"_LD_" 0>" ,(LONGX)jdiadd55); batchp+=strlen(batchp); }
3657                    if (jdiaddfm == 2) 
3658                    sprintf(batchp,"%s|w|%8.6f|%8.6f|%8.6f|%8.6f|v|%8.6f|%8.6f|%8.6f|%8.6f|n|%4.2f|%4.2f|%8.6f|%4.2f|t|%6.4f|%6.4f|%"_LD_"|%"_LD_"|T|%4.2f|%4.2f|%"_LD_"|%"_LD_"|%"_LD_
3659                           ,         h
3660                           ,        *w / *f
3661                           ,        *w / jdintabs
3662                           ,        *w / jditotalw
3663                           ,        *w / jditotal1
3664                           ,        *v / *f
3665                           ,        *v / jdintabs
3666                           ,        *v / jditotalv
3667                           ,        *v / jditotal1
3668                           ,(float) *n / *f
3669                           ,(float) *n / jdintabs
3670                           ,(float) *n / jditotaln
3671                           ,(float) *n / jditotal1
3672                           ,        *w
3673                           ,        *v
3674                           ,        *n
3675                           ,        *f
3676                           ,         jditotalw
3677                           ,         jditotalv
3678                           ,         jditotaln
3679                           ,         jdintabs
3680                           ,         jditotal1
3681                    );
3682                    else
3683                    sprintf(batchp,"%s|T|%4.2f|%4.2f|%"_LD_"|%"_LD_"|%"_LD_"|t|%f|%f|%"_LD_"|%"_LD_"|w|%8.6f|%8.6f|%8.6f|%8.6f|v|%8.6f|%8.6f|%8.6f|%8.6f|n|%4.2f|%4.2f|%8.6f|%4.2f"
3684                           ,         h
3685                           ,         jditotalw
3686                           ,         jditotalv
3687                           ,         jditotaln
3688                           ,         jdintabs
3689                           ,         jditotal1
3690                           ,        *w
3691                           ,        *v
3692                           ,        *n
3693                           ,        *f
3694                           ,        *w / *f
3695                           ,        *w / jdintabs
3696                           ,        *w / jditotalw
3697                           ,        *w / jditotal1
3698                           ,        *v / *f
3699                           ,        *v / jdintabs
3700                           ,        *v / jditotalv
3701                           ,        *v / jditotal1
3702                           ,(float) *n / *f
3703                           ,(float) *n / jdintabs
3704                           ,(float) *n / jditotaln
3705                           ,(float) *n / jditotal1
3706                    );
3707                    if (parmtrace || jdipshow) printf("%"_LD_"|%d|%s\n",mfn,s1+1,batchp);
3708                    batchp+=strlen(batchp); 
3709                  //if (jdiadd55) { sprintf(batchp,"\001"); batchp+=strlen(batchp); }
3710                    if (jdiadd55) { sprintf(batchp,"</%"_LD_">",(LONGX)jdiadd55); batchp+=strlen(batchp); }
3711                    *w=0.0; *v=0.0; *n=0.0; *f=0; *h='\0'; //reinit
3712                } /* end hidx */
3713                jditotalw=0.0; jditotalv=0.00; jditotaln=0; jdintabs=0;jditotal1=0;
3714            } /* end jditotalw */
3715            if (jdiadd55) if (mx_bup[0]) { char *p=fldupdat(irec,mx_bup); if (p) { if (parmtrace) fatal(p); else fatal("mx/jdi/fldupdat"); } }
3716        } /* end parmtabjdip */
3717
3718        /* proc */
3719        if (mp_n) if (mp_edit(xmxp,irec,0,mp_n-1)) MXEXIT(1);
3720
3721        /* convert */
3722        if (tabconvp) {
3723            unsigned char *p,c;
3724            unsigned int n,i,pi;
3725            for (p=FIELDP(0), n=MFRmfrl-MFRbase; n--; p++) {
3726                pi=(int)(*p);
3727                i=(int)tabconvp[pi];
3728                c = (unsigned char )i;
3729                *p=c;
3730            }
3731        }
3732
3733#if MXFST
3734        if (fstpgmp) {
3735            *mx_bup='\0'; if (parmfstup) fst_batchup=mx_bup; /* fst_batchp=mx_bup; */
3736            fst_inter(fstpgmp,irec,stwp,
3737                        &lnk1p,maxlk1,&lnk2p,maxlk2,&qtylk1,&qtylk2);
3738            fst_fx[0]+=qtylk1; /* lnk1p */
3739            fst_fx[1]+=qtylk2; /* lnk2p */
3740            if (*mx_bup) if (fldupdat(irec,mx_bup)) fatal(mx_bup);
3741            if (fst_hdrp) if (*fst_hdrp) {
3742                sprintf(mx_bup,"H 33000 %d ",fst_hdru);
3743                batchp=mx_bup+strlen(mx_bup);
3744                memcpy(batchp,fst_hdrp,fst_hdru); *(batchp+fst_hdru)='\0';
3745                if (fldupdat(irec,mx_bup)) fatal(mx_bup);
3746            }
3747        }
3748#endif /* MXFST */
3749
3750
3751        if (parmdir)        prtdir(recp,MFRmfn);
3752
3753        if (parmfields)     prtfields(recp,MFRmfn);
3754
3755        if (fmtarea) {
3756#if BEFORE20010213
3757            fmt_inter(pgmp,irec,(LONGX)fmtlw,fmtarea,(LONGX)fmtasize);
3758#else
3759            if (fmt_inter(pgmp,irec,(LONGX)fmtlw,fmtarea,(LONGX)fmtasize) < 0)
3760                fatal("mx/pft/format execution error");
3761#endif
3762            if (parmoutmfntag) {
3763              char delim='|';
3764              int tag=parmoutmfntag+1;
3765              FFI len;
3766              char *p0=fmtarea;
3767              batchp=mx_bup; *batchp='\0';
3768              for (len=0, p=p0; ; ) {
3769                if (!*p || *p == '\r' || *p == '\n' || *p == delim) {
3770                    if (len) {
3771                        sprintf(batchp,"H%"_LD_" %"_LD_" ",(LONGX)tag,(LONGX)len); batchp+=strlen(batchp);
3772                        memcpy(batchp,p0,len); *(batchp+=len)='\0';
3773                    }
3774                    if (mx_bup[0]) {
3775                        /* out rec */
3776                        RECSTRU *recp;
3777                        RECORD(upirec,VRDBname(upcrec),VMF0nxtmfn(upcrec)); MFRstatus=ACTIVE;
3778                        sprintf(batchp+1,"A%"_LD_"/%"_LD_"/",(LONGX)parmoutmfntag,VMFRmfn(irec));
3779                        if (fldupdat(upirec,batchp+1)) fatal("mx/outpft/fldupdat/1");
3780                        if (fldupdat(upirec,mx_bup)) fatal("mx/outpft/fldupdat/2");
3781                        recupdat(upcrec,upirec);
3782                        /* re-init */
3783                        batchp=mx_bup; *batchp='\0'; tag=parmoutmfntag+1;
3784                    }
3785                    else tag++;
3786                    /* move line ptr */
3787                    while (*p == '\r' || *p == '\n' || *p == delim) p++;
3788                    p0=p; len=0;
3789                    if (!*p0) break;
3790                }
3791                else {
3792                    p++; len++;
3793                }
3794              } /* end for */
3795            } /* end parmoutpft */
3796            else
3797            if (ptabtable) {
3798              /* tabulate generated lines */
3799              char delim=0x01; //'|';
3800              FFI len;
3801              char *p0=fmtarea;
3802              for (len=0, p=p0; ; ) {
3803                /* next line */
3804                if (!*p || *p == '\r' || *p == '\n' || *p == delim) {
3805                    if (len) {
3806                        /* tabulate line */
3807                        LONGX hidx;
3808                        int hwidth=(ptabwidth+1);
3809                        int hfound;
3810                        int tabv=1;
3811                        if (parmtabtg) {
3812                            FFI loop;
3813                            DIRSTRU *dirp;
3814                            int xdir;
3815                            for (dirp=MFRdir, xdir=0, loop=MFRnvf; loop--; dirp++, xdir++) {
3816                                int len;
3817                                char *p;
3818                                if (dirp->tag != parmtabtg) continue;
3819                                p=FIELDP(xdir);
3820                                for (tabv=0, len=dirp->len; len--; p++) if (isdigit(*p)) tabv=tabv*10+((int)*p - (int)'0'); else break;
3821                            }
3822                        }
3823                        hidx=hashindex(ptabtable,ptabmaxprim,ptabwidth,p0,len,&hfound,1);
3824                        //if (hfound) if (!hfound) fatal("");
3825                        ptabCOUNT[hidx]+=tabv;
3826                        if (parmtrace) { char *h=ptabtable+hidx*hwidth; printf("[%9"_LD_"] %9"_LD_" %s\n",hidx,jdiFREQ1[hidx],h); }
3827                    }//end if len
3828                    /* move line ptr */
3829                    while (*p == '\r' || *p == '\n' || *p == delim) p++;
3830                    p0=p; len=0;
3831                    if (!*p0) break;
3832                }//if !*p || *p == '\r' || *p == '\n' || *p == delim
3833                else {
3834                    p++; len++;
3835                }//end if !*p || *p == '\r' || *p == '\n' || *p == delim
3836              } /* end for */
3837            } /* end ptabtable */
3838            else
3839            if (parmpftoutfp) { char *q=mx_bup;
3840              for (p=fmtarea; *p; p++)
3841                if (*p != '\r') *q++=(*p);
3842              *q='\0'; if (*mx_bup) fprintf(parmpftoutfp,"%s",mx_bup);
3843            }   
3844            else
3845              for (p=fmtarea; *p; p++)
3846                if (*p != '\r')
3847                    putchar(*p);
3848        }
3849
3850        if (parmsysp) {
3851            if (!parmsysa) {
3852                parmsysa=loadfile(NULL,'@',"",NULL,fmtasize+1,'\0');
3853        if (!parmsysa) fatal("ALLOC/parmsysa");
3854        }
3855#if BEFORE20010213
3856            recfmt(irec,MAXMFRL,parmsysp,parmsysa,fmtasize);
3857#else
3858            if (recfmt(irec,MAXMFRL,parmsysp,parmsysa,fmtasize) < 0)
3859                fatal("mx/sys/format execution error");
3860#endif
3861            for (shp=parmsysa; *shp; ) {
3862                for (p=shp; *p; p++)
3863                    if (*p == '\n' || *p == '\r') {
3864                        *p++ = '\0';
3865                        if (*p == '\n' || *p == '\r') *p++ = '\0';
3866                        break;
3867                    }
3868                if (*shp) {
3869                    n=1;
3870                    if (parmsyss) {
3871                        printf("%s\n",shp);
3872                        printf(prompt1p); isxp=gets(line); q=isxp;
3873                        if (ISX(q)) n=0;
3874                    }
3875                    if (n) system(shp);
3876                }
3877                shp = p;
3878            }
3879        }
3880
3881        if (parmmfrl)
3882            if (MFRmfrl > parmmfrl) {
3883                printf("MFN=%"_LD_" -> MFRmfrl=%d\n",MFRmfn,MFRmfrl);
3884                parmmfrl=MFRmfrl;
3885            }
3886
3887#if TB
3888    for (itagbin=0; itagbin < ntagbin; itagbin++) {
3889        tagbin=vtagbin[itagbin];
3890#if 1
3891#if BEFORE20000913
3892        if (tagbin > 999) {
3893#else
3894        if (tagbin == 0) {
3895#endif
3896          sprintf(line,"create=%"_LD_".dat",MFRmfn);
3897          dbxopenc(NULL,line,&fdtagbin,NULL,line,0,0);
3898          if (parmtrace) printf("+++ %s fd=%d\n",line,fdtagbin);
3899          for (xdir=0; xdir < MFRnvf; xdir++)
3900                if ((unsigned)CIWRITE(fdtagbin,FIELDP(xdir),DIRlen(xdir))
3901                != DIRlen(xdir)) fatal("mx/tbin/write");
3902          CLOSE(fdtagbin);
3903        } else
3904#endif
3905        if ((xdir=fieldx(irec,tagbin,1)) >= 0) {
3906          sprintf(line,"create=%"_LD_"%c%d",MFRmfn,'.',tagbin);
3907          dbxopenc(NULL,line,&fdtagbin,NULL,line,0,0);
3908          if (parmtrace) printf("+++ %s fd=%d\n",line,fdtagbin);
3909          for (xdir=0; xdir < MFRnvf; xdir++)
3910           if (DIRtag(xdir) == tagbin)
3911              if ((unsigned)CIWRITE(fdtagbin,FIELDP(xdir),DIRlen(xdir))
3912              != DIRlen(xdir)) fatal("mx/tbin/write");
3913          CLOSE(fdtagbin);
3914        }
3915    }
3916#endif /* TB */
3917
3918        if (parmcopy || parmiso2) {
3919#if RECXPND
3920            if (parmxpn01) recxpn00(irec,parmxpn01,parmxpn02); /* tag,dlm */
3921#endif
3922            if (parmiso2 && MFRnvf > 0) {
3923                if (parmiso2 == 1) iso_write(recp,parmisoxfs,parmisoxgs,parmisoldrtag);
3924                        else {
3925                            p=mx_bup; *p='\0';
3926                            for (xdir=0; xdir < MFRnvf; xdir++) {
3927                                memcpy(p,FIELDP(xdir),n=DIRlen(xdir));
3928                                p+=n;
3929                                *p++='|';
3930                            }
3931                            *(p-1)='\n'; *p='\0';
3932                            fprintf(fpfix,"%s",mx_bup);
3933                        }
3934            }
3935            if (parmcopy) if (!parmoutmfntag) {
3936                if (parmdupp) {
3937                    if (MFRnvf == 0) {
3938                        if (fldupdat(irec,"A1//")) fatal("A1//");
3939                    }
3940                    for (p=parmdupp; *p; p++) {
3941                        record(upirec,VRDBname(upcrec),VMF0nxtmfn(upcrec));
3942                        VMFRstatus(upirec)=ACTIVE;
3943                        q=mx_bup; n=DIRlen(0); n++;
3944                        sprintf(q,"H%d %d ",DIRtag(0),n); q+=strlen(q);
3945                        if (parmdupx == DUPPLEFT) *q++ = *p;
3946                        memcpy(q,FIELDP(0),DIRlen(0)); q+=DIRlen(0);
3947                        if (parmdupx == DUPPRIGHT) *q++ = *p;
3948                        *q = '\0';
3949                        if (fldupdat(upirec,mx_bup)) fatal(mx_bup);
3950                        recupdat(upcrec,upirec);
3951                    }
3952                }
3953                else {
3954                    n=1;
3955                    if (parmcopy == UPDATF) if (MFRnvf <= 0) n=0;
3956                    if (parmcopy == UPDATF && n) {
3957                        nbytes=sizeof(LONGX)*MAXUPFTAG;
3958                        if (!tagfreq) {
3959                            tagfreq=(LONGX *)ALLOC((ALLOPARM)nbytes);
3960                            if (tagfreq == (LONGX *)ALLONULL)
3961                                fatal("ALLOC/tagfreq");
3962                        }
3963                        memset(tagfreq,0x00,nbytes);
3964                        record(upirec,VRDBname(upcrec),MFRmfn); /* RLOCK */
3965                        if (VRECrc(upirec) == RCLOCK) FATLOCK;
3966                        for (xdir=0; xdir < MFRnvf; xdir++)
3967                            if (DIRtag(xdir) >= MAXUPFTAG) fatal("MAXUPFTAG");
3968                            else tagfreq[DIRtag(xdir)]++;
3969                        batchp=mx_bup;
3970                        for (utag=0; utag < MAXUPFTAG; utag++)
3971                            if (tagfreq[utag]) {
3972                                sprintf(batchp,"D%"_LD_,(LONGX)utag);
3973                                batchp+=strlen(batchp);
3974                            }
3975                        *batchp='\0';
3976                        if ((p=fldupdat(upirec,mx_bup)) != NULL) fatal(p);
3977                        batchp=mx_bup;
3978                        for (xdir=0; xdir < MFRnvf; xdir++) {
3979                            sprintf(batchp,"H%6"_LD_" %6"_LD_" ",
3980                                (LONGX)DIRtag(xdir),(LONGX)DIRlen(xdir));
3981                            batchp+=strlen(batchp);
3982                            memcpy(batchp,FIELDP(xdir),DIRlen(xdir));
3983                            batchp+=DIRlen(xdir);
3984                        }
3985                        *batchp='\0';
3986                        if ((p=fldupdat(upirec,mx_bup)) != NULL) fatal(p);
3987                    }
3988
3989                    if (parmcopy == MERGE) {
3990                        record(upirec,VRDBname(upcrec),MFRmfn); /* RLOCK */
3991                    if (VRECrc(upirec) == RCLOCK) FATLOCK;
3992                        if (VRECrc(upirec) == RCNORMAL) n=0;
3993                    }
3994
3995                    if (parmcopy == APPEND) if (MFRnvf <= 0) n=0;
3996
3997                    if (n) {
3998#if MULTI
3999                        if (VRDBnetws(upcrec) != MONONETS) {
4000                            if (parmcopy == APPEND) {
4001                                memcpy(VMFX(upirec),MFX,MFRmfrl);
4002                                VMFRmfn(upirec)=0L;
4003                                VRECwlock(upirec)|=NEWREC;
4004                            }
4005                            else {
4006                                if (parmcopy != UPDATF) {
4007                                    record(upirec,VRDBname(upcrec),MFRmfn); /* RLOCK */
4008                            if (VRECrc(upirec) == RCLOCK) FATLOCK;
4009                                    memcpy(VMFX(upirec),MFX,MFRmfrl);
4010                                }
4011                                VRECwlock(upirec)|=NEWREC|FORCE;
4012                            }
4013                        }
4014                        else {
4015                            if (parmcopy != UPDATF)
4016                            reccopy(upirec,upcrec,recp,MFRmfn);
4017                            if (parmcopy == APPEND)
4018                                VMFRmfn(upirec)=VMF0nxtmfn(upcrec);
4019                        }
4020                        recupdat(upcrec,upirec);
4021#else
4022                        if (parmcopy != UPDATF)
4023                            reccopy(upirec,upcrec,recp,MFRmfn);
4024                        if (parmcopy == APPEND)
4025                            VMFRmfn(upirec)=VMF0nxtmfn(upcrec);
4026                        recupdat(upcrec,upirec);
4027#endif
4028                    }
4029                }
4030            }
4031        }
4032
4033#if MXIFUPD
4034        if (ifnp) {
4035            if (svdifupx) {
4036#if BEFORE20000831
4037#else
4038                if (svdifupx == 1) {
4039                    upif_init(ifnp); svdifupx=2;
4040#if MULTI
4041#if CIAPI
4042                    if (dbnp_dbxnetws(ifnp) == FULLNETS) svdifupy=1;
4043#else /* CIAPI */
4044                    if (dbxstorp(ifnp)->dbxnetws == FULLNETS) svdifupy=1;
4045#endif /* CIAPI */
4046#endif /* MULTI */
4047                }
4048                else if (svdifupy) upif_init(ifnp);
4049#endif
4050                svdifupd(lnk1p,qtylk1,lnk2p,qtylk2,             /* add new */
4051                         NULL,0,NULL,0,                         /*         */
4052                         pstflag,0L);
4053#if CIAPI
4054                     dbnp_dbxirecs(ifnp)+=1;
4055                     dbnp_dbxipadd(ifnp)[0]+=qtylk1;
4056                     dbnp_dbxipadd(ifnp)[1]+=qtylk2;
4057#else /* CIAPI*/
4058                ifndbxp->dbxirecs++;
4059                ifndbxp->dbxipadd[0]+=qtylk1;
4060                ifndbxp->dbxipadd[1]+=qtylk2;
4061#endif /* CIAPI*/
4062#if BEFORE20000831
4063#else
4064                if (svdifupy) { upif_end(ifnp,pstflag); invflush(ifnp); }
4065#endif
4066            }
4067            else
4068                ifupdat(VRDBname(mstcrec),VMFRmfn(mstirec),VMFRmfn(mstirec),
4069                        ifnp,fstpgmp,stwp,maxlk1,maxlk2,pstflag,endup);
4070        }
4071#endif
4072
4073    }  /* end of record */
4074
4075
4076    if (ISX(isxp)) MXEXIT(0);
4077
4078    if (parmwait && boolqryp != NULL) {
4079        do {
4080            printf(prompt2p); isxp=gets(line); p=isxp;
4081            if (!p) break;
4082        } while (!*p);
4083        if (ISX(p) || !p)
4084            MXEXIT(0);
4085        if (mxbool(xmxp,p,dbnp)) MXEXIT(1); count=0;
4086        goto LOOP;
4087    }
4088
4089    MXEXIT(0);
4090}
Note: See TracBrowser for help on using the browser.