root/trunk/cisis.h

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

essage first commit

Line 
1/* ***********************************************************
2CISIS.H
3
4CISIS application programs and functions include CISIS.H
5as their main header file.
6
7CISIS application programs include CIRUN.H, providing
8the CISIS Interface run time pointers, control variables
9and other CISIS application mandatory areas.
10
11Please replace ciaot.h to cirun.h in include statements
12of existing CISIS Interface applications.
13
14                                AOT, August 19, 1992.
15
16CISIS Interface v3.20 supports MicroISIS dbn.par file.
17It might be necessary to change existing CISIS applications
18to add a data base name parameter - to get a dbn.par file -
19in the following functions: dbxopen(), dbxcipar(),
20loadfile() and loadstw().
21
22                                AOT, March 6, 1996.
23
24*********************************************************** */
25
26
27#ifndef CISIS_H
28#define CISIS_H
29
30/* *****************************************************
31CISIS environment
32***************************************************** */
33
34#define GCC         01
35#if GCC
36#ifndef PACKED
37/*#define PACKED2 __attribute__ ((aligned(2),packed))*/
38#define PACKED __attribute__ ((aligned(2)))
39#endif
40#endif
41
42#define PC          0
43#define DOS32BITS   0
44#define MSC         0
45#define VAX         0
46#define MPE         0
47#define UNIX        01
48#define SUN         0
49#define UNISYS      0
50#define UNISYSGDB   0
51#define UNISYSCPU   0
52#define INTELCPU    1
53#define BRME        0
54#define BRMXCPU     0
55#define CDCS4320    0
56
57#define CNV_PCFILES 0   /* Standard MicroISIS PC format conversion */
58#define CNV_PCBINUM 0   /* PC data representation (swapped) conversion */
59
60#define PCREADLINUX 0   /* Read Linux's M/F in PC */
61
62#ifdef CIAPI_SOURCE
63#define CICPP       1   /* CISIS CPP preprocessor */
64#endif
65#ifdef ISIS_DLL
66#define CICPP       1   /* CISIS CPP preprocessor */
67#endif
68#ifdef CI_WINISIS
69#define CICPP       1   /* CISIS CPP preprocessor */
70#endif
71#ifndef CICPP
72#define CICPP       0   /* CISIS CPP preprocessor */
73#endif
74
75#if CICPP
76#ifndef USE_GDBFMT
77#ifdef CI_WINISIS
78#define USE_GDBFMT  1   /* CICPP/FST+IFU with GDB New FORMAT Release 2 */
79#else
80#define USE_GDBFMT  0   /* CICPP/FST+IFU with CISIS FORMAT */
81#endif
82#endif
83#endif /* CICPP */
84
85#if CICPP
86#ifndef MAXNDBX
87#if BEFORE990318
88#define MAXNDBX  256L   /* maximum #entries in vdbxp[] */
89#else
90#define MAXNDBX  2048L  /* maximum #entries in vdbxp[] */
91#endif /* BEFORE990318 */
92#endif
93#endif /* CICPP */
94
95#if UNISYS || UNISYSCPU
96#define ISISUNISYS  1
97#endif
98
99#if PC || VAX || GCC || (UNISYS && !UNISYSGDB)
100#define ANSI        1
101#endif
102
103#if PC /* || VAX */
104#define CRLF        1
105#else
106#define CRLF        0
107#endif
108
109#if PC || VAX || UNISYSCPU || INTELCPU || SUN
110#define SWAPPED     1
111#endif
112
113#ifdef PACKED
114#define ISPACKED    1
115#else
116#if SWAPPED
117#if !UNIX /*#if PC || VAX*/
118#define ISPACKED    1
119#endif /* !UNIX */
120#endif
121#define PACKED
122#endif
123
124#if MPE || VAX || UNIX
125#define O_BINARY    0
126#define O_DENYNONE  0
127#endif
128
129#if SUN
130#define SUNBUG_UNSIGNED 1 /* cannot test if link records have sorted postings */
131#if GCC
132#define SUNBUG_GCC1     1 /* cannot access node just read in noderead() */
133#endif
134#endif /* SUN */
135
136
137/* *****************************************************
138CISIS configuration
139***************************************************** */
140
141#define UC_EXTENSION ISISUNISYS  /* ISIS/UNISYS upper case .extension */
142#define LINK_7544KEY ISISUNISYS  /* ISIS/UNISYS fixed-length link */
143#define MST0FILL0XFF ISISUNISYS  /* ISIS/UNISYS .mst 1st block filler */
144
145#if !CICPP
146#ifndef CIAPI
147#define CIAPI         0                   /* para compilar aplicacoes em C que usem CIAPI */
148#endif
149#if CIAPI
150#ifndef TLS
151#define TLS        0                   /* setar 1 para compilar zserver em windows-95 */
152#endif
153#endif
154#endif
155#ifndef CIB71
156#define CIB71       1                   /* CISIS Rosnier Mijares Valdes' search function */
157#endif
158#ifndef CIB64
159#define CIB64       0                   /* cib62 using ISIS I/F */
160#endif
161#ifndef CDMDL
162#define CDMDL       0                   /* BRM CD-ROM Retrieval Interface */
163#endif
164#ifndef WWWISIS
165#define WWWISIS     00
166#endif /* WWWISIS */
167#define BIGREC      0                   /* BRM CD-ROM Retrieval Interface */
168#ifndef  LINDLUX
169#define LINDLUX     0                   /* ifupd2 */
170#endif
171#define DBXMSTXL    1                   /* extended .mst capacity */
172#if !EXCFMCGI
173#define CICGI       1                   /* cicgi0/cicgi1 */
174#endif
175#if CICPP
176#define FATRAP      0                   /* fatal() trapping */
177#else /* CICPP */
178#define FATRAP      1                   /* fatal() trapping */
179#endif /* CICPP */
180
181#ifndef CIFFI
182#define CIFFI       0                   /* size-t mfrl/base/pos/len */
183#endif
184#ifndef CIWTF
185#if !CICPP
186#if !CIAPI
187#if GCC
188#if CIFFI
189#define CIWTF       1                    /* WTFUN support */
190#else
191#define CIWTF       0                    /* WTFUN support */
192#endif
193#endif /* GCC */
194#endif /* CIAPI */
195#endif /* CICPP */
196#endif
197
198
199#if !CDMDL
200
201#ifndef LIND
202#if CIFFI
203#define LIND        1                   /* MY: must be off */
204#else
205#define LIND        0                   /* MY: must be off */
206#endif
207#endif
208#ifndef ISISXL
209#if CIFFI || LIND
210#define ISISXL      1                   /* Large keys - standard for CIFFI */
211#else
212#define ISISXL      00                   /* Large keys */
213#endif
214#endif
215#ifndef ISISXL512
216#define ISISXL512   00                  /* very Large keys */
217#endif
218#ifndef CNLI
219#define CNLI        1                   /* MY: must be off */
220#endif
221#define ZTREE       1                   /* MY: must be off */
222#define SAMEL       0                   /* MY: must be off */
223
224#ifndef CI_WINISIS
225#define RECGIZM     1                   /* CIGIZ */
226#define RECXPND     0                   /* MX: putdir/getdir */
227#define RECDECO     1                   /* DEC */
228#endif
229#define GEN_ISI     1                   /* enable iso_open()/iso_read() */
230#define GEN_UTL     1                   /* enable except loaductb() */
231
232#define INVXBOOL    (LIND || CIB64 || CIB71) /* 0 */       /* Bx0 use several inverted files */
233#define  TW_BOOL    0                   /* Bx0 multiple ifp's for text word */
234
235#define CIPAR       1                   /* dbxcipfp & dbxcdcip processing */
236#define CIPARIC     0                   /* CIPAR ignore case */
237#ifdef ISIS_DLL
238#define GIPAR       1                   /* dbn.par & dbxgicip processing */
239#endif
240#ifdef CI_WINISIS
241#define GIPAR       1                   /* dbn.par & dbxgicip processing */
242#endif
243#ifndef GIPAR
244#define GIPAR       0                   /* dbn.par & dbxgicip processing */
245#endif
246
247#define MULTI       1                   /* Multi-user operation */
248#define IFUPDATE    1                   /* Inverted file update */
249#define MFUPDATE    1                   /* Master file update */
250
251#else /* CDMDL */
252
253#define ISISXL      1                   /* Large keys */
254#define LIND        1                   /* MY: must be off */
255#define CNLI        1                   /* MY: must be off */
256#define ZTREE       1                   /* MY: must be off */
257#define SAMEL       0                   /* MY: must be off */
258
259#define RECGIZM     1                   /* CIGIZ */
260#define RECXPND     0                   /* MX: putdir/getdir */
261#define RECDECO     1                   /* DEC */
262#define GEN_ISI     1                   /* enable iso_open()/iso_read() */
263#define GEN_UTL     1                   /* enable except loaductb() */
264
265#define INVXBOOL    1                   /* Bx0 use several inverted files */
266#define  TW_BOOL    0                   /* Bx0 multiple ifp's for text word */
267
268#define CIPAR       1                   /* dbxcipfp & dbxcdcip processing */
269#define CIPARIC     0                   /* CIPAR ignore case */
270#define GIPAR       0                   /* dbn.par & dbxgicip processing */
271
272#define MULTI       01                   /* Multi-user operation */
273#define IFUPDATE    01                   /* Inverted file update */
274#define MFUPDATE    1                   /* Master file update */
275
276#endif /* CDMDL */
277
278#if _LARGEFILE64_SOURCE
279#if  (_FILE_OFFSET_BITS != 64)
280#error "_FILE_OFFSET_BITS != 64"
281#endif
282#define LSEEK64 lseek64
283#define P_OFF_T "lld"
284#define LONG_LONG long long
285#else /* _LARGEFILE64_SOURCE */
286#if (_FILE_OFFSET_BITS == 64)
287#error "_FILE_OFFSET_BITS == 64"
288#endif
289#define LSEEK64 lseek
290#define P_OFF_T "ld"
291#define LONG_LONG long
292#endif /* _LARGEFILE64_SOURCE */
293
294
295/* *****************************************************
296CISIS/C++ DLL export
297***************************************************** */
298#if CICPP
299/* DLL export */
300#if defined (BUILDING_YOUR_DLL)
301#define _YOURCLASS _export
302#else
303#if defined (USING_YOUR_DLL)
304#define _YOURCLASS _import
305#else
306#define _YOURCLASS
307#endif /* USING_YOUR_DLL */
308#endif /* BUILDING_YOUR_DLL */
309#endif /* CICPP */
310
311/*
312        Required CISIS.H header files
313*/
314
315#include <stdio.h>   /* FILE */
316
317/*
318        Compiler dependent header files
319*/
320
321#if PC
322#include <fcntl.h>
323#include <process.h>
324#include <io.h>
325#include <stdlib.h>
326#include <limits.h>
327#include <dos.h>
328#include <sys/types.h>
329#endif
330
331#if VAX
332#include <file.h>
333#include <stdlib.h>
334#endif
335
336#if MPE
337#include <fcntl.h>
338#include <stdlib.h>
339#include <limits.h>
340#endif
341
342#if UNIX
343#include <fcntl.h>
344#include <unistd.h>
345#include <sys/types.h>
346#include <stdlib.h>
347#include <limits.h>
348#include <errno.h>
349#endif
350
351#ifndef SIXTY_FOUR
352#define SIXTY_FOUR  0
353#endif /* SIXTY_FOUR */
354
355#if SIXTY_FOUR
356#define LONGX int
357#define LONGX_MAX INT_MAX
358#define _LD_ "d"
359#else /* SIXTY_FOUR */
360#define LONGX long
361#define LONGX_MAX LONG_MAX
362#define _LD_ "ld"
363#endif /* SIXTY_FOUR */
364
365#define UBYTE       unsigned char       /* UCHR */
366#define UWORD       unsigned short      /* INT  */
367#if BEFOREWINDEFH
368#define ULONG       unsigned LONGX       /*      */
369#endif
370#if BEFOREWINNTH
371#define CHAR        UBYTE
372#else
373#define UCHR        UBYTE
374#endif
375#if BEFOREWINDEFH
376#define INT         UWORD
377#endif
378
379#if CIFFI
380#define FFI         unsigned int /* size_t = bug no linux - RP, 27/05/2003 */
381#define MFRL_MAX    INT_MAX
382#else
383#define FFI         UWORD /* UWORD = UWORD unsigned short */
384#define MFRL_MAX    SHRT_MAX
385#endif
386
387
388/*
389        Memory allocation
390*/
391
392#if CICPP           /* alloc substituido por new */
393
394#ifndef CINEWCPP
395#define CINEWCPP 1  // AOT,HB 31/07/2002 */
396#endif
397
398#if MSC || !CINEWCPP                 /* HB, 27/05/2002 */
399#define BAD_ALLOC ...   /* catch qualquer coisa */
400#else /* MSC || !CINEWCPP */
401#if 0                   /* catch especifico */
402#define BAD_ALLOC xalloc
403#include <except.h>
404#else /* 0 */
405#include <new>
406#define BAD_ALLOC std::bad_alloc
407#endif /* 0 */
408#endif /* MSC || !CINEWCPP */
409
410#define ALLOMAXV    64000U /* <==== RPIVA VAI MUDAR 20010214*/
411#define ALLOPARM    unsigned int
412#define ALLONULL    NULL
413//#define CORELEFT()  640000
414
415#else /* CICPP */
416
417#if PC
418#if MSC
419#include <malloc.h>
420#define ALLOMAXV    64000U
421#define ALLOC       malloc
422#define ALLOPARM    unsigned int
423#define ALLONULL    NULL
424#define FREE        free
425#define CORELEFT    coreleft
426#else /* MSC */
427#if DOS32BITS /* 20000518 */
428#include <alloc.h>
429#if BEFORE20010105
430#define ALLOMAXV    UINT_MAX /* 640000L */ /* AOT/RP, 27/03/2001 */
431#else
432#define ALLOMAXV    INT_MAX  /* 640000L */ /* AOT/RP, 27/03/2001 */
433#endif
434#define ALLOC       malloc
435#define ALLOPARM    size_t
436#define ALLONULL    NULL
437#define FREE        free
438#define CORELEFT    coreleft
439#else /* DOS32BITS 20000518 */
440#include <alloc.h>
441#define ALLOMAXV    64000L
442#define ALLOC       farmalloc
443#define ALLOPARM    unsigned LONGX
444#define ALLONULL    NULL
445#define FREE        farfree
446#define CORELEFT    farcoreleft
447#endif /* DOS32BITS 20000518 */
448#endif
449#endif /* PC */
450
451#if VAX
452#define ALLOC       malloc
453#define ALLOPARM    size_t
454#define ALLOMAXV    640000L
455#define ALLONULL    NULL
456#define FREE        free
457#define CORELEFT    coreleft
458#endif
459
460#if MPE
461#include <malloc.h>
462#define ALLOC       malloc
463#define ALLOPARM    unsigned int
464#define ALLOMAXV    64000000L
465#define ALLONULL    NULL
466#define FREE        free
467#define CORELEFT    coreleft
468#endif
469
470#if UNIX
471#include <malloc.h>
472#define ALLOC       malloc
473#define ALLOPARM    unsigned
474#define ALLOMAXV    INT_MAX /* 64000000L */ /* 64000L*/ /* 128000000L*/ /* UINT_MAX */
475#define ALLONULL    NULL
476#define FREE        free
477#define CORELEFT    coreleft
478#if !GCC
479#define size_t      int
480#endif
481#endif
482
483#endif /* CICPP */
484
485
486/*
487        MAX PATH NAME
488*/
489#if PC
490#if DOS32BITS
491#define CIMPL 512
492#else /* DOS32BITS */
493#define CIMPL (128+4)
494#endif /* DOS32BITS */
495#else
496#define CIMPL 512
497#endif /* PC */
498
499
500/*
501        Unbuffered low level I/O
502*/
503#if CICPP
504#define PERMIS      0644
505#define CREAT       creat
506#define OPEN        open
507#define CLOSE       close
508#define CIREAD      read
509#define CIWRITE     write
510#else /* CICPP */
511#if PC
512#if MSC
513#define PERMIS      0644
514#define CREAT       creat
515#if MULTI
516#define OPEN        sopen
517#else
518#define OPEN        open
519#endif
520#define CLOSE       close
521#define CIREAD      read
522#define CIWRITE     write
523#else /* MSC */
524#define PERMIS      0000
525#if DOS32BITS /* UINT_MAX -1 */
526#define CREAT       _rtl_creat
527#define OPEN        _rtl_open
528#define CLOSE       _rtl_close
529#define CIREAD      _rtl_read
530#define CIWRITE     _rtl_write
531#else /* DOS32BITS */
532#define CREAT       _creat
533#define OPEN        _open
534#define CLOSE       _close
535#define CIREAD      _read
536#define CIWRITE     _write
537#endif /* DOS32BITS */
538#endif /* MSC */
539#else
540#if VAX
541#define PERMIS      0644
542#endif
543#if MPE
544#define PERMIS      0644
545#endif
546#if UNIX
547/*#define PERMIS      0644*/
548#define PERMIS      0664    /* Requested by Chico in apr 2012 */
549#endif
550#define CREAT       creat
551#define OPEN        open
552#define CLOSE       close
553#define CIREAD      read
554#define CIWRITE     write
555#endif
556#endif /* CICPP */
557
558/*
559        Standard Library extensions
560*/
561
562
563#define GEN_CORELEFT            MSC || MPE || VAX || UNIX  || DOS32BITS /* 20000518 */
564#define GEN_LABS                MPE || VAX || (UNIX && !UNISYS)
565#define GEN_STRSTR              MPE || VAX || (UNIX && !UNISYSGDB && !SUN && !BRME && !GCC)
566#define GEN_STRUPR              MPE || VAX || UNIX
567#define GEN_STRREV              MPE || VAX || UNIX
568#define GEN_MEMICMP             /* CIPARIC && */ (MPE || VAX || (UNIX && !BRME))
569
570#if CDCS4320 || MPE || (GCC && !CICPP) || BRME
571#define CONST                   /* not supported */
572#else
573#define CONST const
574#endif
575
576#if GEN_CORELEFT
577#if ANSI
578unsigned LONGX coreleft(void);
579#else
580unsigned LONGX coreleft();
581#endif
582#endif
583
584#if GEN_LABS
585#if ANSI
586long labs(long x);
587#else
588long labs();
589#endif
590#endif
591
592#if GEN_STRSTR
593#if ANSI
594char *strstr(CONST char *s1, CONST char *s2);
595#else
596char *strstr();
597#endif
598#endif
599
600#if GEN_STRUPR
601#if ANSI
602char *strupr(char *p);
603#else
604char *strupr();
605#endif
606#endif
607
608#if GEN_STRREV
609#if ANSI
610char *strrev(char *p);
611#else
612char *strrev();
613#endif
614#endif
615
616#if GEN_MEMICMP
617#if ANSI
618int memicmp(CONST void *s1, CONST void *s2, size_t n);
619#else
620int memicmp();
621#endif
622#endif
623
624
625#if CICPP
626class _YOURCLASS CISISX;
627#endif /* CICPP */
628
629/*
630        FATRAP support
631*/
632
633#if FATRAP
634#include <setjmp.h>
635#endif
636
637/* *****************************************************
638CISIS/C++ extern "C"
639***************************************************** */
640#if CICPP
641#ifdef __cplusplus
642extern "C" {
643#endif
644#endif /* CICPP */
645
646
647/* *****************************************************
648CIDBX.H
649***************************************************** */
650
651#if MAXMFRL==0
652#if CIFFI
653#define MAXMFRL    1048576L     /* 1024*1024 ! */
654#else /* CIFFI */
655#if UNIX || WWWISIS || USE_CIREC || DOS32BITS
656#if BEFORE20010109
657#define MAXMFRL    30000L       /*     */
658#else
659#if MULTI
660#define MAXMFRL    32767L       /*     */
661#else /* MULTI */
662#define MAXMFRL    63002L       /*     */
663#endif /* MULTI */
664#endif
665#else /* UNIX || WWWISIS || USE_CIREC || DOS32BITS */
666#define MAXMFRL     8192L       /* gdb */
667#endif /* UNIX || WWWISIS || USE_CIREC || DOS32BITS */
668#endif /* CIFFI */
669#endif /* MAXMFRL */   
670
671#if ISISXL
672#define LE1         16          /* gdb ISISXL */
673#if SUPERISIS
674#define LE2         256
675#else
676#if ISISXL512
677#define LE2         512         /* gdb ISISXL */
678#else
679#define LE2         60          /* gdb ISISXL */
680#endif
681#endif /* SUPERISIS */
682#else /* ISISXL */
683#define LE1         10          /* gdb */
684#define LE2         30          /* gdb */
685#endif /* ISISXL */
686
687
688#define XRBSIZ      512         /* gdb */
689#define XRSHIFT     9           /*     */
690
691#define XRMAXTIV    127         /* gdb */
692#define XRMAXTV1    126         /*     */
693
694#define MSBSIZ      512         /* gdb */
695#define MSBSHIFT    9           /*     */
696
697#define XRXDIVIDE   2048        /* gdb */
698#define XRXSHIFT    11          /*     */
699#define XRXMASK     0x000001FF  /* gdb no IF pending */
700#define XRXMASKN    0x00000400  /* gdb ++ IF pending */
701#define XRXMASKU    0x00000200  /* gdb ++ IF pending */
702
703#if LIND
704#ifndef LIND4
705#define LIND4       1 /*0*/
706#endif /* LIND4 */
707#endif /* LIND */
708
709#if LIND4
710#define MAXUPDMFN   0x7FFFFFFFL /* gdb posting */
711#else /* LIND4 */
712#define MAXUPDMFN   0x00FFFFFFL /* gdb posting */
713#endif /* LIND4 */
714
715#define MSMFTUSR    0           /* gdb non system */
716#define MSMFTMSG    1           /* gdb msg data base */
717
718#define XRPOS       LONGX
719#define XRPTR       /*off_t*/ LONGX
720#define XRPOSSIZ    sizeof(XRPOS)
721#define XRPTRSIZ    sizeof(XRPTR)
722
723typedef struct xrstru {
724    XRPOS     xrxrpos;           /* gdb .xrf blk order */
725    XRPTR     xrmfptr[XRMAXTIV]; /* gdb mfr ptrs */
726} XRSTRU;
727
728typedef struct msstru {
729    char     msbuff[MSBSIZ];    /* gdb .mst blk */
730    LONGX     msbufn;            /* gdb .mst blk order - simulated */
731} MSSTRU;
732
733
734#define IFBSIZ      512         /* gdb */
735#define IFSHIFT     9           /*     */
736
737#define IFMAXTIV    127         /* gdb */
738
739#define PUNT        LONGX        /* gdb paho 1988 */
740
741#define INFO        LONGX        /* gdb */
742
743#if LIND
744#ifndef INFO8
745#define INFO8       1            /* 8-byte ptr and size (info1/info3) in .ly1/.ly2 IDXE - AOT/HB 14/03/2008 */
746#endif /* INFO8 */
747
748#if INFO8
749#if SIXTY_FOUR
750#if _LARGEFILE64_SOURCE
751#define INFX        off_t
752#else  /* _LARGEFILE64_SOURCE */
753#define INFX        unsigned int
754#endif /* _LARGEFILE64_SOURCE */
755#else  /* SIXTY_FOUR */
756#define INFX        off_t        /* gdb */
757#endif /* SIXTY_FOUR */
758#else  /* INFO8 */ 
759#define INFX        LONGX        /* gdb */
760#endif /* INFO8 */
761#else /* LIND */
762#define INFX        LONGX        /* gdb */
763#endif /* LIND */
764
765#define INFOSIZE    sizeof(INFO)
766#define IFHDRINFOS  5           /* check in trminit() */
767#define IFPSTINFOS  2           /*                    */
768#define IFNVSPLT    28          /* gdb .ifp never split - header+posting */
769
770#define MAXLIV      8           /* INVMAP.nx */
771#define NEGLIV      (-1)        /* INVMAP.cn[treecase].liv - gdb */
772
773#define ORDN        5           /* gdb */
774#define TWORDN      10          /*     */
775
776#define ORDF        5           /* gdb */
777#define TWORDF      10          /*     */
778
779#define CNTN        15          /* gdb */
780#define CNTK        5           /* gdb */
781
782#if SAMEL
783#define MAXSAMEL    8           /* max no. of .ifp on same leaf */
784#endif
785
786
787typedef struct cnstru {
788    UWORD      idtype      PACKED;/* gdb .cnt idtype */
789    UWORD      ordn        PACKED;/* gdb .cnt ordn */
790    UWORD      ordf        PACKED;/* gdb .cnt ordf */
791    UWORD      n           PACKED;/* gdb .cnt n */
792    UWORD      k           PACKED;/* gdb .cnt k */
793    short    liv         PACKED;/* gdb .cnt liv = no of index levels */
794/* 6*2=12 */
795    PUNT     posrx       PACKED;/* gdb .cnt posrx = pos of root node */
796    PUNT     nmaxpos     PACKED;/* gdb .cnt nmaxpos */
797    PUNT     fmaxpos     PACKED;/* gdb .cnt fmaxpos */
798    UWORD      abnormal    PACKED;/* gdb .cnt abnormal */
799/*  CNBUNI   +2 */
800} CNSTRU;
801
802typedef struct n0stru {
803    PUNT     pos         PACKED;/* gdb .n0x pos */
804    UWORD      ock         PACKED;/* gdb .n0x ock */
805    UWORD      it          PACKED;/* gdb .n0x it */
806    char     idxchars[1] PACKED;/* gdb .n01 and .n02 idx */
807} N0STRU;
808
809typedef struct l0stru {
810    PUNT     pos         PACKED;/* gdb .l0x pos */
811    UWORD      ock         PACKED;/* gdb .l0x ock */
812    UWORD      it          PACKED;/* gdb .l0x it */
813    PUNT     ps          PACKED;/* gdb .l0x ps */
814#if LIND
815    PUNT     psb         PACKED;/* tlc gdb .l0x ps backward */
816#endif
817    char     idxchars[1] PACKED;/* gdb .l01 and .l02 idx */
818} L0STRU;
819
820
821typedef struct nxstru {
822    int      pages;             /* no of memo buffers alloced */
823    int      left;              /* no of memo buffers still free */
824    char    *basep;             /* area addr */
825} NXSTRU;
826
827#define NTREE           2
828#define LTXPAGES        128L
829#define LUXPAGES        1024L
830#define LVXPAGES        1024L /* lvxmxmfn/8+1 */
831#define LVXIYPBS        8192L /* ou INT_MAX */
832
833typedef struct invmap {
834#if LINDLUX
835    LONGX ltxthresh;
836    LONGX ltxpages[NTREE];
837    N0STRU *ltxvpagp[NTREE][1+LTXPAGES];
838    LONGX luxthresh;
839    LONGX luxpages[NTREE];
840    L0STRU *luxvpagp[NTREE][1+LUXPAGES];
841    int  lvxiflind;
842    LONGX lvxmaxmfn;
843    LONGX lvxpages;
844    char *lvxvpagp[1+LVXPAGES];
845    FILE *lvxfplog;
846#endif /* LINDLUX */
847    char    *ifl1p;             /* .l01 block */
848    char    *ifl2p;             /* .l02 block */
849#if SAMEL
850    int      iflxn;             /* #total */
851#endif
852#if ZTREE
853    int      iflzx;             /* ztree */
854#endif
855#if 1 /* IFUPDATE */
856    int      cnopn;             /* =dbxopen(.cnt) */
857#endif
858    int      n1opn;             /* =dbxopen(.n01) */
859    int      n2opn;             /* =dbxopen(.n02) */
860    int      l1opn;             /* =dbxopen(.l01) */
861    int      l2opn;             /* =dbxopen(.l02) */
862#if SAMEL
863    int      ifopn[MAXSAMEL];   /* =dbxopen(.ifp) */
864#else
865    int      ifopn;             /* =dbxopen(.ifp) */
866#endif
867#if 1 /* IFUPDATE */
868    int      cnopw;             /* dbxopenw/w(.cnt) */
869#endif
870    int      n1opw;             /* dbxopenw/w(.n01) */
871    int      n2opw;             /* dbxopenw/w(.n02) */
872    int      l1opw;             /* dbxopenw/w(.l01) */
873    int      l2opw;             /* dbxopenw/w(.l02) */
874    int      ifopw;             /* dbxopenw/w(.ifp) */
875    int      ifopv;             /* dbxflock/dbxulock(.ifp) */
876    CNSTRU   cn[2];             /* .cnt recs */
877    NXSTRU   nx[2][MAXLIV];     /* .n01 and .n02 pages */
878    char    *nybasep[2];        /* all .n01 and .n02 pages */
879    char    *lybasep[2];        /* all .l01 and .l02 pages */
880    char    *iybasep;           /* all .ifp blocks */
881    off_t    cc_offset;         /* .cnt SEEK_SET offset */
882#if CNLI
883    off_t    cn_offset[2];      /* .n0x SEEK_SET offset */
884    off_t    cl_offset[2];      /* .l0x SEEK_SET offset */
885    off_t    ci_offset;         /* .ifp SEEK_SET offset */
886#endif
887} INVMAP;
888
889
890#if RECGIZM
891typedef struct gizmstru {
892    short isize;
893    short osize;
894    unsigned char *ipatt;
895    unsigned char *opatt;
896    LONGX nused;
897    struct gizmstru *nextp;
898} GIZMSTRU;
899
900#define MAXGIZR 16
901
902typedef struct vgizpstru {
903    GIZMSTRU *ghdrp[256];
904    int grngs;
905    UWORD grng1[MAXGIZR];
906    UWORD grng2[MAXGIZR];
907    unsigned char *gdbnp;
908    struct vgizpstru *nextp;
909} VGIZPSTRU;
910
911#endif
912
913
914#if RECDECO
915#define MAXDECR 16
916#define MAXDECX 16
917
918typedef struct vdecpstru {
919    unsigned char *ddbnp;
920    int drngs;
921    UWORD drng1[MAXDECR];
922    UWORD drng2[MAXDECR];
923    unsigned char drdlm;
924    int dsflds;
925    unsigned char dsfld[MAXDECX];
926    unsigned char dsfldx[MAXDECX];
927    LONGX dsfldv[MAXDECX];
928    struct vdecpstru *nextp;
929} VDECPSTRU;
930#endif
931
932#if CIAPI
933typedef void DBXSTRU;
934#else /* CIAPI */
935#if CICPP
936class _YOURCLASS DBXSTRU;       /* Para substituir def da struct */
937#else
938typedef struct dbxstru {
939    char       dbxname[CIMPL+1];  /* dbname + .ext + NULL */
940    int        dbxxropn;          /* =dbxopen(.xrf) */
941    int        dbxmsopn;          /* =dbxopen(.mst) */
942    int        dbxxropw;          /* dbxopenw/w(.xrf) */
943    int        dbxmsopw;          /* dbxopenw/w(.mst) */
944    int        dbxmsopv;          /* dbxflock/dbxulock(.mst) */
945    XRSTRU    *dbxxribp;          /* ptr .xrf ibuf */
946    MSSTRU    *dbxmsibp;          /* ptr .mst ibuf */
947#if GIPAR
948    char      *dbxgicip;          /* extended .mst capacity */
949#endif
950#if DBXMSTXL
951    int        dbxmstxl;          /* extended .mst capacity */
952#endif
953    int        dbxmflush;         /* mstflush() flag */
954    int        dbxmclose;         /* mstclose() flag */
955    int        dbxiflush;         /* invflush() flag */
956#if MULTI
957    int        dbxnetws;          /* type of network support */
958    int        dbxdelxx;          /* flag data entry lock */
959    int        dbxewlxx;          /* flag exclusive write lock */
960    int        dbxmxtmp;          /* mx() tmpseq master file */
961#endif
962    LONGX       dbxmsmfn;          /* mstsetup() .mst nxtmfn */
963    INVMAP    *dbxifmap;          /* .cnt, .n0x, .l0x, .ifp */
964#if 1 /* SAMEL */
965    int        dbxiflxx;          /* dbx samel */
966#endif
967    char      *dbxxryyp;          /* all .xrf blocks */
968    char      *dbxmsyyp;          /* all .mst blocks */
969#if RECGIZM
970    VGIZPSTRU *dbxvgzrp;          /* gizmo processing */
971#endif
972#if RECXPND
973    int        dbxxpn01;          /* expand processing */
974    int        dbxxpn02;          /* expand processing */
975#endif
976#if RECDECO
977    VDECPSTRU *dbxvderp;          /* decod processing */
978#endif
979#if IFUPDATE
980    int        dbxiinit;          /* ifupdat() init */
981    int        dbxitrac;          /* ifupdat() trace parameter */
982    LONGX       dbxitell;          /* ifupdat() tell parameter */
983    LONGX       dbxirang;          /* ifupdat() tell parameter */
984    LONGX       dbxirecs;          /* ifupdat() records updated */
985    LONGX       dbxipadd[2];       /* ifupdat() added lk1/lk2 posts */
986    LONGX       dbxipdel[2];       /* ifupdat() deleted lk1/lk2 posts */
987#endif
988} DBXSTRU;
989#endif /* CICPP */
990
991#define DBXname         dbxp->dbxname
992#define DBXxropn        dbxp->dbxxropn
993#define DBXmsopn        dbxp->dbxmsopn
994#define DBXxropw        dbxp->dbxxropw
995#define DBXmsopw        dbxp->dbxmsopw
996#define DBXmsopv        dbxp->dbxmsopv
997#define DBXxribp        dbxp->dbxxribp
998#define DBXmsibp        dbxp->dbxmsibp
999#if GIPAR
1000#define DBXgicip        dbxp->dbxgicip
1001#endif
1002#if DBXMSTXL
1003#define DBXmstxl        dbxp->dbxmstxl
1004#endif
1005#define DBXmflush       dbxp->dbxmflush
1006#define DBXmclose       dbxp->dbxmclose
1007#define DBXiflush       dbxp->dbxiflush
1008#if MULTI
1009#define DBXnetws        dbxp->dbxnetws
1010#define DBXdelxx        dbxp->dbxdelxx
1011#define DBXewlxx        dbxp->dbxewlxx
1012#define DBXmxtmp        dbxp->dbxmxtmp
1013#endif
1014#define DBXmsmfn        dbxp->dbxmsmfn
1015#define DBXifmap        dbxp->dbxifmap
1016#define DBXiflxx        dbxp->dbxiflxx
1017#define DBXxryyp        dbxp->dbxxryyp
1018#define DBXmsyyp        dbxp->dbxmsyyp
1019#if RECGIZM
1020#define DBXvgzrp        dbxp->dbxvgzrp
1021#endif
1022#if RECXPND
1023#define DBXxpn01        dbxp->dbxxpn01
1024#define DBXxpn02        dbxp->dbxxpn02
1025#endif
1026#if RECDECO
1027#define DBXvderp        dbxp->dbxvderp
1028#endif
1029#if IFUPDATE
1030#define DBXiinit        dbxp->dbxiinit
1031#define DBXitrac        dbxp->dbxitrac
1032#define DBXitell        dbxp->dbxitell
1033#define DBXirang        dbxp->dbxirang
1034#define DBXirecs        dbxp->dbxirecs
1035#define DBXipadd        dbxp->dbxipadd
1036#define DBXipdel        dbxp->dbxipdel
1037#endif
1038
1039#define VDBXname(i)     vdbxp[i]->dbxname
1040#define VDBXxropn(i)    vdbxp[i]->dbxxropn
1041#define VDBXmsopn(i)    vdbxp[i]->dbxmsopn
1042#define VDBXxropw(i)    vdbxp[i]->dbxxropw
1043#define VDBXmsopw(i)    vdbxp[i]->dbxmsopw
1044#define VDBXmsopv(i)    vdbxp[i]->dbxmsopv
1045#define VDBXxribp(i)    vdbxp[i]->dbxxribp
1046#define VDBXmsibp(i)    vdbxp[i]->dbxmsibp
1047#if GIPAR
1048#define VDBXgicip(i)    vdbxp[i]->dbxgicip
1049#endif
1050#if DBXMSTXL
1051#define VDBXmstxl(i)    vdbxp[i]->dbxmstxl
1052#endif
1053#define VDBXmflush(i)   vdbxp[i]->dbxmflush
1054#define VDBXmclose(i)   vdbxp[i]->dbxmclose
1055#define VDBXiflush(i)   vdbxp[i]->dbxiflush
1056#if MULTI
1057#define VDBXnetws(i)    vdbxp[i]->dbxnetws
1058#define VDBXdelxx(i)    vdbxp[i]->dbxdelxx
1059#define VDBXewlxx(i)    vdbxp[i]->dbxewlxx
1060#define VDBXmxtmp(i)    vdbxp[i]->dbxmxtmp
1061#endif
1062#define VDBXmsmfn(i)    vdbxp[i]->dbxmsmfn
1063#define VDBXifmap(i)    vdbxp[i]->dbxifmap
1064#define VDBXiflxx(i)    vdbxp[i]->dbxiflxx
1065#define VDBXxryyp(i)    vdbxp[i]->dbxxryyp
1066#define VDBXmsyyp(i)    vdbxp[i]->dbxmsyyp
1067#if RECGIZM
1068#define VDBXvgzrp(i)    vdbxp[i]->dbxvgzrp
1069#endif
1070#if RECXPND
1071#define VDBXxpn01(i)    vdbxp[i]->dbxxpn01
1072#define VDBXxpn02(i)    vdbxp[i]->dbxxpn02
1073#endif
1074#if RECDECO
1075#define VDBXvderp(i)    vdbxp[i]->dbxvderp
1076#endif
1077#if IFUPDATE
1078#define VDBXiinit(i)    vdbxp[i]->dbxiinit
1079#define VDBXitrac(i)    vdbxp[i]->dbxitrac
1080#define VDBXitell(i)    vdbxp[i]->dbxitell
1081#define VDBXirang(i)    vdbxp[i]->dbxirang
1082#define VDBXirecs(i)    vdbxp[i]->dbxirecs
1083#define VDBXipadd(i)    vdbxp[i]->dbxipadd
1084#define VDBXipdel(i)    vdbxp[i]->dbxipdel
1085#endif
1086
1087#define DBIifl1p        dbxp->dbxifmap->ifl1p
1088#define DBIifl2p        dbxp->dbxifmap->ifl2p
1089#define DBIiflxn        dbxp->dbxifmap->iflxn
1090#define DBIiflzx        dbxp->dbxifmap->iflzx
1091#define DBIcnopn        dbxp->dbxifmap->cnopn
1092#define DBIn1opn        dbxp->dbxifmap->n1opn
1093#define DBIn2opn        dbxp->dbxifmap->n2opn
1094#define DBIl1opn        dbxp->dbxifmap->l1opn
1095#define DBIl2opn        dbxp->dbxifmap->l2opn
1096#if SAMEL
1097#define DBIifopn(lxx)   dbxp->dbxifmap->ifopn[lxx]
1098#else
1099#define DBIifopn        dbxp->dbxifmap->ifopn
1100#endif
1101#define DBIcnopw        dbxp->dbxifmap->cnopw
1102#define DBIn1opw        dbxp->dbxifmap->n1opw
1103#define DBIn2opw        dbxp->dbxifmap->n2opw
1104#define DBIl1opw        dbxp->dbxifmap->l1opw
1105#define DBIl2opw        dbxp->dbxifmap->l2opw
1106#define DBIifopw        dbxp->dbxifmap->ifopw
1107#define DBIifopv        dbxp->dbxifmap->ifopv
1108#define DBIcn(i)        dbxp->dbxifmap->cn[i]
1109#define DBInx(i,j)      dbxp->dbxifmap->nx[i][j]
1110#define DBInybasep(i)   dbxp->dbxifmap->nybasep[i]
1111#define DBIlybasep(i)   dbxp->dbxifmap->lybasep[i]
1112#define DBIiybasep      dbxp->dbxifmap->iybasep
1113#if CNLI
1114#define DBIcn_offset(i) dbxp->dbxifmap->cn_offset[i]
1115#define DBIcl_offset(i) dbxp->dbxifmap->cl_offset[i]
1116#define DBIci_offset    dbxp->dbxifmap->ci_offset
1117#endif
1118
1119#endif /* CIAPI */
1120
1121#if !CIAPI
1122#if !CICPP      /* Deslocados para classe DBXSTRU  */
1123/* CIDBX Interface */
1124#if ANSI
1125#if MULTI
1126int dbxcinet(char *dbnamp);
1127int dbxflock(DBXSTRU *dbxp, char *type);
1128int dbxulock(DBXSTRU *dbxp, char *type);
1129int dbxilock(DBXSTRU *dbxp, char *mdbnp, char *type);
1130int dbxwlock(DBXSTRU *dbxp, char *m0p, int times);
1131#endif  /* MULTI */
1132void dbxflush(char *dbnamp);
1133DBXSTRU *dbxsrchp(char *dbnamp);
1134DBXSTRU *dbxstorp(char *dbnamp);
1135int dbxopen(char *gidbnp, char *dbnamp, char *extp);
1136#if CLOSEX
1137int CLOSE(int fd);
1138#endif
1139int dbxopenw(char *gidbnp, char *dbnamp,char *extp,int *opnp,int *opwp,char *errmsgp);
1140char *dbxopenc(char *gidbnp, char *filnamp,int *opnp,int *opwp,char *errmsgp, int xcreate, int xappend);
1141void dbxinit(void);
1142void fatal(char *msg);
1143int fpccreat(char *gidbnp, char *namp,char *extp,int lrecl);
1144void fpcwrite(char *recbufp,FFI reclen);
1145void fpcclose(void);
1146char *dbxtmpnm(char *dirtmp, int strip, char *filnamp);
1147char *cicopyr(char *namep);
1148#else
1149#if MULTI
1150int dbxcinet();
1151int dbxflock();
1152int dbxulock();
1153int dbxilock();
1154int dbxwlock();
1155#endif /* MULTI */
1156void dbxflush();
1157DBXSTRU *dbxsrchp();
1158DBXSTRU *dbxstorp();
1159int dbxopen();
1160int CLOSE();
1161int dbxopenw();
1162char *dbxopenc();
1163void dbxinit();
1164void fatal();
1165int fpccreat();
1166void fpcwrite();
1167void fpcclose();
1168char *dbxtmpnm();
1169char *cicopyr();
1170#endif /* ANSI */
1171#endif /* CICPP */
1172#endif /* CIAPI */
1173/* global */
1174
1175#if !CICPP                      /* Deslocados para classe CISIS */
1176extern DBXSTRU *vdbxp[];        /* pointers to the entries      */
1177extern LONGX ndbxs;              /* actual #entries              */
1178extern LONGX maxndbx;            /* runtime value                */
1179#endif /* CICPP */
1180
1181#if !CICPP
1182extern int dbxtrace;            /* dbxopen/dbxcipar trace */
1183
1184extern int dbxopt_fatal;        /* dbxopen() - fatal when file doesn't exist */
1185extern int dbxopt_errno;        /* dbxopen() - dbname/errno msg before fatal */
1186
1187extern int dbxopt_mflush;       /* record() - flush lastrecread if != dbname */
1188extern int dbxopt_mclose;       /* record() - close lastrecread if != dbname */
1189extern int dbxopt_iflush;       /* term() - flush lasttrmread if != dbname */
1190
1191extern int dbxopt_ordwr;        /* dbxopen() - O_RDWR / O_RDONLY (LM/CD-ROM) */
1192extern int dbxordwr;            /* dbxopen() - dbxopt_ordwr & O_RDWR */
1193
1194extern off_t dbxfloff;          /* dbxflock()/dbxulock() - offset */
1195extern LONGX dbxflsiz;          /* dbxflock()/dbxulock() - length */
1196extern int dbxfloop;            /* dbxflock() - #retries */
1197extern int dbxwloop;            /* dbxwlock() - #retries */
1198extern int dbxiloop;            /* dbxilock() - #retries */
1199extern int dbxuclos;            /* dbxulock() - close/reopen */
1200extern int dbxewlrc;            /* dbxflock()/dbxwlock() error action */
1201
1202extern LONGX rec_maxmfrl;   /* MAXMFRL/cipar maxmfrl entry */
1203extern LONGX rec_mstload;      /* 28/03/97 */
1204extern LONGX trm_invload;      /* 28/03/97 */
1205
1206#if CNV_PCBINUM
1207extern char cnv_pcbuff[];  /* PC data representation (swapped) */
1208#endif
1209
1210#if CNV_PCFILES
1211extern UCHR nodeunibuff[];      /* area para ler pagina de .n01/.n02 */
1212#if ISISUNISYS
1213#define LEAFCNV_PCFILES 0
1214#else
1215#define LEAFCNV_PCFILES 1
1216#endif
1217#if LEAFCNV_PCFILES
1218extern UCHR leafunibuff[];      /* area para ler pagina de .l01/.l02 */
1219#endif
1220#endif
1221#endif /* CICPP */
1222
1223#ifndef ON
1224#define ON       1
1225#endif
1226#ifndef OFF
1227#define OFF      0
1228#endif
1229#define BY8SHIFT 3
1230#define BY8RMASK 0x07
1231#if !CICPP
1232extern unsigned char bitmask[]; /* 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01 */
1233#endif /* CICPP */
1234
1235#define FPCBSIZ 0x4000  /*16K*/ /* fpccreat()/fpcwrite()/fpcclose() */
1236#if !CICPP
1237extern int fpc_fd;              /* fpccreat()/fpcwrite()/fpcclose() */
1238extern FFI fpc_left;            /* fpccreat()/fpcwrite()/fpcclose() */
1239extern char *fpc_buffer;        /* fpccreat()/fpcwrite()/fpcclose() */
1240
1241extern int vlex[];              /* use it */
1242extern int nxbsiz[];            /* use it */
1243extern int lxbsiz[];            /* use it */
1244
1245extern char *mx1extp;           /* mstsetup/recisis0 */
1246extern char *xx1extp;           /* mstsetup/recisis0 */
1247
1248extern char *cx1extp;           /* invsetup/trmisis0 */
1249extern char *nx12extp[];        /* invsetup/trmisis0 */
1250extern char *lx12extp[];        /* invsetup/trmisis0 */
1251extern char *ix1extp;           /* invsetup/trmisis0 */
1252#if CNLI
1253extern char *iy0extp;           /* All IF into one. To ALP, WL */
1254#endif
1255
1256#if MULTI
1257extern int cipnetws;            /* MULTI default operation */
1258#endif
1259
1260#if DBXMSTXL
1261extern int cipmstxl;            /* extended .mst capacity */
1262#endif
1263#endif /* CICPP */
1264
1265/* FATRAP Interface */
1266#define MAXFATML        80 /* for fatal_iomsg or equivalent */
1267#if FATRAP
1268#if !CICPP      /* Deslocados para a classe CISIS em cisis.hpp */
1269/* global */
1270extern int     fatal_errcod;    /* cisis fatal() error code */
1271extern char    fatal_iomsg[];   /* cisis fatal() flag/msg */
1272extern jmp_buf fatal_jumper;    /* cisis fatal() longjmp() */
1273#endif /* CICPP */
1274#endif
1275
1276#if !CICPP      /* Deslocados para a classe DBXSTRU em cidbx.cpp */
1277/* CIPAR Interface */
1278#if ANSI
1279int dbxciset(char *cipfile);
1280char *dbxcipar(char *gidbnp, char argkey[], char argchar);
1281#if GIPAR
1282char *dbxgipar(char *gidbnp, char *gikeyp, int *namlenp, int *extlenp);
1283#endif
1284#else
1285int dbxciset();
1286char *dbxcipar();
1287#if GIPAR
1288int dbxgipar();
1289#endif
1290#endif
1291#endif /* CICPP */
1292
1293/* global */
1294#if !CICPP
1295extern FILE *dbxcipfp;          /* dbxcipar() input parameter file pointer */
1296extern char *dbxcdcip;          /* dbxcipar() input data */
1297extern char dbxcikey[];         /* dbxcipar() actual file name */
1298extern int dbxcipok;            /* dbxcipar() found */
1299
1300#if GIPAR
1301extern char dbxgikey[];         /* dbxgipar() actual file name */
1302extern char *dbxgiext[];        /* dbxgipar() dbn.par .extensions */
1303extern int dbxgiexn[];          /* dbxgipar() dbn.par numbers */
1304#endif
1305#endif /* CICPP */
1306
1307
1308/* *****************************************************
1309CIREC.H
1310***************************************************** */
1311
1312typedef struct m0stru {
1313    LONGX     m0ctlmfn    PACKED;/* gdb ctlmfn */
1314    LONGX     m0nxtmfn    PACKED;/* gdb nxtmfn */
1315    LONGX     m0nxtmfb    PACKED;/* gdb nxtmfb */
1316    UWORD      m0nxtmfp    PACKED;/* gdb nxtmfp - offset */
1317    UWORD      m0mftype    PACKED;/* gdb mftype */
1318#if PCREADLINUX
1319    UWORD      fillerXm0mftype;
1320#endif /* PCREADLINUX */
1321    LONGX     m0reccnt    PACKED;/* gdb reccnt */
1322    LONGX     m0mfcxx1    PACKED;/* gdb mfcxx1 */
1323    LONGX     m0mfcxx2    PACKED;/* gdb mfcxx2 - MULTI: Data entry lock */
1324    LONGX     m0mfcxx3    PACKED;/* gdb mfcxx3 - MULTI: Exclusive write lock */
1325} M0STRU;
1326
1327typedef struct dir_entry {
1328    UWORD    tag         PACKED;/* gdb dir.tag */
1329    FFI      pos         PACKED;/* gdb dir.pos */
1330    FFI      len         PACKED;/* gdb dir.len */
1331} DIRSTRU;
1332
1333#if CNV_PCFILES
1334typedef struct m1stru {    /* Conversion is done during I/O */
1335    LONGX     m1mfn;             /* gdb mfn */
1336    LONGX     m1mfbwb;           /* gdb mfbwb */
1337    FFI      m1mfrl;            /* gdb mfrl - MULTI: record being updated */
1338    UWORD      m1mfbwp;           /* gdb mfbwp - offset */
1339    FFI      m1base;            /* gdb base */
1340    UWORD      m1nvf;             /* gdb nvf */
1341    UWORD      m1status;          /* gdb status */
1342    DIRSTRU  m1dir[1];          /* gdb dir_entries */
1343} M1STRU;
1344#else
1345typedef struct m1stru {
1346/* PACKED CIFFI */
1347/* 4 */      LONGX     m1mfn       PACKED;/* gdb mfn */
1348/* 2 4 */    FFI      m1mfrl      PACKED;/* gdb mfrl - MULTI: record being updated */
1349#if PCREADLINUX
1350             UWORD      fillerXm1mfrl;
1351#endif /* PCREADLINUX */
1352/* 4 */      LONGX     m1mfbwb     PACKED;/* gdb mfbwb */
1353/* 2 */      UWORD      m1mfbwp     PACKED;/* gdb mfbwp - offset */
1354/* 2 4 */    FFI      m1base      PACKED;/* gdb base (MSNVSPLT) */
1355/* 14 18 */
1356/*  ? 20 */
1357/* 2 */      UWORD      m1nvf       PACKED;/* gdb nvf */
1358/* 2    */   UWORD      m1status    PACKED;/* gdb status */
1359/* 18 22 */
1360/* 20 24 align4 */
1361/* 6 10 */   DIRSTRU  m1dir[1]    PACKED;/* gdb dir_entries */
1362/* ?  ?  align4 */
1363} M1STRU;
1364#endif
1365
1366#if CIFFI || PCREADLINUX
1367#if 0
1368#define LEADER      22          /* gdb */
1369#define MSNVSPLT    18          /* gdb .mst never split - 'til base */
1370#endif /* 0 */
1371#define LEADER      (sizeof(M1STRU)-sizeof(DIRSTRU))       /* pc=18,hp=20;ff=22/24 */
1372#define MSNVSPLT    (LEADER-sizeof(UWORD)-sizeof(UWORD))   /* pc=14,hp=16;ff=18/20  */
1373#else /* CIFFI */
1374#if (ISPACKED && !UNIX) || CNV_PCFILES     /* PC || VAX || CNV_PCFILES */
1375#define LEADER      18          /* gdb */
1376#define MSNVSPLT    14          /* gdb .mst never split - 'til base */
1377#else /* ISPACKED || CNV_PCFILES */
1378#define LEADER      20          /* gdb */
1379#define MSNVSPLT    16          /* gdb .mst never split - 'til base */
1380#endif /* ISPACKED || CNV_PCFILES */
1381#endif /* CIFFI */
1382
1383
1384typedef union mfunion {
1385    M0STRU   m0;
1386    M1STRU   m1;
1387    char     mx[1];             /* gdb flds */
1388} MFUNION;
1389
1390#if CIAPI
1391typedef void RECSTRU;
1392#else /* CIAPI */
1393#if CICPP
1394class _YOURCLASS RECSTRU;       /* Para substituir def da struct */
1395#endif /* CICPP */
1396
1397#if !CICPP                      /* Declarada como classe em cirec.hpp */
1398typedef struct recstru {
1399    LONGX     recnbytes;         /* nbytes allocated (RECHSIZE not included) */
1400    int      rectype;           /* layout indicator */
1401    DBXSTRU *recdbxp;           /* ptr dbx */
1402    int      recrc;             /* record rc */
1403#if MULTI
1404    int      reclock;           /* mfr read/lock option */
1405    int      recwlock;          /* mfr write/lock option */
1406#endif
1407    int      recgdbl;           /* mfr read/mfrl lock granted */
1408    int      recgdbw;           /* mfr read/mfrl flag */
1409    MFUNION  recmf;             /* master_recs and .mx unions */
1410} RECSTRU;
1411
1412#define RECHSIZE        sizeof(RECSTRU)-sizeof(MFUNION)
1413#endif /* CICPP */
1414
1415#define RECnbytes       recp->recnbytes
1416#define RECtype         recp->rectype
1417
1418#define RECdbxp         recp->recdbxp
1419
1420#define RDBname         recp->recdbxp->dbxname
1421#define RDBxropn        recp->recdbxp->dbxxropn
1422#define RDBmsopn        recp->recdbxp->dbxmsopn
1423#define RDBxropw        recp->recdbxp->dbxxropw
1424#define RDBmsopw        recp->recdbxp->dbxmsopw
1425#define RDBmsopv        recp->recdbxp->dbxmsopv
1426#define RDBxribp        recp->recdbxp->dbxxribp
1427#define RDBmsibp        recp->recdbxp->dbxmsibp
1428#if GIPAR
1429#define RDBgicip        recp->recdbxp->dbxgicip
1430#endif
1431#if DBXMSTXL
1432#define RDBmstxl        recp->recdbxp->dbxmstxl
1433#endif
1434#define RDBmflush       recp->recdbxp->dbxmflush
1435#define RDBmclose       recp->recdbxp->dbxmclose
1436#if MULTI
1437#define RDBnetws        recp->recdbxp->dbxnetws
1438#define RDBdelxx        recp->recdbxp->dbxdelxx
1439#define RDBewlxx        recp->recdbxp->dbxewlxx
1440#define RDBmxtmp        recp->recdbxp->dbxmxtmp
1441#endif
1442#define RDBmsmfn        recp->recdbxp->dbxmsmfn
1443#define RDBifmap        recp->recdbxp->dbxifmap
1444#define RDBiflxx        recp->recdbxp->dbxiflxx
1445#define RDBxryyp        recp->recdbxp->dbxxryyp
1446#define RDBmsyyp        recp->recdbxp->dbxmsyyp
1447#if RECGIZM
1448#define RDBvgzrp        recp->recdbxp->dbxvgzrp
1449#endif
1450#if RECXPND
1451#define RDBxpn01        recp->recdbxp->dbxxpn01
1452#define RDBxpn02        recp->recdbxp->dbxxpn02
1453#endif
1454#if RECDECO
1455#define RDBvderp        recp->recdbxp->dbxvderp
1456#endif
1457
1458#define RECrc           recp->recrc
1459#if MULTI
1460#define REClock         recp->reclock
1461#define RECwlock        recp->recwlock
1462#endif
1463#define RECgdbl         recp->recgdbl
1464#define RECgdbw         recp->recgdbw
1465
1466#if CICPP
1467#define MF0ctlmfn       recp->recmfp->m0.m0ctlmfn
1468#define MF0nxtmfn       recp->recmfp->m0.m0nxtmfn
1469#define MF0nxtmfb       recp->recmfp->m0.m0nxtmfb
1470#define MF0nxtmfp       recp->recmfp->m0.m0nxtmfp
1471#define MF0mftype       recp->recmfp->m0.m0mftype
1472#define MF0reccnt       recp->recmfp->m0.m0reccnt
1473#define MF0mfcxx1       recp->recmfp->m0.m0mfcxx1
1474#define MF0mfcxx2       recp->recmfp->m0.m0mfcxx2
1475#define MF0mfcxx3       recp->recmfp->m0.m0mfcxx3
1476
1477#define MFRmfn          recp->recmfp->m1.m1mfn
1478#define MFRmfrl         recp->recmfp->m1.m1mfrl
1479#define MFRmfbwb        recp->recmfp->m1.m1mfbwb
1480#define MFRmfbwp        recp->recmfp->m1.m1mfbwp
1481#define MFRbase         recp->recmfp->m1.m1base
1482#define MFRnvf          recp->recmfp->m1.m1nvf
1483#define MFRstatus       recp->recmfp->m1.m1status
1484#define MFRdir          recp->recmfp->m1.m1dir
1485
1486#define DIRtag(x)       recp->recmfp->m1.m1dir[x].tag
1487#define DIRpos(x)       recp->recmfp->m1.m1dir[x].pos
1488#define DIRlen(x)       recp->recmfp->m1.m1dir[x].len
1489
1490#define MFX             recp->recmfp->mx
1491#else /* CICPP */
1492#define MF0ctlmfn       recp->recmf.m0.m0ctlmfn
1493#define MF0nxtmfn       recp->recmf.m0.m0nxtmfn
1494#define MF0nxtmfb       recp->recmf.m0.m0nxtmfb
1495#define MF0nxtmfp       recp->recmf.m0.m0nxtmfp
1496#define MF0mftype       recp->recmf.m0.m0mftype
1497#define MF0reccnt       recp->recmf.m0.m0reccnt
1498#define MF0mfcxx1       recp->recmf.m0.m0mfcxx1
1499#define MF0mfcxx2       recp->recmf.m0.m0mfcxx2
1500#define MF0mfcxx3       recp->recmf.m0.m0mfcxx3
1501
1502#define MFRmfn          recp->recmf.m1.m1mfn
1503#define MFRmfrl         recp->recmf.m1.m1mfrl
1504#define MFRmfbwb        recp->recmf.m1.m1mfbwb
1505#define MFRmfbwp        recp->recmf.m1.m1mfbwp
1506#define MFRbase         recp->recmf.m1.m1base
1507#define MFRnvf          recp->recmf.m1.m1nvf
1508#define MFRstatus       recp->recmf.m1.m1status
1509#define MFRdir          recp->recmf.m1.m1dir
1510
1511#define DIRtag(x)       recp->recmf.m1.m1dir[x].tag
1512#define DIRpos(x)       recp->recmf.m1.m1dir[x].pos
1513#define DIRlen(x)       recp->recmf.m1.m1dir[x].len
1514
1515#define MFX             recp->recmf.mx
1516#endif /* CICPP */
1517
1518#define VRECnbytes(r)   vrecp[r]->recnbytes
1519#define VRECtype(r)     vrecp[r]->rectype
1520
1521#define VRECdbxp(r)     vrecp[r]->recdbxp
1522
1523#define VRDBname(r)     vrecp[r]->recdbxp->dbxname
1524#define VRDBxropn(r)    vrecp[r]->recdbxp->dbxxropn
1525#define VRDBmsopn(r)    vrecp[r]->recdbxp->dbxmsopn
1526#define VRDBxropw(r)    vrecp[r]->recdbxp->dbxxropw
1527#define VRDBmsopw(r)    vrecp[r]->recdbxp->dbxmsopw
1528#define VRDBmsopv(r)    vrecp[r]->recdbxp->dbxmsopv
1529#define VRDBxribp(r)    vrecp[r]->recdbxp->dbxxribp
1530#define VRDBmsibp(r)    vrecp[r]->recdbxp->dbxmsibp
1531#if GIPAR
1532#define VRDBgicip(r)    vrecp[r]->recdbxp->dbxgicip
1533#endif
1534#if DBXMSTXL
1535#define VRDBmstxl(r)    vrecp[r]->recdbxp->dbxmstxl
1536#endif
1537#define VRDBmflush(r)   vrecp[r]->recdbxp->dbxmflush
1538#define VRDBmclose(r)   vrecp[r]->recdbxp->dbxmclose
1539#if MULTI
1540#define VRDBnetws(r)    vrecp[r]->recdbxp->dbxnetws
1541#define VRDBdelxx(r)    vrecp[r]->recdbxp->dbxdelxx
1542#define VRDBewlxx(r)    vrecp[r]->recdbxp->dbxewlxx
1543#define VRDBmxtmp(r)    vrecp[r]->recdbxp->dbxmxtmp
1544#endif
1545#define VRDBmsmfn(r)    vrecp[r]->recdbxp->dbxmsmfn
1546#define VRDBifmap(r)    vrecp[r]->recdbxp->dbxifmap
1547#define VRDBiflxx(r)    vrecp[r]->recdbxp->dbxiflxx
1548#define VRDBxryyp(r)    vrecp[r]->recdbxp->dbxxryyp
1549#define VRDBmsyyp(r)    vrecp[r]->recdbxp->dbxmsyyp
1550#if RECGIZM
1551#define VRDBvgzrp(r)    vrecp[r]->recdbxp->dbxvgzrp
1552#endif
1553#if RECXPND
1554#define VRDBxpn01(r)    vrecp[r]->recdbxp->dbxxpn01
1555#define VRDBxpn02(r)    vrecp[r]->recdbxp->dbxxpn02
1556#endif
1557#if RECDECO
1558#define VRDBvderp(r)    vrecp[r]->recdbxp->dbxvderp
1559#endif
1560
1561#define VRECrc(r)       vrecp[r]->recrc
1562#if MULTI
1563#define VREClock(r)     vrecp[r]->reclock
1564#define VRECwlock(r)    vrecp[r]->recwlock
1565#endif
1566#define VRECgdbl(r)     vrecp[r]->recgdbl
1567#define VRECgdbw(r)     vrecp[r]->recgdbw
1568
1569#if CICPP
1570#define VMF0ctlmfn(r)   vrecp[r]->recmfp->m0.m0ctlmfn
1571#define VMF0nxtmfn(r)   vrecp[r]->recmfp->m0.m0nxtmfn
1572#define VMF0nxtmfb(r)   vrecp[r]->recmfp->m0.m0nxtmfb
1573#define VMF0nxtmfp(r)   vrecp[r]->recmfp->m0.m0nxtmfp
1574#define VMF0mftype(r)   vrecp[r]->recmfp->m0.m0mftype
1575#define VMF0reccnt(r)   vrecp[r]->recmfp->m0.m0reccnt
1576#define VMF0mfcxx1(r)   vrecp[r]->recmfp->m0.m0mfcxx1
1577#define VMF0mfcxx2(r)   vrecp[r]->recmfp->m0.m0mfcxx2
1578#define VMF0mfcxx3(r)   vrecp[r]->recmfp->m0.m0mfcxx3
1579
1580#define VMFRmfn(r)      vrecp[r]->recmfp->m1.m1mfn
1581#define VMFRmfrl(r)     vrecp[r]->recmfp->m1.m1mfrl
1582#define VMFRmfbwb(r)    vrecp[r]->recmfp->m1.m1mfbwb
1583#define VMFRmfbwp(r)    vrecp[r]->recmfp->m1.m1mfbwp
1584#define VMFRbase(r)     vrecp[r]->recmfp->m1.m1base
1585#define VMFRnvf(r)      vrecp[r]->recmfp->m1.m1nvf
1586#define VMFRstatus(r)   vrecp[r]->recmfp->m1.m1status
1587#define VMFRdir(r)      vrecp[r]->recmfp->m1.m1dir
1588
1589#define VDIRtag(r,x)    vrecp[r]->recmfp->m1.m1dir[x].tag
1590#define VDIRpos(r,x)    vrecp[r]->recmfp->m1.m1dir[x].pos
1591#define VDIRlen(r,x)    vrecp[r]->recmfp->m1.m1dir[x].len
1592
1593#define VMFX(r)         vrecp[r]->recmfp->mx
1594#else /* CICPP */
1595#define VMF0ctlmfn(r)   vrecp[r]->recmf.m0.m0ctlmfn
1596#define VMF0nxtmfn(r)   vrecp[r]->recmf.m0.m0nxtmfn
1597#define VMF0nxtmfb(r)   vrecp[r]->recmf.m0.m0nxtmfb
1598#define VMF0nxtmfp(r)   vrecp[r]->recmf.m0.m0nxtmfp
1599#define VMF0mftype(r)   vrecp[r]->recmf.m0.m0mftype
1600#define VMF0reccnt(r)   vrecp[r]->recmf.m0.m0reccnt
1601#define VMF0mfcxx1(r)   vrecp[r]->recmf.m0.m0mfcxx1
1602#define VMF0mfcxx2(r)   vrecp[r]->recmf.m0.m0mfcxx2
1603#define VMF0mfcxx3(r)   vrecp[r]->recmf.m0.m0mfcxx3
1604
1605#define VMFRmfn(r)      vrecp[r]->recmf.m1.m1mfn
1606#define VMFRmfrl(r)     vrecp[r]->recmf.m1.m1mfrl
1607#define VMFRmfbwb(r)    vrecp[r]->recmf.m1.m1mfbwb
1608#define VMFRmfbwp(r)    vrecp[r]->recmf.m1.m1mfbwp
1609#define VMFRbase(r)     vrecp[r]->recmf.m1.m1base
1610#define VMFRnvf(r)      vrecp[r]->recmf.m1.m1nvf
1611#define VMFRstatus(r)   vrecp[r]->recmf.m1.m1status
1612#define VMFRdir(r)      vrecp[r]->recmf.m1.m1dir
1613
1614#define VDIRtag(r,x)    vrecp[r]->recmf.m1.m1dir[x].tag
1615#define VDIRpos(r,x)    vrecp[r]->recmf.m1.m1dir[x].pos
1616#define VDIRlen(r,x)    vrecp[r]->recmf.m1.m1dir[x].len
1617
1618#define VMFX(r)         vrecp[r]->recmf.mx
1619#endif /* CICPP */
1620
1621#define FIELDP(xdir)            MFX+(MFRbase+DIRpos(xdir))
1622
1623#define VFIELDP(irec,xdir)      VMFX(irec)+(VMFRbase(irec)+VDIRpos(irec,xdir))
1624
1625#endif /* CIAPI */
1626
1627#define TYPEMF0     11
1628#define TYPEMFR     12
1629#define TYPEX       13
1630#define TYPEMFQ     TYPEMFR             /* 31 */
1631
1632#if MULTI
1633#define NOLOCK      0           /* recread() unlocked option */
1634#define RLOCK       1           /* recread() record lock */
1635#define DELOCK      2           /* recread() data entry lock */
1636#define RDELOCK     3           /* recread() record or data entry lock */
1637#define EWLOCK      4           /* recread() exclusive write lock */
1638#define FORCE       8           /* recunlck() force unlock */
1639#define WUNLOCK     1           /* recwrite() unlock */
1640#define WLOCK       2           /* recwrite() keep lock */
1641#define NEWREC      4           /* recwrite() new record mask */
1642#endif
1643
1644#define RCLOCK      (-2)        /* gdb - Lock refused */
1645#define RCEOF       (-1)        /* gdb */
1646#define RCNORMAL    0           /* gdb */
1647#define RCLDEL      1           /* gdb */
1648#define RCPDEL      2           /* gdb */
1649
1650#define ACTIVE      0           /* gdb - mfr.leader.status */
1651#define DELETED     1           /* gdb - mfr.leader.status */
1652
1653/* CIREC Interface */
1654#if !CICPP                      /* transferidas para a classe RECSTRU */
1655#if ANSI
1656LONGX recallok(LONGX irec, LONGX nbytes);
1657LONGX record(LONGX irec, char *dbnamp, LONGX mfn);
1658int nocc(LONGX irec, int tag);
1659int fieldx(LONGX irec, int tag, int occ);
1660int fieldn(LONGX irec, int tag, int occ);
1661int recread(RECSTRU *recp, LONGX mfn);
1662int recxref(RECSTRU *recp, LONGX mfn, LONGX *comb, int *comp);
1663void recinit(void);
1664void mstsetup(char *dbnamp, LONGX loadxrf, LONGX loadmst);
1665void mstflush(char *dbnamp);
1666void mstclose(DBXSTRU *dbxp);
1667#else
1668LONGX recallok();
1669LONGX record();
1670int nocc();
1671int fieldx();
1672int fieldn();
1673int recread();
1674int recxref();
1675void recinit();
1676void mstsetup();
1677void mstflush();
1678void mstclose();
1679#endif
1680#endif /* CICPP */
1681
1682/* global */
1683#if !CICPP
1684extern RECSTRU *vrecp[];        /* pointers to the entries      */
1685extern LONGX nrecs;              /* actual #entries              */
1686extern LONGX maxnrec;            /* runtime value                */
1687#endif /* CICPP */
1688
1689#if !CICPP
1690extern int rectrace;            /* rec RESTRACE runtime switch  */
1691
1692extern LONGX recxrefb;           /* recxref() comb */
1693extern int  recxrefp;           /* recxref() comp */
1694extern int  recxrefn;           /* recxref() flagnew */
1695extern int  recxrefm;           /* recxref() flagmod */
1696extern FFI  recreadl;           /* force recread() mfrl */
1697#if IFUPDATE
1698extern LONGX recreadb;           /* force recread() comb = mfbwb */
1699extern int  recreadp;           /* force recread() comp = mfbwp */
1700#endif
1701#endif /* CICPP */
1702
1703
1704
1705/* *****************************************************
1706CIGIZ.H
1707***************************************************** */
1708
1709#if RECGIZM
1710#define GIZMTAG1        1
1711#define GIZMTAG2        2
1712#define GIZMTAG11       11
1713#define GIZMTAG21       21
1714
1715#if !CIAPI
1716
1717/* CIGIZ Interface */
1718#if ANSI
1719unsigned char *pattalloc(int n);
1720GIZMSTRU *gizmalloc(int n);
1721#if CICPP
1722int gizmread(CISISX *cisisxp, char *gizdbnp, VGIZPSTRU **vgizmpp);
1723LONGX recgizmo(CISISX *cisisxp, RECSTRU *recp, VGIZPSTRU *vgizmap);
1724#else /* CICPP */
1725int gizmread(char *gizdbnp, VGIZPSTRU **vgizpp, LONGX irec);
1726LONGX recgizmo(LONGX irec, VGIZPSTRU *vgizmap);
1727#endif /* CICPP */
1728void gizflush(VGIZPSTRU *vgizmap);
1729#else
1730unsigned char *pattalloc();
1731GIZMSTRU *gizmalloc();
1732int gizmread();
1733LONGX recgizmo();
1734void gizflush();
1735#endif /* ANSI */
1736
1737#endif /* !CIAPI */
1738
1739
1740#endif /* RECGIZM */
1741
1742#if RECXPND
1743#if ANSI
1744#if CICPP
1745LONGX recxpnmo(RECSTRU *recp);
1746LONGX recxpn00 (RECSTRU *recp, int xpn01, int xpn02);
1747#else /* CICPP */
1748LONGX recxpnmo(LONGX irec);
1749LONGX recxpn00(LONGX irec, int xpn01, int xpn02);
1750#endif /* CICPP */
1751#else
1752LONGX recxpnmo();
1753LONGX recxpn00();
1754#endif /* ANSI */
1755#endif /* RECXPND */
1756
1757
1758#if RECDECO
1759#define DECOTAG1        1
1760#define DECOTAG2        2
1761#define DECOTAG3        3
1762#define DECOTAG4        4
1763
1764/* CIDEC Interface */
1765#if ANSI
1766#if CICPP
1767int recdecod(CISISX * cisisxp, RECSTRU *recp, char *decdbnp);
1768LONGX recdecex (CISISX * cisisxp, RECSTRU *recp);
1769#else /* CICPP */
1770int recdecod(LONGX irec, char *decdbnp, LONGX wrec);
1771LONGX recdecex(LONGX irec);
1772#endif /* CICPP */
1773void decflush(VDECPSTRU *vdecmap);
1774#else
1775int recdecod();
1776LONGX recdecex();
1777void decflush();
1778#endif /* ANSI */
1779#endif /* RECDECO */
1780
1781/* global */
1782#if !CICPP
1783extern int dectrace;            /* decoread()/recdeco() runtime switch  */
1784#endif /* CICPP */
1785
1786
1787
1788/* *****************************************************
1789CITRM.H
1790***************************************************** */
1791
1792#ifndef PACKED2
1793#if GCC
1794#if SIXTY_FOUR && _LARGEFILE64_SOURCE
1795#define PACKED2 __attribute__ ((aligned(2),packed))
1796#else
1797#define PACKED2 __attribute__ ((aligned(2)))
1798#endif
1799#else /* GCC */
1800#define PACKED2
1801#endif /* GCC */
1802#endif
1803
1804typedef struct n1idxe {
1805    UCHR     key[LE1] PACKED2;          /* gdb .n01 idx key */
1806    PUNT     punt PACKED2;              /* gdb .n01 idx punt */
1807} N1IDXE;
1808
1809typedef struct n2idxe {
1810    UCHR     key[LE2] PACKED2;          /* gdb .n02 idx key */
1811    PUNT     punt PACKED2;              /* gdb .n02 idx punt */
1812} N2IDXE;
1813
1814typedef struct n1stru {
1815    PUNT     pos PACKED2;               /* gdb .n01 pos */
1816    UWORD    ock PACKED2;               /* gdb .n01 ock */
1817    UWORD    it PACKED2;                /* gdb .n01 it */
1818    N1IDXE   idx[TWORDN] PACKED2;       /* gdb .n01 idx */
1819} N1STRU;
1820
1821typedef struct n2stru {
1822    PUNT     pos PACKED2;               /* gdb .n02 pos */
1823    UWORD    ock PACKED2;               /* gdb .n02 ock */
1824    UWORD    it PACKED2;                /* gdb .n02 it */
1825    N2IDXE   idx[TWORDN] PACKED2;       /* gdb .n02 idx */
1826} N2STRU;
1827
1828
1829typedef struct l1idxe {
1830    UCHR     key[LE1] PACKED2;          /* gdb .l01 idx key */
1831#if ISISUNISYS
1832    UCHR     keyalign[2] PACKED2; /* see ISIS.PAS for UNISYS */
1833#endif
1834    INFX     info1 PACKED2;             /* gdb .l01 idx info1 */
1835    INFO     info2 PACKED2;             /* gdb .l01 idx info2 */
1836#if LIND
1837    union {
1838       INFX    info3 PACKED2;          /* tlc info3 - tot no of docs */
1839       INFX    info4 PACKED2;          /* tlc info4 - posting type and etc */
1840    } info3info4;
1841#endif
1842} L1IDXE;
1843
1844typedef struct l2idxe {
1845    UCHR     key[LE2] PACKED2;          /* gdb .l02 idx key */
1846#if ISISUNISYS
1847    UCHR     keyalign[2] PACKED2; /* see ISIS.PAS for UNISYS */
1848#endif
1849    INFX     info1 PACKED2;             /* gdb .l02 idx info1 */
1850    INFO     info2 PACKED2;             /* gdb .l02 idx info2 */
1851#if LIND
1852    union {
1853        INFX info3 PACKED2;             /* tlc info3 - tot no of docs */
1854        INFX info4 PACKED2;             /* tlc info4 - posting type and etc */
1855    } info3info4;
1856#endif
1857} L2IDXE;
1858
1859typedef struct l1stru {
1860    PUNT     pos PACKED2;               /* gdb .l01 pos */
1861    UWORD    ock PACKED2;               /* gdb .l01 ock */
1862    UWORD    it PACKED2;                /* gdb .l01 it */
1863    PUNT     ps PACKED2;                /* gdb .l01 ps */
1864#if LIND
1865    PUNT     psb PACKED2;               /* tlc gdb .l0x ps backward */
1866#endif
1867    L1IDXE   idx[TWORDF] PACKED2;       /* gdb .l01 idx */
1868} L1STRU;
1869
1870typedef struct l2stru {
1871    PUNT     pos PACKED2;               /* gdb .l02 pos */
1872    UWORD    ock PACKED2;               /* gdb .l02 ock */
1873    UWORD    it PACKED2;                /* gdb .l02 it */
1874    PUNT     ps PACKED2;                /* gdb .l02 ps */
1875#if LIND
1876    PUNT     psb PACKED2;                       /* tlc gdb .l0x ps backward */
1877#endif
1878    L2IDXE   idx[TWORDF] PACKED2;       /* gdb .l02 idx */
1879} L2STRU;
1880
1881
1882#if SAMEL
1883                                /* *** SAMEL *** */
1884typedef struct lxidxe {
1885    INFX     info1;             /* gdb .l0x idx info1 */
1886    INFO     info2;             /* gdb .l0x idx info2 */
1887#if LIND
1888    union {
1889        INFX info3;             /* tlc info3 - tot no of docs */
1890        INFX info4;             /* tlc info4 - posting type and etc */
1891    } info3info4;
1892#endif
1893} LXIDXE;
1894
1895typedef struct lxl1stru {
1896    PUNT     pos;               /* gdb .l01 pos */
1897    UWORD    ock;               /* gdb .l01 ock */
1898    UWORD    it;                /* gdb .l01 it */
1899    PUNT     ps;                /* gdb .l01 ps */
1900#if LIND
1901    PUNT     psb;               /* tlc gdb .l0x ps backward */
1902#endif
1903    UCHR     key[TWORDF][LE1];  /* gdb .l01 idx key */
1904    LXIDXE   idx[1][TWORDF];    /* gdb .l01 idx - samel */
1905} LXL1STRU;
1906
1907typedef struct lxl2stru {
1908    PUNT     pos;               /* gdb .l02 pos */
1909    UWORD    ock;               /* gdb .l02 ock */
1910    UWORD    it;                /* gdb .l02 it */
1911    PUNT     ps;                /* gdb .l02 ps */
1912#if LIND
1913    PUNT     psb;                       /* tlc gdb .l0x ps backward */
1914#endif
1915    UCHR     key[TWORDF][LE2];  /* gdb .l02 idx key */
1916    LXIDXE   idx[1][TWORDF];    /* gdb .l02 idx - samel */
1917} LXL2STRU;
1918
1919#endif /* SAMEL */
1920
1921
1922#if ZTREE
1923
1924#define LZKASZ1 (TWORDF*(2+LE1))
1925#define LZKASZ2 (TWORDF*(2+LE2))
1926
1927typedef struct lzstru {
1928    PUNT     pos PACKED2;               /* gdb .l0x pos */
1929    UWORD    ock PACKED2;               /* gdb .l0x ock */
1930    UWORD    it PACKED2;                /* gdb .l0x it */
1931    PUNT     ps PACKED2;                /* gdb .l0x ps */
1932#if LIND
1933    PUNT     psb PACKED2;               /* tlc gdb .l0x ps backward */
1934#endif
1935    INFX     info1[TWORDF] PACKED2;     /* tlc gdb .l0x idx info1 */
1936    INFO     info2[TWORDF] PACKED2;     /* tlc gdb .l0x idx info2 */
1937#if LIND
1938    INFX     info3[TWORDF] PACKED2;     /* tlc gdb .l0x idx info3 */
1939#endif
1940    char     keys[LZKASZ2] PACKED2;     /* compressed keys */
1941} LZSTRU;
1942
1943#define LZHSIZE (sizeof(LZSTRU)-LZKASZ2)
1944
1945#endif /* ZTREE */
1946
1947#define MINLCHR     ' '
1948
1949#if LIND4
1950#define PMFNSIZ     4           /* gdb */
1951#else /* LIND4 */
1952#define PMFNSIZ     3           /* gdb */
1953#endif /* LIND4 */
1954
1955#define PTAGSIZ     2           /* gdb */
1956#define POCCSIZ     1           /* gdb */
1957#define PCNTSIZ     2           /* gdb */
1958
1959#if SWAPPED
1960#if LIND4
1961#define M1      3
1962#define M2      2
1963#define M3      1
1964#define M4      0
1965#else /* LIND4 */
1966#define M1      2
1967#define M2      1
1968#define M3      0
1969#define M4      3
1970#endif /* LIND4 */
1971#define T1      1
1972#define T2      0
1973#define O1      0
1974#define O2      1
1975#define C1      1
1976#define C2      0
1977#else /* SWAPPED */
1978#if LIND4
1979#define M1      0
1980#define M2      1
1981#define M3      2
1982#define M4      3
1983#else /* LIND4 */
1984#define M1      1
1985#define M2      2
1986#define M3      3
1987#define M4      0
1988#endif /* LIND4 */
1989#define T1      0
1990#define T2      1
1991#define O1      1
1992#define O2      0
1993#define C1      0
1994#define C2      1
1995#endif /* SWAPPED */
1996
1997#define BITSTRING   (-1)        /* xxxSTRING also used for CIB7HITLIST */
1998#define MFNSTRING   0
1999#define CNTSTRING   1
2000
2001#if LIND
2002typedef struct ifpstru {
2003    UCHR     ifpx[IFBSIZ];      /* tlc .ifp data */
2004} IFPSTRU;
2005#else
2006typedef struct ifpstru {
2007    INFO     ifpblk;            /* gdb .ifp blk order */
2008    INFO     ifprec[IFMAXTIV];  /* gdb .ifp data */
2009} IFPSTRU;
2010
2011typedef struct ifpctrl {
2012    INFO     ifpblk;            /* gdb .ifp blk order */
2013    INFO     ifprec1;           /* gdb .ifp ifprec(1) */
2014    INFO     ifprec2;           /* gdb .ifp ifprec(2) */
2015} IFPCTRL;
2016
2017typedef struct ifphead {
2018    INFO     ifpnxtb;           /* gdb .ifp ifpnxtb */
2019    INFO     ifpnxtp;           /* gdb .ifp ifpnxtp */
2020    INFO     ifptotp;           /* gdb .ifp ifptotp */
2021    INFO     ifpsegp;           /* gdb .ifp ifpsegp */
2022    INFO     ifpsegc;           /* gdb .ifp ifpsegc */
2023} IFPHEAD;
2024
2025#define IFHDRSIZ    sizeof(IFPHEAD)
2026#endif
2027
2028typedef struct poststru {                               /* CIFST */
2029    UCHR pmfn[PMFNSIZ];         /* gdb .ifp pmfn */
2030    UCHR ptag[PTAGSIZ];         /* gdb .ifp ptag */
2031    UCHR pocc[POCCSIZ];         /* gdb .ifp pocc */
2032    UCHR pcnt[PCNTSIZ];         /* gdb .ifp pcnt */
2033} POSTSTRU;
2034
2035#define IFPSTSIZ    sizeof(POSTSTRU)
2036
2037#define CNBSIZ      sizeof(CNSTRU)
2038#define N1BSIZ      sizeof(N1STRU)
2039#define N2BSIZ      sizeof(N2STRU)
2040#define L1BSIZ      sizeof(L1STRU)
2041#define L2BSIZ      sizeof(L2STRU)
2042
2043#if CNV_PCFILES
2044#if PC || GCC
2045#define CNBUNI      0
2046#define N1BUNI      0
2047#define N2BUNI      0
2048#define L1BUNI      0
2049#define L2BUNI      0
2050#else
2051#define CNBUNI      2
2052#define N1BUNI      2
2053#define N2BUNI      2
2054#define L1BUNI      2
2055#define L2BUNI      2
2056#endif
2057#endif
2058
2059#if CIAPI
2060typedef void TRMSTRU;
2061#else /* CIAPI */
2062#if CICPP
2063class _YOURCLASS TRMSTRU;       /* Para substituir def da struct */
2064#endif /* CICPP */
2065
2066#if !CICPP                      /* Declarada como classe em citrm.hpp */
2067typedef struct trmstru {
2068    LONGX    trmnbytes;         /* nbytes allocated */
2069    int      trmtype;           /* layout indicator */
2070    DBXSTRU *trmdbxp;
2071    int      trmrc;             /* term/nxterm rc */
2072    UCHR     trmkey[LE2+1];     /* key padded with blanks and null */
2073    LONGX    trmpost;           /* current posting order */
2074    LONGX    trmpmfn;           /* current posting pmfn */
2075    UWORD    trmptag;           /* current posting ptag */
2076    UWORD    trmpocc;           /* current posting pocc */
2077    UWORD    trmpcnt;           /* current posting pcnt */
2078    L1STRU   trml1buf;          /* .l01 input buffer */
2079    UCHR     trml1nul;          /* .l01 input buffer idx delimiter */
2080    L2STRU   trml2buf;          /* .l02 input buffer */
2081    UCHR     trml2nul;          /* .l02 input buffer idx delimiter */
2082    int      trmlcase;          /* last term/nxterm tree used */
2083    int      trmrcase;          /* trmread() treecase+1 selection  */
2084    off_t    trmrseek[2];       /* last term/nxterm leafread() lseek addr */
2085    int      trmrsize[2];       /* last term/nxterm leafread() read size */
2086    int      trmliock[2];       /* last trmread() ock */
2087    UCHR     *trmlidxp[2];      /* last term/nxterm idxchars ptr */
2088    LONGX    trmpleft;          /* postings left in segment */
2089    UCHR     *trmpcurr;         /* trmpchar not yet incremented */
2090    UCHR     *trmpchar;         /* ptr to next posting in trmifbuf */
2091#if LIND
2092    INFX      trmyaddr;          /* byte address */
2093    INFO      trmypsts;          /* total no of psts */
2094    int       trmycase;          /* postings type */
2095    int       trmysize;          /* postings length */
2096    INFO      trmydocs;          /* total no of docs */
2097    INFX      trmydisk;          /* total no of bytes */
2098    INFX      trmyread;          /* total no of bytes already read */
2099    INFX      trmyleft;          /* total no of bytes left on ifbuf */
2100#else
2101    INFO     trmpcblk;          /* info1 for next posting() */
2102    INFO     trmpcpos;          /* info2 for next posting() */
2103    IFPHEAD  trmifseg;          /* .ifp current segm header */
2104    IFPHEAD  trmifhdr;          /* .ifp 1st segm header - total psts here */
2105#endif
2106    UCHR     trmifbuf[1];       /* .ifp input buffer */
2107} TRMSTRU;
2108#endif /* CICPP */
2109
2110#if LIND
2111#define TRMxytotp       TRMypsts
2112#else
2113#define TRMxytotp       TRMifhdr.ifptotp
2114#endif
2115
2116#if !CICPP
2117#define TRMHSIZE        sizeof(TRMSTRU)                 /* one byte more */
2118#endif /* CICPP */
2119
2120#define TRMnbytes       trmp->trmnbytes
2121#define TRMtype         trmp->trmtype
2122
2123#define TRMdbxp         trmp->trmdbxp
2124
2125#define TDBname         trmp->trmdbxp->dbxname
2126#define TDBifmap        trmp->trmdbxp->dbxifmap
2127#define TDBiflxx        trmp->trmdbxp->dbxiflxx
2128#define TDBiflush       trmp->trmdbxp->dbxiflush
2129
2130#define TRMrc           trmp->trmrc
2131#define TRMkey          trmp->trmkey
2132
2133#define TRMpost         trmp->trmpost
2134#define TRMpmfn         trmp->trmpmfn
2135#define TRMptag         trmp->trmptag
2136#define TRMpocc         trmp->trmpocc
2137#define TRMpcnt         trmp->trmpcnt
2138
2139#define TRMl1buf        trmp->trml1buf
2140#define TRMl2buf        trmp->trml2buf
2141#define TRMlcase        trmp->trmlcase
2142#define TRMrcase        trmp->trmrcase
2143#define TRMrseek(i)     trmp->trmrseek[i]
2144#define TRMrsize(i)     trmp->trmrsize[i]
2145#define TRMliock(i)     trmp->trmliock[i]
2146#define TRMlidxp(i)     trmp->trmlidxp[i]
2147
2148#define TRMpleft        trmp->trmpleft
2149#define TRMpcurr        trmp->trmpcurr
2150#define TRMpchar        trmp->trmpchar
2151
2152#if LIND
2153#define TRMyaddr        trmp->trmyaddr
2154#define TRMypsts        trmp->trmypsts
2155#define TRMycase        trmp->trmycase
2156#define TRMysize        trmp->trmysize
2157#define TRMydocs        trmp->trmydocs
2158#define TRMydisk        trmp->trmydisk
2159#define TRMyread        trmp->trmyread
2160#define TRMyleft        trmp->trmyleft
2161#else
2162#define TRMpcblk        trmp->trmpcblk
2163#define TRMpcpos        trmp->trmpcpos
2164#define TRMifseg        trmp->trmifseg
2165#define TRMifhdr        trmp->trmifhdr
2166#endif
2167
2168#define TRMifbuf        trmp->trmifbuf
2169
2170#define VTRMnbytes(r)   vtrmp[r]->trmnbytes
2171#define VTRMtype(r)     vtrmp[r]->trmtype
2172
2173#define VTRMdbxp(r)     vtrmp[r]->trmdbxp
2174
2175#define VTDBname(r)     vtrmp[r]->trmdbxp->dbxname
2176#define VTDBifmap(r)    vtrmp[r]->trmdbxp->dbxifmap
2177#define VTDBiflxx(r)    vtrmp[r]->trmdbxp->dbxiflxx
2178#define VTDBiflush(r)   vtrmp[r]->trmdbxp->dbxiflush
2179
2180#define VTRMrc(r)       vtrmp[r]->trmrc
2181#define VTRMkey(r)      vtrmp[r]->trmkey
2182
2183#define VTRMpost(r)     vtrmp[r]->trmpost
2184#define VTRMpmfn(r)     vtrmp[r]->trmpmfn
2185#define VTRMptag(r)     vtrmp[r]->trmptag
2186#define VTRMpocc(r)     vtrmp[r]->trmpocc
2187#define VTRMpcnt(r)     vtrmp[r]->trmpcnt
2188
2189#define VTRMl1buf(r)    vtrmp[r]->trml1buf
2190#define VTRMl2buf(r)    vtrmp[r]->trml2buf
2191#define VTRMlcase(r)    vtrmp[r]->trmlcase
2192#define VTRMrcase(r)    vtrmp[r]->trmrcase
2193#define VTRMrseek(r,i)  vtrmp[r]->trmrseek[i]
2194#define VTRMrsize(r,i)  vtrmp[r]->trmrsize[i]
2195#define VTRMliock(r,i)  vtrmp[r]->trmliock[i]
2196#define VTRMlidxp(r,i)  vtrmp[r]->trmlidxp[i]
2197
2198#define VTRMpleft(r)    vtrmp[r]->trmpleft
2199#define VTRMpcurr(r)    vtrmp[r]->trmpcurr
2200#define VTRMpchar(r)    vtrmp[r]->trmpchar
2201
2202#if LIND
2203#define VTRMyaddr(r)    vtrmp[r]->trmyaddr
2204#define VTRMypsts(r)    vtrmp[r]->trmypsts
2205#define VTRMycase(r)    vtrmp[r]->trmycase
2206#define VTRMysize(r)    vtrmp[r]->trmysize
2207#define VTRMydocs(r)    vtrmp[r]->trmydocs
2208#define VTRMydisk(r)    vtrmp[r]->trmydisk
2209#define VTRMyread(r)    vtrmp[r]->trmyread
2210#define VTRMyleft(r)    vtrmp[r]->trmyleft
2211#else
2212#define VTRMpcblk(r)    vtrmp[r]->trmpcblk
2213#define VTRMpcpos(r)    vtrmp[r]->trmpcpos
2214#define VTRMifseg(r)    vtrmp[r]->trmifseg
2215#define VTRMifhdr(r)    vtrmp[r]->trmifhdr
2216#endif
2217
2218#if LIND
2219#define VTRMxytotp(r)   vtrmp[r]->trmypsts
2220#else
2221#define VTRMxytotp(r)   vtrmp[r]->trmifhdr.ifptotp
2222#endif
2223
2224#define VTRMifbuf(r)    vtrmp[r]->trmifbuf
2225
2226#endif /* CIAPI */
2227
2228#define TYPETRM     21
2229
2230#define RCEOF       (-1)        /*     */
2231#define RCNORMAL    0           /*     */
2232#define RCNEXT      1           /*     */
2233
2234#define ABNORMAL    0           /* gdb */
2235
2236/* CITRM Interface */
2237#if !CIAPI
2238#if !CICPP                      /* transferidas para a classe TRMSTRU */
2239#if ANSI
2240LONGX trmalloc(LONGX itrm, LONGX nbytes);
2241LONGX term(LONGX itrm, UCHR *dbnamp, UCHR *keyp);
2242LONGX nxterm(LONGX itrm);
2243LONGX posting(LONGX itrm, LONGX n);
2244int trmread(TRMSTRU *trmp, int treecase, UCHR **retkeyp);
2245N0STRU *noderead(INVMAP *invp, int treecase, int level, PUNT punt);
2246L0STRU *leafread(UCHR *lbufp, INVMAP *invp, int treecase, PUNT punt, int lxx);
2247#if !LIND
2248IFPSTRU *postread(UCHR *xbufp, INVMAP *invp, PUNT xblk, int lxx);
2249#else
2250IFPSTRU *postread(UCHR *xbufp, INVMAP *invp, off_t addr, unsigned int toread,
2251                                                                int lxx);
2252#endif
2253int cntread(DBXSTRU *dbxp, int *ifpopen, char *ifpname, int *firstcnli);
2254void invsetup(UCHR *dbnamp, LONGX loadn0x,LONGX loadl0x,LONGX loadpst);
2255void posthdr1(TRMSTRU *trmp);
2256void postpost(TRMSTRU *trmp);
2257void trminit(void);
2258void invflush(char *dbnamp);
2259INVMAP *dbxinvmp(DBXSTRU *dbxp);
2260void invclose(DBXSTRU *dbxp);
2261#else
2262LONGX trmalloc();
2263LONGX term();
2264LONGX nxterm();
2265LONGX posting();
2266int trmread();
2267N0STRU *noderead();
2268L0STRU *leafread();
2269IFPSTRU *postread();
2270int cntread();
2271void invsetup();
2272void posthdr1();
2273void postpost();
2274void trminit();
2275void invflush();
2276INVMAP *dbxinvmp();
2277void invclose();
2278#endif
2279#endif /* CICPP */
2280#endif /* CIAPI */
2281
2282/* global */
2283#if !CIAPI
2284#if !CICPP
2285extern TRMSTRU *vtrmp[];        /* pointers to the entries      */
2286extern LONGX ntrms;              /* actual #entries              */
2287extern LONGX maxntrm;            /* runtime value                */
2288#endif /* CICPP */
2289#endif /* CIAPI */
2290
2291#if !CICPP
2292extern int trmtrace;            /* trm TRSTRACE runtime switch  */
2293extern int trmifupd;            /* trm IFUPDATE operation */
2294extern unsigned char highv[];   /* trm high values              */
2295#endif /* CICPP */
2296
2297
2298
2299/* *****************************************************
2300CIUPD.H
2301***************************************************** */
2302
2303#if 1 /* MULTI */
2304#define MONONETS        0       /* single user (non network version) */
2305#define FULLNETS        1       /* full network version */
2306#define MASTNETS        2       /* restricted network support */
2307#endif
2308
2309#define BUFFUPL         (MAXMFRL+MAXMFRL)
2310
2311#define MS0ctlmfn       ms0p->m0ctlmfn
2312#define MS0nxtmfn       ms0p->m0nxtmfn
2313#define MS0nxtmfb       ms0p->m0nxtmfb
2314#define MS0nxtmfp       ms0p->m0nxtmfp
2315#define MS0mftype       ms0p->m0mftype
2316#define MS0reccnt       ms0p->m0reccnt
2317#define MS0mfcxx1       ms0p->m0mfcxx1
2318#define MS0mfcxx2       ms0p->m0mfcxx2
2319#define MS0mfcxx3       ms0p->m0mfcxx3
2320
2321#define MSHmfn          mshp->m1mfn
2322#define MSHmfrl         mshp->m1mfrl
2323#define MSHmfbwb        mshp->m1mfbwb
2324#define MSHmfbwp        mshp->m1mfbwp
2325#define MSHbase         mshp->m1base
2326#define MSHnvf          mshp->m1nvf
2327#define MSHstatus       mshp->m1status
2328
2329#define MS1mfn          ms1p->m1mfn
2330#define MS1mfrl         ms1p->m1mfrl
2331#define MS1mfbwb        ms1p->m1mfbwb
2332#define MS1mfbwp        ms1p->m1mfbwp
2333#define MS1base         ms1p->m1base
2334#define MS1nvf          ms1p->m1nvf
2335#define MS1status       ms1p->m1status
2336#define MS1dir          ms1p->m1dir
2337
2338#define MSDtag(x)       ms1p->m1dir[x].tag
2339#define MSDpos(x)       ms1p->m1dir[x].pos
2340#define MSDlen(x)       ms1p->m1dir[x].len
2341
2342
2343/* CIUPD Interface */
2344#if !CICPP                      /* transferidas para a classe RECSTRU */
2345#if ANSI
2346#if MULTI
2347int recunlck(LONGX irec, int option);
2348#endif
2349int recisis0(char *dbnamp);
2350int recupdat(LONGX crec, LONGX irec);
2351int recwrite(RECSTRU *crecp, RECSTRU *recp);
2352int recwmast(RECSTRU *crecp, RECSTRU *recp, LONGX b, int p, int nblk, FFI wlen);
2353int recwxref(RECSTRU *recp, XRPTR pointer, LONGX lastmfn);
2354char *fldupdat(LONGX irec, char *batchp);
2355void recreset(char *dbnamp, LONGX mfn1, LONGX mfn2, LONGX xrec, LONGX parmtell);
2356#else
2357#if MULTI
2358int recunlck();
2359#endif
2360int recisis0();
2361int recupdat();
2362int recwrite();
2363int recwmast();
2364int recwxref();
2365char *fldupdat();
2366void recreset();
2367#endif
2368#endif /* CICPP */
2369
2370/* global */
2371#if !CICPP
2372extern int multrace;                    /* upd MULTRACE runtime switch */
2373extern int recisis0_m;                  /* recisis0() init .mst */
2374#endif /* CICPP */
2375
2376
2377/* *****************************************************
2378CIUPI.H
2379***************************************************** */
2380/* CIUPI Interface */
2381#if ANSI
2382#if CICPP
2383int trmisis0(CISISX *cisisxp,char *dbnamp);
2384#else
2385int trmisis0(char *dbnamp);
2386#endif /* CICPP */
2387int cntwrit(DBXSTRU *dbxp);
2388int nodewrit(DBXSTRU *dbxp,N0STRU *n0p,int level,int isroot);
2389int leafwrit(DBXSTRU *dbxp,L0STRU *l0p);
2390#if CNV_PCBINUM
2391int ifpwrit(DBXSTRU *dbxp, char *buffer, LONGX nbytes, INFO hdblk[], INFO hdoff[], int hdn);
2392#else /* CNV_PCBINUM */
2393int ifpwrit(DBXSTRU *dbxp,char *buffer,LONGX nbytes);
2394#endif /* CNV_PCBINUM */
2395#else
2396int trmisis0();
2397int cntwrit();
2398int nodewrit();
2399int leafwrit();
2400int ifpwrit();
2401#endif
2402
2403
2404/* *****************************************************
2405CIUTL.H
2406***************************************************** */
2407
2408#define SFLDCHR '^'
2409
2410#if PC || MPE
2411#define OPENFCHR        '�'
2412#define CLOSFCHR        '�'
2413#endif
2414#if VAX
2415#define OPENFCHR        '"'
2416#define CLOSFCHR        '"'
2417#endif
2418#if UNIX
2419#define OPENFCHR        '"'
2420#define CLOSFCHR        '"'
2421#endif
2422
2423/* CIUTL Interface */
2424#if !CIAPI
2425#if CICPP
2426UBYTE *subfldp(UBYTE *fldp, UBYTE dlm, FFI *lenp);
2427FFI subfldn(UBYTE *sfldp, FFI len);
2428FFI subfield(UBYTE *fldp, FFI fldl, UBYTE dlm, UBYTE *areap);
2429char *loadfile(char *gidbnp, char at, char *atp, char *areap, LONGX asize, char lf2x);
2430char *loadstw(char *gidbnp, char *atp,char *areap,LONGX asize,int *nstws);
2431char *loaductb(char *gidbnp, char *uctbp, char *ucfilp);
2432char *loadactb(char *gidbnp, char *actbp, char *acfilp);
2433void decodepst(POSTSTRU *pstp, LONGX *mfnp, unsigned short *tagp,
2434          unsigned short *occp, unsigned short *cntp);
2435void encodepst(POSTSTRU *pstp, LONGX mfn, unsigned short tag,
2436          unsigned short occ, unsigned short cnt );
2437FFI bobkey(char *keyp,FFI klen,char *areap,FFI maxlen,int l,int m,int t);
2438#if CIAPI_SOURCE
2439LONGX prtifcnt  (TRMSTRU *trmp, char dbname[]);
2440LONGX prtcontrol(RECSTRU *recp, char dbname[]);
2441LONGX prtleader(RECSTRU *recp, LONGX mfn);
2442LONGX prtfields(RECSTRU *recp, LONGX mfn);
2443LONGX prtxref(CISISX *cisisxp, RECSTRU *recp, LONGX mfn);
2444LONGX prtdir(RECSTRU *recp, LONGX mfn);
2445int recfgets(CISISX *cisisxp, RECSTRU *crec, RECSTRU *irec, char line[], FFI linsiz, FILE *fpconv);
2446int reccopy(CISISX *cisisxp, RECSTRU *upirec,RECSTRU *upcrec,RECSTRU *recp,LONGX mfn);
2447unsigned LONGX showcore(char *msg);
2448char *recfield(CISISX *cisisxp, char *areap, RECSTRU *recp, int tag, int iocc, char *defaultp);
2449int fldocc(CISISX *cisisxp, RECSTRU *recp, int diridx);
2450#endif /* CIAPI_SOURCE */
2451#else /* CICPP */
2452#if ANSI
2453UBYTE *subfldp(UBYTE *fldp, UBYTE dlm, FFI *lenp);
2454FFI subfldn(UBYTE *sfldp, FFI len);
2455FFI subfield(UBYTE *fldp, FFI fldl, UBYTE dlm, UBYTE *areap);
2456LONGX prtifcnt  (TRMSTRU *trmp, char dbname[]);
2457LONGX prtcontrol(RECSTRU *recp, char dbname[]);
2458LONGX prtleader(RECSTRU *recp, LONGX mfn);
2459LONGX prtfields(RECSTRU *recp, LONGX mfn);
2460LONGX prtxref(RECSTRU *recp, LONGX mfn);
2461LONGX prtdir(RECSTRU *recp, LONGX mfn);
2462int recfgets(LONGX crec, LONGX irec, char line[], FFI linsiz, FILE *fpconv);
2463int reccopy(LONGX upirec, LONGX upcrec, RECSTRU *recp, LONGX mfn);
2464unsigned LONGX showcore(char *msg);
2465char *recfield(char *areap, LONGX ridx, int tag, int iocc, char *defaultp);
2466int fldocc(LONGX irec, int diridx);
2467char *loadfile(char *gidbnp, char at, char *atp, char *areap, LONGX asize, char lf2x);
2468char *loadstw(char *gidbnp, char *atp,char *areap,LONGX asize,int *nstws);
2469char *loaductb(char *gidbnp, char *uctbp, char *ucfilp);
2470char *loadactb(char *gidbnp, char *actbp, char *acfilp);
2471void decodepst(POSTSTRU *pstp, LONGX *mfnp, unsigned short *tagp,
2472                    unsigned short *occp, unsigned short *cntp);
2473void encodepst(POSTSTRU *pstp, LONGX mfn, unsigned short tag,
2474                    unsigned short occ, unsigned short cnt );
2475FFI bobkey(char *keyp,FFI klen,char *areap,FFI maxlen,int l,int m,int t);
2476#else
2477UBYTE *subfldp();
2478FFI subfldn();
2479FFI subfield();
2480LONGX prtcontrol();
2481LONGX prtleader();
2482LONGX prtfields();
2483LONGX prtxref();
2484LONGX prtdir();
2485int recfgets();
2486int reccopy();
2487unsigned LONGX showcore();
2488char *recfield();
2489int fldocc();
2490char *loadfile();
2491char *loadstw();
2492char *loaductb();
2493char *loadactb();
2494void decodepst();
2495void encodepst();
2496FFI bobkey();
2497#endif
2498#endif /* CICPP */
2499#endif /* CIAPI */
2500
2501
2502
2503/* *****************************************************
2504CIISO.H
2505***************************************************** */
2506
2507#define ISOBSIZ         99999L          /* wrn: is LONGX */    /* AOT, 06/06/2005 - length[5] */
2508
2509#define ISOLLEF         4
2510#define ISOLSCP         5
2511#define ISOXFS          '#'             /* 0x1E = 30 para Minisis */
2512#define ISOXGS          '#'             /* 0x1D = 29 para Minisis */
2513#define ISOXFSMARC      0x1E            /* 0x1E = 30 para Minisis and Marc */   /* AOT, 10/06/2005 */
2514#define ISOXGSMARC      0x1D            /* 0x1D = 29 para Minisis and Marc */   /* AOT, 10/06/2005 */
2515#define ISOXXSMARC      0x23            /* subfield  para Minisis and Marc */   /* AOT, 10/06/2005 */
2516
2517#if CICPP
2518class _YOURCLASS ISO_2709;       /* Para substituir def da struct */
2519#endif /* CICPP */
2520
2521typedef struct isohstru {
2522    unsigned char length[5];
2523    unsigned char status[1];
2524    unsigned char icodes[4];
2525    unsigned char indlen[1];
2526    unsigned char sublen[1];
2527    unsigned char basead[5];
2528    unsigned char forusr[3];
2529    unsigned char lenlef[1];
2530    unsigned char lenscp[1];
2531    unsigned char forfut[2];
2532} ISOHSTRU;
2533
2534typedef struct isodstru {
2535    unsigned char tagfld[3];
2536    unsigned char lenfld[ISOLLEF];
2537    unsigned char locfld[ISOLSCP];
2538} ISODSTRU;
2539
2540#define ISOHSIZE       sizeof(ISOHSTRU)
2541#define ISODSIZE       sizeof(ISODSTRU)
2542
2543#if !CICPP
2544extern int iso_ismarc;
2545#endif /* CICPP */
2546
2547/* CIISO Interface */
2548#if !CICPP
2549#if ANSI
2550int iso_open(char *gidbnp, unsigned char filnam[], int lrecb, int lrfix, int isfix);
2551int iso_read(LONGX crec, LONGX irec, unsigned int ldrtag);
2552int iso_creat(char *gidbnp, unsigned char filnam[], int lrecb, int lrfox, int isfox);
2553int iso_write(RECSTRU *recp, unsigned char isoxfs, unsigned char isoxgs, unsigned int ldrtag);
2554int iso_close(void);
2555int iso_rclos(void);
2556#else
2557int iso_open();
2558int iso_read();
2559int iso_creat();
2560int iso_write();
2561int iso_close();
2562int iso_rclos();
2563#endif
2564#endif /* CICPP */
2565
2566
2567
2568/* *****************************************************
2569CIB7.H
2570***************************************************** */
2571
2572#if CIB71
2573
2574#ifndef CIB7HITLIST
2575#define CIB7HITLIST     1
2576#endif
2577#ifndef CIB7TMPNULL
2578#define CIB7TMPNULL     1
2579#endif
2580
2581#if BEFORE20020127
2582#define MAXVOPR         512
2583#else                         /* 16K for MeSH/Drug category */
2584#define MAXVOPR         16384 /* 16K */  /* AOT, 29/01/2002 */
2585#endif                        /* 16K x sizeof(char)+sizeof(char)+sizeof(char*) */
2586#define MAXQUAL         20
2587#define MAXPDLS         32
2588#define MAXERRL         60
2589
2590#define ZORX  '+'
2591#define ZAND  '*'
2592#define ZANN  '^'
2593#if !LIND
2594#define ZANG  'G'
2595#define ZANF  'F'
2596#define ZANP  '.'
2597#define ZANE  '$'
2598#endif
2599#define ZASS  '='
2600#define ZLDV  '_'
2601#define ZPFX  '['
2602#define ZQUA  '/'
2603
2604#define TOKNULL         0
2605#define TOKDELIM        1
2606#define TOKTERM         2
2607
2608#define TBOOL           1
2609
2610#define MFQTDBN0        11
2611#define MFQTQRY0        12
2612#define MFQTOBJ0        13
2613
2614#define MFQTXCTS        20
2615
2616#define MFQSWTIM        't'
2617#define MFQSWDBN        'd'
2618#define MFQSWQTY        'q'
2619
2620#define MFQTASET        21
2621#define MFQTALCC        22
2622
2623#define MFQTHITS        31
2624#define MFQTHCUR        32
2625#define MFQTHMFN        33
2626#define MFQTHSIZ        34
2627#define MFQTHMEM        35
2628
2629#define OPRNULL         0x01
2630#define OPRXEND         0x02
2631#define PSTLEVEL        0x03
2632#define ACCLEVEL        0x04
2633
2634#define B7UPLEN         9               /* length for b40 numeric fields */
2635#define B7DELADD        "D%dA%d|%09ld|" /* sprintf format for dir/field */
2636#define B7EDIT1         "%09ld"         /* sprintf format for field edit */
2637
2638#define MFQTXTAG        101             /* inverted files prefixes */
2639
2640#define B7RE_X2         1
2641#define B7RE_X3         2
2642#define B7RE_X1         3
2643#define B7RE_53         4
2644#define B7RE_1          5
2645#define B7RE_2          6
2646#define B7RE_3          7
2647#define B7RE_4          8
2648#define B7RE_10         9
2649#define B7RE_18         10
2650#define B7RE_28         11
2651#define B7RE_PFX        12
2652#define B7RE_SET        13
2653
2654#define B7EE_X2         2
2655#define B7EE_PFX        11
2656
2657
2658/* estructura de la pila de ejecuci�/
2659typedef struct pdlstru {
2660   UCHR        *pdllvel;      /* bitstring, contiene la informacion de los postings. */
2661   LONGX        pdlleft;    /* cuanto queda del lvel */
2662   LONGX        pdldocs;    /* cantidad de documentos almacenados */
2663   LONGX        pdllmfn;    /* valor del �o MFN de la BD */
2664   LONGX        pdlsize;    /* tama�ctual de lvel */
2665   LONGX        pdlisiz;    /* tama�nicial de lvel, also growing step */
2666   short int   pdlplen;    /* tama�e los postings */
2667   char        *pdlnxtp;      /* proximo slot libre en lvel */
2668} PDLSTRU;
2669/*
2670   si plen == 0
2671      se usa un bit per MFN. * + ^
2672   sino
2673      3 bytes para MFN
2674      2 bytes para TAG  ==> 5 oper (G)
2675      1 byte  para OCC  ==> 6 oper (F)
2676      2 bytes para CNT  ==> 8 oper . $
2677
2678*/
2679
2680
2681#if CIB7HITLIST /* AOT 15/01/2002 */
2682
2683#define B7HITLISTLONG   1
2684#define B7HITLISTSHORT  2
2685
2686typedef struct b7hitbuf {
2687    LONGX setno;                         /* query number */
2688    LONGX bufsiz;                        /* buffer size */
2689    LONGX ndocs;                         /* number of docs */
2690    int  hcase;                         /* BITSTRING or MFNSTRING (4 bytes) */
2691    int  htype;                         /* list of LONGX or unsigned short mfn's */
2692    LONGX align4;                        /* 4-byte alignment */
2693    UBYTE area[1];                      /* buffer - via ALLOC() */
2694} B7HITBUF;
2695
2696typedef struct b7hitlist {
2697    LONGX mfnlist[1];                    /* array of mfn */
2698} B7HITLIST;
2699
2700typedef struct b7hitlistshort {
2701    unsigned short int mfnlist[1];      /* array of mfn - short */
2702} B7HITLISTSH;
2703
2704#else /* CIB7HITLIST */
2705
2706typedef struct b7hitbuf {
2707    LONGX setno;                         /* query number */
2708#if BEFORE20010607
2709    LONGX block;                         /* block number */
2710#endif
2711    LONGX bufsiz;                        /* buffer size */
2712    UBYTE area[1];                      /* buffer - via ALLOC() */
2713} B7HITBUF;
2714#endif /* CIB7HITLIST */
2715
2716
2717typedef struct
2718{
2719/*variables globales ... */
2720
2721/*cib71.c */
2722#if BOLTRACE
2723#define DISTRACE 1
2724   char *b7objp;
2725#endif
2726
2727   int and2gf;
2728   char *subst_and;
2729   LONGX b7setno1;
2730   LONGX b7setno;
2731   char *b7batchp;                 /* fldupdat */
2732   RECSTRU *b7recp;                /* current recp */
2733
2734#if FATRAP
2735/* error */
2736   jmp_buf b71jumper;
2737#endif
2738
2739   int b71error;
2740   char b7errxy[MAXERRL+1];       /* static */
2741
2742/* gettoken */
2743   char *tokbackp;
2744   char *toknextp;
2745   char *token;
2746   char toktyp;
2747   char tokopr;
2748   int tokqty;
2749   int toklen;
2750
2751   char *tokqualp;                 /* qualifiers */
2752   int tokquall;                   /* length */
2753   int tokqualn;                   /* no of elements in the list */
2754
2755   char *tokmassp;                 /* toknextp after b7_massp() */
2756
2757/* expressoes */
2758   int nb7oprs;
2759
2760/*cib72 */
2761   unsigned char mask;
2762   char *b7_gidbnp;
2763   PDLSTRU *vpdlp[MAXPDLS];
2764   int npdls;
2765   LONGX b7tell;
2766   LONGX b7itrm;
2767   int b7fd;
2768   int b7error;
2769   B7HITBUF *b7bufferp;
2770
2771   char b7_pfxdbn[CIMPL+1];
2772   char b7_pfxopx[LE2+LE2+1];
2773   FFI b7_pfxlen;
2774   char b7_pfxmsg[LE2+1];
2775   char b7_pfxtwx[CIMPL+1];
2776   FFI b7_pfxmdl;
2777
2778#if FIXTRACE
2779   int xtrac;
2780#endif
2781
2782   char vetopr[MAXVOPR],vetcas[MAXVOPR],*vetopp[MAXVOPR];
2783   int nop;
2784
2785#if !TLS
2786   void *ciapip;
2787#endif
2788   LONGX smfn;
2789   LONGX sirec;
2790
2791   short unsigned int nqualts,vqualt[MAXQUAL],*qualtp;
2792
2793   int b7rootmsg;
2794
2795   int b7tw2mh;
2796
2797} b7_CIB7;
2798
2799#if !CIAPI && !CIAPI_SOURCE
2800extern int b70trace;            /* b70 RUXTRACE runtime switch */
2801#endif /* !CIAPI && !CIAPI_SOURCE */
2802
2803
2804/* --------------------- cib70.h --------------------- */
2805
2806/* CIB71 Interface */
2807#if ANSI
2808char *b7_exp(b7_CIB7 *cib7p, LONGX irec, char *dbnamp, char *qryp,
2809               char *buffup, char *qrydbnp, LONGX crec, int *errnop);
2810char *b7_run(b7_CIB7 *cib7p, LONGX irec,char *dbnamp,char *buffup, int buffuplen,
2811            LONGX tell,unsigned char uctab[],char *btch0p,
2812            LONGX tlirecp,LONGX crec,int *errnop);
2813LONGX b7_hit(b7_CIB7 *cib7p, LONGX irec, LONGX nord, LONGX setno);
2814int b7_hballoc(b7_CIB7 *cib7p, LONGX bufsiz, B7HITBUF **bufferpp);
2815int b7_hbinit(b7_CIB7 *cib7p, LONGX setno, B7HITBUF *bufferp);
2816int b7_hbfree(b7_CIB7 *cib7p, B7HITBUF **bufferpp);
2817#else /* ANSI */
2818char *b7_exp();
2819char *b7_run();
2820LONGX b7_hit();
2821int b7_hballoc();
2822int b7_hbinit();
2823int b7_hbfree();
2824#endif /* ANSI */
2825#else /* CIB71 */
2826
2827
2828/* *****************************************************
2829CIB40.H
2830***************************************************** */
2831
2832#if !LIND && !CIB64
2833
2834#define BX0CDROM        1       /* Bx0 is a bit more user friendly */
2835#define SHOWCORE        1       /* 1 to show coreleft if b40trace is on */
2836
2837#define MAXVOPR         512
2838#define MAXQUAL         20
2839#define MAXPDLS         32
2840#define MAXERRL         60
2841
2842#define ZORX  '+'
2843#define ZAND  '*'
2844#define ZANN  '^'
2845#if !LIND
2846#define ZANG  'G'
2847#define ZANF  'F'
2848#endif
2849#define ZANP  '.'
2850#define ZANE  '$'
2851#define ZASS  '='
2852#define ZLDV  '_'
2853#define ZQUA  '/'
2854
2855#define TOKNULL         0
2856#define TOKDELIM        1
2857#define TOKTERM         2
2858
2859#define TBOOL           1
2860
2861#define OPRNULL         0x01
2862#define OPRXEND         0x02
2863#define PSTLEVEL        0x03
2864#define ACCLEVEL        0x04
2865
2866#define MFQTDBN0        11
2867#define MFQTQRY0        12
2868#define MFQTOBJ0        13
2869
2870#define MFQTXCTS        20
2871
2872#define MFQSWTIM        't'
2873#define MFQSWDBN        'd'
2874#define MFQSWQTY        'q'
2875
2876#define MFQTASET        21
2877#define MFQTALCC        22
2878
2879#define MFQTHITS        31
2880#define MFQTHCUR        32
2881#define MFQTHMFN        33
2882#define MFQTHSIZ        34
2883#define MFQTHMEM        35
2884
2885#define MFQXHMFNx       'C'
2886#define MFQXHTAGx       'A'
2887#define MFQXHOCCx       'S'
2888#define MFQXHCNTx       'E'
2889
2890
2891#define B4UPLEN         6               /* length for b40 numeric fields */
2892#define B4DELADD        "D%dA%d|%06ld|" /* sprintf format for dir/field */
2893#define B4EDIT1         "%06ld"         /* sprintf format for field edit */
2894
2895#define MFQTXTAG        101             /* inverted files prefixes */
2896
2897typedef struct irxstru {
2898    LONGX     irxbytes;          /* irx bytes */
2899    LONGX     irxhits;
2900    char     irxarea[1];        /* irx area  */
2901} IRXSTRU;
2902
2903
2904/* CIB40 Interface */
2905#if ANSI
2906char *b4_exp(LONGX irec, char *dbnamp, char *qryp,char *qrydbnp, int *errnop);
2907char *b4_run(LONGX irec, char *dbnamp, LONGX nbytes1, LONGX nbytes2, LONGX tell,
2908                unsigned char uctab[], LONGX tlirec, int *errnop);
2909LONGX b4_hit(LONGX irec, LONGX nhit);
2910int b4_msg(int tline, char *msg, LONGX psts, LONGX docs, int tmsg);
2911int b4_kbh();
2912char *b4_massp(char *tken, int tklen,
2913                                char *tkqualp, int tkquall, char *tknextp);
2914char *b4_xlkey(char *opx, char *bufp, unsigned char uctab[], char *xlfilp,
2915                                                                int *opxlp);
2916#else
2917char *b4_exp();
2918char *b4_run();
2919LONGX b4_hit();
2920int b4_msg();
2921int b4_kbh();
2922char *b4_massp();
2923char *b4_xlkey();
2924#endif
2925
2926/* global */
2927#if !CICPP
2928extern int b40trace;
2929extern char b4_tmpnam[];
2930extern LONGX b4setno;
2931/* extern ...;  */
2932#endif /* CICPP */
2933
2934#endif /* CIB40 */
2935
2936
2937/* *****************************************************
2938CIB50.H
2939***************************************************** */
2940
2941#if LIND || CIB64
2942
2943#define ERRTRACE        0
2944#define BX0CDROM        1       /* Bx0 is a bit more user friendly */
2945#if CICPP
2946#define SHOWCORE        0       /* 1 to show coreleft if b50trace is on */
2947#else /* CICPP */
2948#define SHOWCORE        1       /* 1 to show coreleft if b50trace is on */
2949#endif /* CICPP */
2950#define MAXPDLS         32
2951#define MAXERRL         81
2952
2953#define ZORX  '+'
2954#define ZAND  '*'
2955#define ZANN  '^'
2956#define ZLDV  '_'
2957#define ZPFX  '['
2958#define ZPDL  '{'
2959
2960#define TOKNULL         0
2961#define TOKDELIM        1
2962#define TOKTERM         2
2963
2964#define TBOOL           1
2965
2966#define OPRNULL         0x01
2967#define OPRXEND         0x02
2968#define PSTLEVEL        '1'
2969#define ACCLEVEL        '1'
2970#define FLDUPXB5        0x05
2971
2972#define MFQTDBN0        11
2973#define MFQTQRY0        12
2974#define MFQTOBJ0        13
2975
2976#define MFQTXCTS        20
2977
2978#define MFQSWTIM        't'
2979#define MFQSWDBN        'd'
2980#define MFQSWQTY        'q'
2981
2982#define MFQTASET        21
2983#define MFQTALCC        22
2984
2985#define MFQTHITS        31
2986#define MFQTHCUR        32
2987#define MFQTHMFN        33
2988#define MFQTHSIZ        34
2989#define MFQTHMEM        35
2990
2991#define MFQTSNAM        36
2992
2993#define MFQTHITX        41              /* CDUSP */
2994
2995#define B5UPLEN         8               /* length for b50 numeric fields */
2996#define B5DELADD        "D%dA%d|%08ld|" /* sprintf format for dir/field */
2997#define B5EDIT1         "%08ld"         /* sprintf format for field edit */
2998
2999#define MFQTXTAG        101             /* inverted files prefixes */
3000
3001#define B5RE_X2         1
3002#define B5RE_X3         2
3003#define B5RE_X1         3
3004#define B5RE_53         4
3005#define B5RE_1          5
3006#define B5RE_2          6
3007#define B5RE_3          7
3008#define B5RE_4          8
3009#define B5RE_10         9
3010#define B5RE_18         10
3011#define B5RE_28         11
3012#define B5RE_PFX        12
3013#define B5RE_SET        13
3014
3015#if ! CICPP
3016#if BIGREC
3017#else /* BIGREC */
3018typedef struct b6hitbuf {
3019    LONGX setno;                         /* query number */
3020    LONGX block;                         /* block number */
3021    LONGX bufsiz;                        /* buffer size */
3022    UBYTE area[1];                      /* buffer - via ALLOC() */
3023} B6HITBUF;
3024#endif /* BIGREC */
3025#endif /* CICPP */
3026
3027/* CIB50 Interface */
3028#if !CICPP
3029#if ANSI
3030char *b5_exp(LONGX irec, char *dbnamp, char *qryp,
3031                char *buffup, char *qrydbnp, LONGX crec, int *errnop);
3032#if BIGREC
3033char *b5_run(LONGX irec, char *dbnamp,
3034                char *buffup, LONGX nbytes1, LONGX tell,
3035                unsigned char uctab[], char *btch0p, LONGX tlirec, LONGX crec,
3036                int *errnop);
3037LONGX b5_hit(LONGX irec, LONGX nhit, char *buffup);
3038#else /* BIGREC */
3039char *b6_run(LONGX irec, char *dbnamp,
3040                char *buffup, int buffuplen, LONGX nbytes1, LONGX tell,
3041                unsigned char uctab[], char *btch0p, LONGX tlirec,
3042      LONGX crec, int *errnop);
3043LONGX b6_hit(LONGX irec, LONGX nhit, LONGX setno, B6HITBUF *bufferp);
3044int b6_hballoc(LONGX bufsiz, B6HITBUF **bufferpp);
3045int b6_hbinit(LONGX setno, B6HITBUF *bufferp);
3046int b6_hbfree(B6HITBUF **bufferpp);
3047#endif /* BIGREC */
3048int b5_msg(int tline, char *msg, LONGX docs, int tmsg);
3049int b5_kbh(void);
3050char *b5_massp(char *tken, int tklen, int b5ee_pfx);
3051void b5_experr(int error, char *errp, int errl);
3052int b50read(DBXSTRU *dbxp,LONGX mfn,int tag,int occ,char *areap,LONGX *areasizp);
3053int b5_pfx(LONGX irec, UWORD invxtag, char *dp, char *op, int b5re_pfx);
3054int b5_nxtoken(void); /* now return toktype */
3055#else /* ANSI */
3056char *b5_exp();
3057#if BIGREC
3058char *b5_run();
3059LONGX b5_hit();
3060#else /* BIGREC */
3061char *b6_run();
3062LONGX b6_hit();
3063int b6_hballoc();
3064int b6_hbinit();
3065int b6_hbfree();
3066#endif /* BIGREC */
3067int b5_msg();
3068int b5_kbh();
3069char *b5_massp();
3070void b5_experr();
3071int b50read();
3072int b5_pfx();
3073int b5_nxtoken();
3074#endif /* ANSI */
3075#endif /* CICPP */
3076
3077/* global */
3078#if !CICPP
3079extern char *toknextp;          /* b5_nxtoken input data */
3080extern int toklen;              /* token length */
3081#if BEFORE970507
3082extern char *token;             /* token addr */
3083extern int toktyp;              /* token type - return by b5_nxtoken() */
3084#endif
3085
3086extern LONGX b5setno;            /* query set number */
3087extern char b53_tmpnam[];       /* tmp file name for b5_run() */
3088extern int b50trace;            /* b50 RUXTRACE runtime switch */
3089extern DBXSTRU *b5_savdbxp;     /* '@' processing for b5_run() */
3090extern LONGX b5_isn1;            /* query #0 lower limit */
3091extern LONGX b5_isn2;            /* query #0 upper limit */
3092
3093#if BIGREC
3094#else /* BIGREC */
3095extern B6HITBUF *b6bufferp;     /* b6_run() processing buffer */
3096#endif /* BIGREC */
3097
3098#endif /* CIB50 */
3099#endif /* CICPP */
3100
3101#endif /* CIB71 */
3102
3103
3104/* *****************************************************
3105Current master file record & inverted file term
3106***************************************************** */
3107
3108/* CIAOT Definitions */
3109
3110/* Current master file record */
3111
3112#if !CIAPI
3113#if !CICPP                      /* nao existe mais prateleira de registros */
3114#define RECORD(irec,dbn,mfn)    recp=vrecp[(unsigned)record(irec,dbn,mfn)]
3115#define RECALLOC(irec,n)        recp=vrecp[(unsigned)recallok(irec,n)]
3116#endif /* CICPP */
3117#endif /* CIAPI */
3118
3119/* Current inverted file term (and postings) */
3120
3121#if !CIAPI
3122#if !CICPP                      /* nao existe mais prateleira de termos */
3123#define TERM(itrm,dbn,key)      trmp=vtrmp[(unsigned)term(itrm,dbn,key)]
3124#define NXTERM(itrm)            trmp=vtrmp[(unsigned)nxterm(itrm)]
3125#define TRMALLOC(itrm,n)        trmp=vtrmp[(unsigned)trmalloc(itrm,n)]
3126#endif /* CICPP */
3127#endif /* CIAPI */
3128
3129
3130
3131/* *****************************************************
3132CIFMT.H
3133***************************************************** */
3134
3135/* CDS/ISIS Formatting Language interface */
3136
3137#if !EXCFMXML
3138#ifndef CI_XMLELEM
3139#define CI_XMLELEM 0 //1   v5.2 - AOT, 28/12/2005
3140#endif
3141#endif
3142
3143typedef enum ins {
3144   dummy, jumpf, jumpt, jump, pre_cond, pre_r_lit, pre_r_lit_plus,
3145   suf_cond, suf_cond_null, suf_r_lit, suf_r_lit_plus,
3146   set_true_rep, set_false_rep, test_rep, begin, end,
3147
3148   beg_init_not_rep,
3149   end_init_not_rep,
3150   beg_init_rep,
3151   end_init_rep,
3152
3153   begin_rep_gr, end_rep_gr, test_occ, print_field, d_dummy, n_dummy,
3154   load_field_all, load_field_occ, load_number, load_string,
3155   x_spac, c_spac, slash_spac, n_sigx_spac, n_sign_spac, percent_spac,
3156   mpl_par, mpu_par, mhl_par, mhu_par, mdl_par, mdu_par,
3157   escape_seq, u_cond, print_mfn, load_mfn, absent, present, contains,
3158   neq_op, lss_op, gtr_op, leq_op, geq_op, eql_op, or_op, and_op, not_op,
3159   plus_op, minus_op, times_op, divide_op,
3160   init_if, end_then, end_else, fi, val_beg, val_end,
3161   print_core, print_maxmfn, load_core, load_maxmfn,
3162   rupx_beg, rupx_end, rupd_beg, rupd_end, syst_beg, syst_end,
3163   date_mktime_beg, date_mktime_end, /* AOT */
3164   rsum_beg, rsum_end, rmax_beg, rmax_end,
3165   rmin_beg, rmin_end, ravr_beg, ravr_end,
3166   l_beg, l_end, s_beg, s_end, fmt_beg, fmt_end, f_beg, f_end, str_cat,
3167   getenv_beg, getenv_end,
3168   putenv_beg, putenv_end,
3169   prt_str_f,
3170   ref_beg, ref_end,
3171   refu_beg,refu_end, /* Ref aparecendo com funcao */
3172   read_mfn,
3173   update_fld, input_fld, lw_beg, lw_end,
3174   dbname_beg, dbname_end,load_float,
3175   noccins,
3176   np_beg,np_end,
3177   ioccins,
3178   continueins,breakins,
3179   size_beg, size_end,
3180   type_beg, type_end,
3181   load_mstnam, /* print_mstnam, */
3182   load_date, /* print_date, */
3183   duptop,  /* duplicar topo pilha */
3184   end_select,
3185   datex_beg,datex_end, /* AOT */
3186   instr_beg, instr_end,
3187   left_beg,left_end,
3188   right_beg,right_end,
3189   mid_beg,mid_end,
3190   cat_beg, cat_end,
3191        replac_beg,replac_end,
3192#if CI_XMLELEM
3193        xmlelem_beg,xmlelem_end,
3194#endif
3195   nl_beg,nl_end,
3196        ign_cond, /*12-03-99 ignore conditional lits without field selector */
3197      while_beg,while_end,
3198      occins,
3199      eattrib_beg,eattrib_end,sattrib_beg,sattrib_end,
3200      intvvalue,strvvalue,
3201      ss_beg,ss_end,
3202      citype_beg,citype_end,
3203   zzzzzz
3204} instruction_code;
3205
3206typedef int label;
3207
3208typedef struct intermediate_code {
3209   label  lab;
3210   instruction_code  instr;
3211   LONGX  add;
3212} pgm_node;
3213
3214#if CICPP
3215class _YOURCLASS FMTSTRU;       /* Para substituir def da struct */
3216#endif /* CICPP */
3217
3218#if CIAPI
3219typedef void FMT_CODE;
3220#else /* CIAPI */
3221typedef struct lista {
3222    pgm_node info;
3223    LONGX  m_add;
3224    LONGX  next;
3225} FMT_CODE;
3226#endif /* CIAPI */
3227
3228
3229/* CIFMT Interface */
3230
3231#if !CIAPI
3232
3233#if CIAPI_SOURCE
3234LONGX recfmt( RECSTRU* recp, LONGX lw, char *fmt, char *area, LONGX asize);
3235LONGX recfmtcmp(RECSTRU* recp, LONGX lw, char *fmt, char *area, LONGX asize,
3236                    FMTSTRU **ptpgm, int flagfree);
3237#endif /* CIAPI_SOURCE */
3238
3239#if !CICPP
3240#if ANSI
3241LONGX recfmt(   LONGX irec, LONGX lw, char *fmtp, char *areap, LONGX asize);
3242LONGX recfmtcmp(LONGX irec, LONGX lw, char *fmtp, char *areap, LONGX asize,
3243                    FMT_CODE **pgmpp, int flagfree);
3244LONGX fmt_gener(FMT_CODE **pgmpp, char *fmtp);
3245LONGX fmt_inter(FMT_CODE  *pgmp, LONGX irec, LONGX lw, char *areap, LONGX asize);
3246void fmt_free( FMT_CODE  *pgmp);
3247#else
3248LONGX recfmt();
3249LONGX recfmtcmp();
3250LONGX fmt_gener();
3251LONGX fmt_inter();
3252void fmt_free();
3253#endif
3254#endif /* CICPP */
3255
3256/* global */
3257#if !CICPP
3258extern int fmttrace;
3259extern LONGX fmt_error; /* error - code */
3260extern LONGX fmt_errof; /* error - fmt spec offset to error */
3261extern LONGX fmt_fsiz;  /* fmt_inter() - to set max field length */
3262#endif /* CICPP */
3263
3264#endif /* !CIAPI */
3265
3266
3267/* *****************************************************
3268CIFST.H
3269***************************************************** */
3270
3271#if CICPP
3272#if USE_GDBFMT
3273#define FMT_CODX char
3274#else /* USE_GDBFMT */
3275#define FMT_CODX char /*FMTSTRU */
3276#endif /* USE_GDBFMT */
3277#else
3278#define FMT_CODX FMT_CODE
3279#endif /* CICPP */
3280
3281#if CICPP
3282class _YOURCLASS FSTSTRU;       /* Para substituir def da struct */
3283#endif /* CICPP */
3284
3285typedef struct fst_code {
3286    UWORD tag;
3287    int it;
3288    FMT_CODX *fmtp;
3289    struct fst_code *nextp;
3290} FST_CODE;
3291
3292typedef struct link1 {
3293    UCHR key[LE1];
3294    POSTSTRU post;
3295} LINK1;
3296
3297typedef struct link2 {
3298    UCHR key[LE2];
3299    POSTSTRU post;
3300} LINK2;
3301
3302#define FSTERR1 1
3303#define FSTERR2 2
3304#define FSTERR3 3
3305#define FSTERRF 4
3306
3307/* CIFST Interface */
3308
3309#if !CICPP
3310#if ANSI
3311LONGX recfst(   LONGX irec, char *fstspecp,
3312                             char *area1p, LONGX max1,
3313                             char *area2p, LONGX max2,
3314                             LONGX *qty1, LONGX *qty2);
3315LONGX recfstcmp(LONGX irec, char *fstspecp,
3316                             char *area1p, LONGX max1, char *area2p,
3317                             LONGX max2, LONGX *qty1, LONGX *qty2,
3318                             FST_CODE **pgmpp, int flagfree);
3319LONGX fst_gener(FST_CODE **pgmpp, char *fstspecp);
3320LONGX fst_inter(FST_CODE  *pgmp, LONGX irec, char *stwp,
3321         char **area1pp, LONGX max1,
3322         char **area2pp, LONGX max2,
3323         LONGX *qty1p, LONGX *qty2p);
3324void fst_free( FST_CODE  *pgmp);
3325int fst_link(char *pfxp, int plen, char *keyp, int klen,
3326         LONGX mfn, UWORD tag, UWORD occ, UWORD cnt,
3327         char *link1, char *link2, LONGX *lft1, LONGX *lft2);
3328int fst_writ(int treecase, LONGX mfn, UWORD tag, UWORD occ, UWORD cnt,
3329         char *kp, int kl, UCHR *uctabp);
3330int fst_open(char *gidbnp, char *filnamp, int treecase);
3331int fst_clos(int treecase);
3332void pstdecod(POSTSTRU *pst, LONGX *mfn, UWORD *tag, UWORD *occ, UWORD *cnt);
3333void prtlink(char *sp, LONGX mfn, UWORD tag,UWORD occ,UWORD cnt, UCHR *keyp, int len);
3334#else
3335LONGX recfst();
3336LONGX recfstcmp();
3337LONGX fst_gener();
3338LONGX fst_inter();
3339void fst_free();
3340int fst_link();
3341int fst_writ();
3342int fst_open();
3343int fst_clos();
3344void pstdecod();
3345void prtlink();
3346#endif
3347
3348#endif /* CICPP */
3349
3350/* global */
3351#if !CICPP
3352extern int fsttrace;    /* fst FSSTRACE runtime switch */
3353#endif /* CICPP */
3354#if !CICPP
3355extern LONGX fst_error;  /* gener - fst spec error */
3356extern LONGX fst_errl;   /* gener - fst spec line where error occured */
3357extern char *fst_errp;  /* gener - fst spec ptr where error occured */
3358extern char *fst_fmtap; /* inter - static format area */
3359extern LONGX fst_fmtby;  /* inter - bytes for dynamic format area */
3360extern char fst_rdlm;   /* inter - new occ delimiter */
3361extern int fst_fd[];    /* inter - file descriptor for .ln1/.ln2 */
3362extern LONGX fst_fx[];   /* inter - output records to .ln1/.ln2 */
3363extern int cifstfix;    /* inter - key %8ld %5d %4d %4d */
3364extern int cifstfim;    /* inter - key %8ld w/ cifstfix */
3365extern char *fst_batchup; /* inter - batchp for fldupdat() area */
3366extern char *fst_batchp;/* inter - batchp for fldupdat() commands */
3367extern int fst_batch0;  /* inter - batchp ^mmfn^oocc^ccnt^l1/2 option */
3368extern char *fst_hdrp;  /* inter - hit file headers - area */
3369extern int fst_hdrx;    /* inter - hit file headers - #bytes allocated */
3370extern int fst_hdru;    /* inter - hit file headers - #bytes stored */
3371extern int fst_hdrt;    /* inter - hit file headers - for area+^m^t^o^c */
3372extern char *fst_wlupifnp; /* inter - word lookup I/F for TW processing */
3373extern TRMSTRU *fst_wluptrmp; /* inter - word lookup I/F for TW processing */
3374extern LONGX fst_wlupitrm; /* inter - word lookup I/F for TW processing */
3375#endif /* CICPP */
3376
3377
3378/* *****************************************************
3379CIIFx.H
3380***************************************************** */
3381
3382#if IFUPDATE
3383#define IFUPDICT     0
3384#define IFUPISIS     1
3385
3386#define IFUPCORE     0
3387#define IFUPWRIT     1
3388#define IFUPCLOS     2
3389
3390#define IFUPDXUP     1
3391#define IFUPDXLD     2
3392
3393#define MAXIFMRG     1024 /* svdifmerg() */  /* AOT 22/06/2001 */
3394#endif
3395
3396/* CIIFx Interface */
3397
3398#if CICPP
3399class _YOURCLASS CIIFU;       /* Para substituir def da struct */
3400class CIIFL;       /* Para substituir def da struct */
3401#endif /* CICPP */
3402
3403#if !CICPP
3404#if ANSI
3405#if  BEFORE20000926
3406int upif_end(int pstflag);
3407#else /* BEFORE20000926 */
3408int upif_end(char *dbnp, int pstflag);
3409void upif_save(char *dbnp);
3410void upif_restore(char *dbnp);
3411#endif /* BEFORE20000926 */
3412void upif_init(char *dbnp);
3413#if LIND
3414LONGX svdiflind(char *dbnp,char *filekeys_1,char *filekeys_2,
3415                  LONGX maxmfn,char *logp,
3416                  int pstflag,LONGX tell);
3417#else
3418LONGX svdifload(char *dbnp,char *filekeys_1,char *filekeys_2,
3419                  int pstflag,LONGX tell);
3420#endif
3421LONGX svdifmerg(char *dbnp,char *vifnamp[],LONGX vifmfns[],
3422               LONGX parmxmfn,char *parmlogp,int pstflag,LONGX tell);
3423int ifupdat(char *mdbnp,LONGX mfn1,LONGX mfn2,char *idbnp,FST_CODE *fstp,
3424         char *stwp,LONGX maxlk1,LONGX maxlk2,int pstflag,int endup);
3425void svdifupd(char *lnk1p,LONGX qtylk1,char *lnk2p,LONGX qtylk2,
3426         char *olnk1p,LONGX oqtylk1,char *olnk2p,LONGX oqtylk2,
3427         int pstflag,LONGX tell);
3428#else
3429int upif_end();
3430void upif_init();
3431#if LIND
3432LONGX svdiflind();
3433#else
3434LONGX svdifload();
3435#endif
3436LONGX svdifmerg();
3437void svdifupd();
3438int ifupdat();
3439#endif /* ANSI */
3440#endif /* CICPP */
3441
3442/* global */
3443#define CIIFLFIX        1
3444#if !CICPP
3445#if CIIFLFIX
3446extern int ciiflfix;    /* svdifload/lind() - key %8ld %5d %4d %4d */
3447extern int ciiflfim;    /* svdifload/lind() - key %8ld w/ ciiflfix */
3448#endif
3449
3450extern int ifupd_reset;    /* ifupdat() reset IfUpdPend flags */
3451extern int ifupd_wrnmsg;   /* ifupdat() warning messages */
3452#endif /* CICPP */
3453
3454/* see DBXi.... */
3455
3456
3457
3458/* *****************************************************
3459ISISUCTAB & others
3460***************************************************** */
3461
3462#if CICPP
3463#else /* CICPP */
3464#if CIAPI
3465#else /* CIAPI */
3466/* tabelas de mxaot.c
3467*/
3468extern unsigned char isisuctab[];
3469extern int isiswctot;
3470extern unsigned char isiswctab[];
3471extern unsigned char isisactab[];
3472extern unsigned char ansimctab[]; /* convert=ansi */ /* asc2ansi */
3473extern unsigned char arabmctab[]; /* convert=arab */ /* 708_1256 */
3474extern unsigned char ansiuctab[];
3475extern unsigned char ansiactab[];
3476
3477extern int NXPAGES[];           /* AOT, 21/02/2001 */
3478#endif /* CIAPI */
3479#endif /* CICPP */
3480
3481
3482
3483/* *****************************************************
3484MXAOT & others utilities
3485***************************************************** */
3486#if 1 /* !CIAPI_SOURCE */
3487#ifndef ISIS_DLL
3488#ifndef MXFUN
3489#define MXFUN       1              /* AOT, 21/02/2001 */
3490#endif
3491#ifndef IFLOADFUN
3492#define IFLOADFUN   1              /* AOT, 21/02/2001 */
3493#endif
3494#endif /* ISIS_DLL */
3495#if PC
3496#ifndef MYSFUN
3497#define MYSFUN      1              /* AOT, 21/05/2001 */
3498#endif
3499#else
3500#ifndef MYSFUN
3501#define MYSFUN      0              /*                 */
3502#endif
3503#endif
3504#endif /* !CIAPI_SOURCE */
3505
3506/* MXAOT Interface */
3507int mxexec(int argc,char *argv[]);
3508#if MXFUN
3509int cisis_mx(char *stringp);
3510#endif /* MXFUN */
3511
3512/* IFLOADAOT Interface */
3513int ifloadexec(int argc,char *argv[]);
3514#if IFLOADFUN
3515int cisis_ifload(char *stringp);
3516#endif /* MXFUN */
3517
3518
3519/* MYSAOT Interface */
3520#if MYSFUN
3521int cisis_mysfunc(char *gidbnp, int parmlen, char *parmin, char *parmout, LONGX parmtell);
3522#endif /* MYSFUN */
3523
3524
3525/* *****************************************************
3526   Funzioni di Conversione
3527   Original code by Beppe Romano (quadri.nis.garr.it)
3528***************************************************** */
3529
3530#if CNV_PCBINUM
3531#if ANSI
3532int ConvertMST_CTLSTRUCT(char *buffer);
3533
3534int ConvertMST_LEADER(char *buffer, int skipval, int breakval);
3535int ConvertMST_DIR(char *buffer, int nvf);
3536
3537int ConvertXRF_REC(char *buffer);
3538int ConvertXRF_PTR(char *buffer);
3539
3540int ConvertCNT_REC(char *buffer);      /* changed (1 .cnt rec) */
3541int ConvertN01_REC(char *buffer);
3542int ConvertN02_REC(char *buffer);
3543int ConvertL01_REC(char *buffer);
3544int ConvertL02_REC(char *buffer);
3545int ConvertIFP_BLKCTL(char *buffer, int blk1);
3546int ConvertIFP_PSTHDR(char *buffer);
3547int ConvertBuffer(char *buffer, int fieldlength);
3548#else
3549int ConvertL02_REC();
3550int ConvertN02_REC();
3551int ConvertL01_REC();
3552int ConvertN01_REC();
3553int ConvertMST_CTLSTRUCT();
3554int ConvertMST_LEADER();
3555int ConvertMST_DIR();
3556int ConvertCNT_REC();
3557int ConvertXRF_PTR();
3558int ConvertXRF_REC();
3559int ConvertIFP_BLKCTL();
3560int ConvertIFP_PSTHDR();
3561int ConvertBuffer();
3562#endif
3563#endif /* CNV_PCBINUM */
3564
3565
3566#if CICGI
3567
3568#if PC
3569#define CICGI_VALSIZE           (MAXMFRL/8)
3570#define CICGI_NAMESIZE          (MAXMFRL/8)
3571#define CICGI_MAXENTRIES        256 /* 64 */
3572#define CICGI_WORDSIZE          (MAXMFRL/8)
3573#else
3574#define CICGI_VALSIZE           MAXMFRL
3575#define CICGI_NAMESIZE          MAXMFRL
3576#define CICGI_MAXENTRIES        4096 /* 1024 */
3577#define CICGI_WORDSIZE          MAXMFRL
3578#endif
3579
3580typedef struct {
3581    char *namp;
3582    char *valp;
3583} CICGI_ENTRY;
3584
3585#if CICPP
3586class _YOURCLASS CGIClass;       /* Para substituir def da struct */
3587#endif /* CICPP */
3588
3589#if !CICPP
3590#if ANSI
3591int cicgi0(int *argc, char *argv[], char **wwwp, UWORD taghxsub, char *taghpfxp);
3592int cicgi1(int *argc, char *argv[], CICGI_ENTRY entries[], int nentries, char *cicgi_p);
3593#else
3594int cicgi0();
3595int cicgi1();
3596#endif
3597
3598extern int cgitrace; /* extern */
3599#endif /* CICPP */
3600
3601#endif /* CICGI */
3602
3603
3604
3605#include "cihsh.h"      /* CISIS Interface hashing & binary table search */
3606#if CIWTF                                /* WTFUN support */
3607/* header files */
3608#include <math.h>
3609#include <time.h>
3610//#include "cihsh.h"      /* CISIS Interface hashing & binary table search */
3611#include "wt.h"                 /* //MAXNREC; typedef VECTEL; typedef LISTA */
3612#include "wtfun.h"              /* //typedef WTFUN_XWT / WTFUN_ARRAY */
3613/* global */
3614extern WTFUN_ARRAY *ciawtfp;    /* //global WTFUN_ARRAY */
3615extern char *ciahcgi;           /* //global H2000 cgi data */
3616#endif /* CIWTF */
3617
3618#if GCC
3619#define PGCC  1
3620     #include <sys/socket.h>
3621     #include <netinet/in.h>
3622     #include <netdb.h>
3623     #include <arpa/inet.h>  /* inet_ntoa */
3624#else
3625#define uint16_t unsigned short
3626//   #include <wsksock.h>
3627#endif
3628
3629/* ciupdsocy.c / ciupdsocx.c prototypes */
3630int mainfile   (int cmd, char *filnamp, int parm0, int parm1, char *buffer, int buffersize);                                         // in ciupdsocy.c
3631int mainclient (int cmd, char *protocol, char *serverhost, uint16_t port, char *message, char *buffer, int buffersize, int maxrds);  // in ciupdsocx.c
3632
3633
3634
3635/* *****************************************************
3636CISIS/C++ extern "C"
3637***************************************************** */
3638#if CICPP
3639#ifdef __cplusplus
3640}
3641#endif
3642#endif /* CICPP */
3643
3644#endif /* CISIS_H */
Note: See TracBrowser for help on using the browser.