| 1 | /* |
|---|
| 2 | * <R> |
|---|
| 3 | * cib72, b7_run(), b7_hit() |
|---|
| 4 | * basado en b6 usando algo de b4 |
|---|
| 5 | * b4 - proximidad |
|---|
| 6 | * b6 - prefix, multiples I/F, log format |
|---|
| 7 | * </R> |
|---|
| 8 | */ |
|---|
| 9 | |
|---|
| 10 | /* Alteracoes BIREME: |
|---|
| 11 | |
|---|
| 12 | 1. Arquivo temporario com lista de hits |
|---|
| 13 | |
|---|
| 14 | nao gravar arquivo com lista de hits se nome do arquivo = "null" |
|---|
| 15 | (campo MFQTHMEM=35 do registro de b7_run - parametro irec) |
|---|
| 16 | |
|---|
| 17 | ver #if CIB7TMPNULL |
|---|
| 18 | #define CIB7TMPNULL em cisis.h |
|---|
| 19 | AOT, 14/01/2002 |
|---|
| 20 | |
|---|
| 21 | 2. B7BUFFER (lista de hits) com dois tipos de lista |
|---|
| 22 | |
|---|
| 23 | grava bit string ou lista de LONGX integer com os mfn's recuperados |
|---|
| 24 | se for mais economico em termos de espaco |
|---|
| 25 | |
|---|
| 26 | ver #if CIB7HITLIST |
|---|
| 27 | #define CIB7HITLIST em cisis.h |
|---|
| 28 | AOT, 15/01/2002 |
|---|
| 29 | |
|---|
| 30 | 3. Correcao no processamento de '$' |
|---|
| 31 | |
|---|
| 32 | Rosnier deixou passar warning incorrect assign em "if( mkp[len-1]='$' )" |
|---|
| 33 | |
|---|
| 34 | ver #if BEFORE20020115 |
|---|
| 35 | AOT, 15/01/2002 |
|---|
| 36 | |
|---|
| 37 | 4. Correcao do tamanho maximo de CIWRITE |
|---|
| 38 | |
|---|
| 39 | define tamanho maximo UINT_MAX apenas se for PC 16 bits |
|---|
| 40 | |
|---|
| 41 | ver #if BEFORE20020115 |
|---|
| 42 | AOT, 15/01/2002 |
|---|
| 43 | |
|---|
| 44 | 5. Parametro btch0p |
|---|
| 45 | |
|---|
| 46 | chama fldupdat() com parametro btch0p, como cib62.c |
|---|
| 47 | |
|---|
| 48 | ver btch0p - AOT, 16/01/2002 |
|---|
| 49 | AOT, 16/01/2002 |
|---|
| 50 | |
|---|
| 51 | 6. Reprogracao de MFNSTRING na b7_hit() |
|---|
| 52 | |
|---|
| 53 | nao toca no registro do qrydb |
|---|
| 54 | |
|---|
| 55 | ver #if CIB7HITLIST |
|---|
| 56 | AOT, 28/01/2002 |
|---|
| 57 | |
|---|
| 58 | 7. Correcao "chaves de 29 caracteres" |
|---|
| 59 | |
|---|
| 60 | testa existencia de aspas antes de mover '\0' |
|---|
| 61 | |
|---|
| 62 | ver AOT/RP 03/07/2002 |
|---|
| 63 | AOT, 03/07/2002 |
|---|
| 64 | |
|---|
| 65 | 8. Formato para mais hits nas msgs: |
|---|
| 66 | 1 MACACA/SU |
|---|
| 67 | 79 MACACA$ |
|---|
| 68 | 106 Operation + |
|---|
| 69 | 106 Set #000000001 |
|---|
| 70 | Hits=106 |
|---|
| 71 | AOT, 22/12/2006 |
|---|
| 72 | |
|---|
| 73 | 9. Alteracao B72SIZE_MAX para B72B72SIZE_MAX |
|---|
| 74 | |
|---|
| 75 | ver: cib72.c:139:1: warning: "B72SIZE_MAX" redefined |
|---|
| 76 | In file included from /usr/include/netinet/in.h:23, |
|---|
| 77 | from cisis.h:3526, |
|---|
| 78 | from cib72.c:107: |
|---|
| 79 | /usr/include/stdint.h:268:1: warning: this is the location of the previous definition |
|---|
| 80 | AOT, 12/01/2007 |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | */ |
|---|
| 84 | |
|---|
| 85 | /* |
|---|
| 86 | * Alteraciones Rosnier |
|---|
| 87 | * Definir BITSTRING, MFNSTRING e CNTSTRING para !LIND. |
|---|
| 88 | * pasarlo para cisis.h o eliminar el uso en caso !LIND. |
|---|
| 89 | */ |
|---|
| 90 | |
|---|
| 91 | #if !LIND |
|---|
| 92 | #define BITSTRING (-1) |
|---|
| 93 | #define MFNSTRING 0 |
|---|
| 94 | #define CNTSTRING 1 |
|---|
| 95 | #endif |
|---|
| 96 | |
|---|
| 97 | /* |
|---|
| 98 | * Eliminar realloc. |
|---|
| 99 | * No se porque esta "reallocando" en memoria que ya esta en uso. |
|---|
| 100 | * ver #if BEFORE20020319 |
|---|
| 101 | */ |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | #include <stdio.h> |
|---|
| 105 | #include <ctype.h> |
|---|
| 106 | #include <string.h> |
|---|
| 107 | #include <time.h> |
|---|
| 108 | |
|---|
| 109 | #if CIAPI |
|---|
| 110 | #include "ciapi.h" |
|---|
| 111 | #if !TLS |
|---|
| 112 | #define ciapip cib7p->ciapip |
|---|
| 113 | #else |
|---|
| 114 | DWORD extern ciapiTlsIndex; |
|---|
| 115 | #endif |
|---|
| 116 | #else /* CIAPI */ |
|---|
| 117 | #include "cisis.h" |
|---|
| 118 | #endif /* CIAPI */ |
|---|
| 119 | |
|---|
| 120 | #if !CICPP |
|---|
| 121 | #include "cib70.h" |
|---|
| 122 | #endif /* CICPP */ |
|---|
| 123 | |
|---|
| 124 | #define MIDDLEMSG 01 |
|---|
| 125 | #define RUITRACE 0 |
|---|
| 126 | #define RUATRACE 0 |
|---|
| 127 | |
|---|
| 128 | #define HITTRACE 0 |
|---|
| 129 | #define HITTRACx 0 |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | #if BEFORE20020115 |
|---|
| 133 | #if PC |
|---|
| 134 | #define UINTIO 1 |
|---|
| 135 | #else |
|---|
| 136 | #define UINTIO 0 |
|---|
| 137 | #endif |
|---|
| 138 | #else /*BEFORE20020115 */ |
|---|
| 139 | #if PC && !DOS32BITS /* AOT, 15/01/2002 */ |
|---|
| 140 | #define UINTIO 1 |
|---|
| 141 | #else |
|---|
| 142 | #define UINTIO 0 |
|---|
| 143 | #endif |
|---|
| 144 | #endif /*BEFORE20020115 */ |
|---|
| 145 | |
|---|
| 146 | #if UINTIO |
|---|
| 147 | #define B72SIZE_MAX UINT_MAX |
|---|
| 148 | #else |
|---|
| 149 | #define B72SIZE_MAX INT_MAX |
|---|
| 150 | #endif /* UINTIO */ |
|---|
| 151 | |
|---|
| 152 | /* |
|---|
| 153 | Rosnier: falta implementar esta parte (ver comigo e com Ricardo) |
|---|
| 154 | como subcampo na tabela de prefixos (por exemplo, ^vTW^wMH) |
|---|
| 155 | de maneira a poder usar a feature em otras aplicacoes alem do |
|---|
| 156 | search em MedLine e, sobretudo, nao fazer a cagada de ir sempre |
|---|
| 157 | pesquisar numa arvore MH quando uma chave de uma arvore chamada TW |
|---|
| 158 | tem mais de uma palavra |
|---|
| 159 | AOT, 18/05/2001 |
|---|
| 160 | */ |
|---|
| 161 | #define SOING 1 /* CDMDL - text word TI and AB are I |
|---|
| 162 | text word MeSH are I/E/P |
|---|
| 163 | |
|---|
| 164 | if dbn="TW" |
|---|
| 165 | if key has multiple words |
|---|
| 166 | dbn="MH" |
|---|
| 167 | (b6tw2mh) |
|---|
| 168 | */ |
|---|
| 169 | |
|---|
| 170 | /* |
|---|
| 171 | definiciones sobre la pila de ejecuación. |
|---|
| 172 | */ |
|---|
| 173 | #define PDLlvel pdlp->pdllvel |
|---|
| 174 | #define PDLleft pdlp->pdlleft |
|---|
| 175 | #define PDLdocs pdlp->pdldocs |
|---|
| 176 | #define PDLlmfn pdlp->pdllmfn |
|---|
| 177 | #define PDLsize pdlp->pdlsize |
|---|
| 178 | #define PDLisiz pdlp->pdlisiz |
|---|
| 179 | #define PDLplen pdlp->pdlplen |
|---|
| 180 | #define PDLnxtp pdlp->pdlnxtp |
|---|
| 181 | #define VPDLlvel(i) vpdlp[i]->pdllvel |
|---|
| 182 | #define VPDLleft(i) vpdlp[i]->pdlleft |
|---|
| 183 | #define VPDLdocs(i) vpdlp[i]->pdldocs |
|---|
| 184 | #define VPDLlmfn(i) vpdlp[i]->pdllmfn |
|---|
| 185 | #define VPDLsize(i) vpdlp[i]->pdlsize |
|---|
| 186 | #define VPDLisiz(i) vpdlp[i]->pdlisiz |
|---|
| 187 | #define VPDLplen(i) vpdlp[i]->pdlplen |
|---|
| 188 | #define VPDLnxtp(i) vpdlp[i]->pdlnxtp |
|---|
| 189 | #define PDL0 vpdlp[0] |
|---|
| 190 | #define PDL0lvel PDL0->pdllvel |
|---|
| 191 | #define PDL0left PDL0->pdlleft |
|---|
| 192 | #define PDL0docs PDL0->pdldocs |
|---|
| 193 | #define PDL0lmfn PDL0->pdllmfn |
|---|
| 194 | #define PDL0size PDL0->pdlsize |
|---|
| 195 | #define PDL0isiz PDL0->pdlisiz |
|---|
| 196 | #define PDL0plen PDL0->pdlplen |
|---|
| 197 | #define PDL0nxtp PDL0->pdlnxtp |
|---|
| 198 | |
|---|
| 199 | #define vpdltop npdls-1 |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | #if CICPP |
|---|
| 203 | void CIB7::b7_runerr(int error, char *errp, int errl) |
|---|
| 204 | #else /*CICPP*/ |
|---|
| 205 | void b7_runerr(cib7p,error,errp,errl) |
|---|
| 206 | b7_CIB7 *cib7p; |
|---|
| 207 | int error; |
|---|
| 208 | char *errp; |
|---|
| 209 | int errl; |
|---|
| 210 | #endif /*CICPP*/ |
|---|
| 211 | { |
|---|
| 212 | #if ERRTRACE |
|---|
| 213 | char *p; |
|---|
| 214 | int loop; |
|---|
| 215 | #endif |
|---|
| 216 | if (b7fd) { CLOSE(b7fd); b7fd=0;} /* 06/03/95 */ |
|---|
| 217 | |
|---|
| 218 | if (errl <= 0) errl=strlen(errp); |
|---|
| 219 | if (errl > MAXERRL) errl=MAXERRL; |
|---|
| 220 | #if ERRTRACE |
|---|
| 221 | printf("b7_runerr - error=%d (",error); |
|---|
| 222 | for (p=errp,loop=errl;loop--;p++) |
|---|
| 223 | putchar(*p); |
|---|
| 224 | printf(")\n"); |
|---|
| 225 | #endif |
|---|
| 226 | memcpy(b7errxy,errp,errl); b7errxy[errl]='\0'; |
|---|
| 227 | #ifndef CICPP |
|---|
| 228 | #if !WWWISIS |
|---|
| 229 | longjmp(b71jumper,error); |
|---|
| 230 | fatal("b7_run/b7_runerr"); |
|---|
| 231 | #endif /* !WWWISIS */ |
|---|
| 232 | #endif /* CICPP */ |
|---|
| 233 | b7error = error?error:1; |
|---|
| 234 | |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | /* |
|---|
| 238 | eliminar un nivel de la pila. |
|---|
| 239 | */ |
|---|
| 240 | |
|---|
| 241 | #if CICPP |
|---|
| 242 | int CIB7::b7_free(int ipdl) |
|---|
| 243 | #else /*CICPP*/ |
|---|
| 244 | int b7_free(cib7p,ipdl) |
|---|
| 245 | b7_CIB7 *cib7p; |
|---|
| 246 | int ipdl; |
|---|
| 247 | #endif |
|---|
| 248 | { |
|---|
| 249 | PDLSTRU *pdlp; |
|---|
| 250 | pdlp = vpdlp[ipdl]; |
|---|
| 251 | |
|---|
| 252 | if( pdlp == (PDLSTRU*)ALLONULL ) |
|---|
| 253 | return 0; |
|---|
| 254 | |
|---|
| 255 | #if CICPP |
|---|
| 256 | if( PDLlvel ) |
|---|
| 257 | delete[] PDLlvel; |
|---|
| 258 | |
|---|
| 259 | delete[] pdlp; |
|---|
| 260 | #else /* CICPP */ |
|---|
| 261 | if( PDLlvel ) |
|---|
| 262 | FREE( PDLlvel ); |
|---|
| 263 | |
|---|
| 264 | FREE( pdlp ); |
|---|
| 265 | #endif /* CICPP */ |
|---|
| 266 | |
|---|
| 267 | npdls--; |
|---|
| 268 | return 0; |
|---|
| 269 | } |
|---|
| 270 | |
|---|
| 271 | /* |
|---|
| 272 | intercambia 2 niveles de la pila. |
|---|
| 273 | */ |
|---|
| 274 | |
|---|
| 275 | #if CICPP |
|---|
| 276 | int CIB7::b7_xpdl(int ipdl1, int ipdl2 ) |
|---|
| 277 | #else /*CICPP*/ |
|---|
| 278 | int b7_xpdl( cib7p,ipdl1, ipdl2 ) |
|---|
| 279 | b7_CIB7 *cib7p; |
|---|
| 280 | int ipdl1; |
|---|
| 281 | int ipdl2; |
|---|
| 282 | #endif |
|---|
| 283 | { |
|---|
| 284 | |
|---|
| 285 | PDLSTRU *tmp; |
|---|
| 286 | |
|---|
| 287 | tmp = vpdlp[ ipdl1 ]; |
|---|
| 288 | vpdlp[ ipdl1 ]=vpdlp[ ipdl2 ]; |
|---|
| 289 | vpdlp[ ipdl2 ] = tmp; |
|---|
| 290 | |
|---|
| 291 | return 1; |
|---|
| 292 | |
|---|
| 293 | } |
|---|
| 294 | |
|---|
| 295 | /* |
|---|
| 296 | Inicializa un PDLSTRU. |
|---|
| 297 | */ |
|---|
| 298 | |
|---|
| 299 | #if CICPP |
|---|
| 300 | char *CIB7::b7_initpdl(PDLSTRU *pdlp, char postlen, LONGX lastmfn) |
|---|
| 301 | #else /*CICPP*/ |
|---|
| 302 | char *b7_initpdl(cib7p,pdlp, postlen, lastmfn) |
|---|
| 303 | b7_CIB7 *cib7p; |
|---|
| 304 | PDLSTRU *pdlp; |
|---|
| 305 | char postlen; /* tamaño de los postings */ |
|---|
| 306 | LONGX lastmfn; /* último MFN de la base. */ |
|---|
| 307 | #endif /*CICPP*/ |
|---|
| 308 | { |
|---|
| 309 | |
|---|
| 310 | switch( postlen ){ |
|---|
| 311 | case '1': PDLplen=0; break; /* one bit per mfn */ |
|---|
| 312 | case '2': PDLplen=5; break; /* MFN+TAG */ |
|---|
| 313 | case '3': PDLplen=6; break; /* MFN+TAG+OCC */ |
|---|
| 314 | case '4': PDLplen=8; break; /* MFN+TAG+OCC+CNT */ |
|---|
| 315 | default : PDLplen=0; |
|---|
| 316 | } |
|---|
| 317 | |
|---|
| 318 | if( !PDLplen ) |
|---|
| 319 | PDLsize=lastmfn/8+1; /*bitstring.*/ |
|---|
| 320 | else |
|---|
| 321 | PDLsize=lastmfn*PDLplen; |
|---|
| 322 | |
|---|
| 323 | PDLisiz = PDLsize; |
|---|
| 324 | |
|---|
| 325 | #if CICPP |
|---|
| 326 | if( PDLlvel ) delete[] PDLlvel; |
|---|
| 327 | |
|---|
| 328 | try {PDLlvel= (UCHR *)new char[(ALLOPARM)PDLsize]; } |
|---|
| 329 | catch(BAD_ALLOC) { PDLlvel = (UCHR *)ALLONULL; } |
|---|
| 330 | #else /* CICPP */ |
|---|
| 331 | if( PDLlvel ) FREE(PDLlvel); |
|---|
| 332 | |
|---|
| 333 | PDLlvel= (char*)ALLOC((ALLOPARM)(PDLsize)); |
|---|
| 334 | #endif /* CICPP */ |
|---|
| 335 | if (PDLlvel == (UCHR *)ALLONULL) |
|---|
| 336 | { |
|---|
| 337 | b7_runerr(B7_THISP 3,"b7_ipdl/ALLOC/PDLlvel",0); |
|---|
| 338 | return (char *)ALLONULL; |
|---|
| 339 | } |
|---|
| 340 | memset(PDLlvel,0x00,PDLsize); |
|---|
| 341 | |
|---|
| 342 | PDLleft=PDLsize; |
|---|
| 343 | |
|---|
| 344 | PDLdocs=0; |
|---|
| 345 | PDLnxtp=(char *)PDLlvel; |
|---|
| 346 | PDLlmfn=lastmfn; |
|---|
| 347 | |
|---|
| 348 | return (char *)PDLlvel; |
|---|
| 349 | |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | /* |
|---|
| 353 | adicionar PDLSTRU a la pila en el nivel ipdl. |
|---|
| 354 | */ |
|---|
| 355 | |
|---|
| 356 | #if CICPP |
|---|
| 357 | PDLSTRU *CIB7::b7_ipdl(int ipdl) |
|---|
| 358 | #else /*CICPP*/ |
|---|
| 359 | PDLSTRU *b7_ipdl(cib7p,ipdl) |
|---|
| 360 | b7_CIB7 *cib7p; |
|---|
| 361 | int ipdl; |
|---|
| 362 | #endif /*CICPP*/ |
|---|
| 363 | { |
|---|
| 364 | PDLSTRU *pdlp; |
|---|
| 365 | if (ipdl >= npdls) { |
|---|
| 366 | if (ipdl > npdls) |
|---|
| 367 | fatal("b7_ipdl/ipdl"); |
|---|
| 368 | if (npdls >= MAXPDLS) |
|---|
| 369 | { |
|---|
| 370 | b7_runerr(B7_THISP 2,"b7_ipdl/MAXPDLS",0); |
|---|
| 371 | return 0; |
|---|
| 372 | } |
|---|
| 373 | |
|---|
| 374 | #if CICPP |
|---|
| 375 | try { pdlp=(PDLSTRU *)new char[(ALLOPARM)(sizeof(PDLSTRU))]; } |
|---|
| 376 | catch(BAD_ALLOC) { pdlp=(PDLSTRU *)NULL; } |
|---|
| 377 | #else /* CICPP */ |
|---|
| 378 | pdlp=(PDLSTRU *)ALLOC((ALLOPARM)(sizeof(PDLSTRU))); |
|---|
| 379 | #endif /* CICPP */ |
|---|
| 380 | |
|---|
| 381 | memset((char *)pdlp,0x00,sizeof(PDLSTRU)); |
|---|
| 382 | |
|---|
| 383 | if (pdlp == (PDLSTRU *)ALLONULL) |
|---|
| 384 | { |
|---|
| 385 | b7_runerr(B7_THISP 3,"b7_ipdl/ALLOC/pdlp",0); |
|---|
| 386 | return 0; |
|---|
| 387 | } |
|---|
| 388 | #if RUATRACE |
|---|
| 389 | printf("ALLOC - ipdl=%d pdlp=%p\n",ipdl,pdlp); |
|---|
| 390 | #endif |
|---|
| 391 | vpdlp[npdls++]=pdlp; |
|---|
| 392 | } |
|---|
| 393 | else |
|---|
| 394 | pdlp=vpdlp[ipdl]; |
|---|
| 395 | |
|---|
| 396 | return(pdlp); |
|---|
| 397 | } |
|---|
| 398 | |
|---|
| 399 | /* |
|---|
| 400 | guess!!! |
|---|
| 401 | */ |
|---|
| 402 | #if CICPP |
|---|
| 403 | PDLSTRU *CIB7::b7_push() |
|---|
| 404 | #else |
|---|
| 405 | PDLSTRU *b7_push(cib7p) |
|---|
| 406 | b7_CIB7 *cib7p; |
|---|
| 407 | #endif |
|---|
| 408 | { |
|---|
| 409 | return b7_ipdl( B7_THISP npdls ); |
|---|
| 410 | } |
|---|
| 411 | |
|---|
| 412 | /* |
|---|
| 413 | guess!!! |
|---|
| 414 | */ |
|---|
| 415 | #if CICPP |
|---|
| 416 | int CIB7::b7_pop() |
|---|
| 417 | #else |
|---|
| 418 | int b7_pop(cib7p) |
|---|
| 419 | b7_CIB7 *cib7p; |
|---|
| 420 | #endif |
|---|
| 421 | { |
|---|
| 422 | b7_free( B7_THISP npdls-1); |
|---|
| 423 | return 1; |
|---|
| 424 | } |
|---|
| 425 | |
|---|
| 426 | #if CICPP |
|---|
| 427 | int CIB7 :: b7_pfx(RECSTRU *recp, UWORD invxtag, char *dp, char *op, int b7re_pfx) |
|---|
| 428 | #else /* CICPP */ |
|---|
| 429 | int b7_pfx(cib7p,irec, invxtag, dp, op, b7re_pfx) |
|---|
| 430 | b7_CIB7 *cib7p; |
|---|
| 431 | LONGX irec; |
|---|
| 432 | UWORD invxtag; |
|---|
| 433 | char *dp; |
|---|
| 434 | char *op; |
|---|
| 435 | int b7re_pfx; |
|---|
| 436 | #endif /* CICPP */ |
|---|
| 437 | { |
|---|
| 438 | int found=0; |
|---|
| 439 | unsigned char *fldp,*pfxp,*dbnp,*usep,*kp,*msgp; |
|---|
| 440 | int xdir; |
|---|
| 441 | FFI pfxl,dbnl,usel,deflen,opxlen,kl,n,msgl; |
|---|
| 442 | char *tmp; |
|---|
| 443 | |
|---|
| 444 | int aspas; |
|---|
| 445 | |
|---|
| 446 | #if !CICPP |
|---|
| 447 | RECSTRU *recp; |
|---|
| 448 | recp=vrecp[irec]; |
|---|
| 449 | #endif |
|---|
| 450 | if (!recp) fatal("b7_pfx/irec"); |
|---|
| 451 | |
|---|
| 452 | #if CICPP |
|---|
| 453 | if (!recp->recmfp) fatal("b7_pfx/recmfp"); |
|---|
| 454 | #endif /* CICPP */ |
|---|
| 455 | |
|---|
| 456 | b7_pfxtwx[0]='\0'; |
|---|
| 457 | b7_pfxlen=0; |
|---|
| 458 | *b7_pfxmsg='\0'; |
|---|
| 459 | *b7_pfxdbn='\0'; |
|---|
| 460 | strcpy(b7_pfxopx,op); |
|---|
| 461 | opxlen=kl=strlen((const char *)(kp=(unsigned char *)op)); |
|---|
| 462 | deflen=strlen(dp); |
|---|
| 463 | #if INVXTRAC |
|---|
| 464 | printf("0. dbname=%s,opx=%s<== \n",b7_pfxdbn,b7_pfxopx); |
|---|
| 465 | #endif |
|---|
| 466 | #if CICPP |
|---|
| 467 | if (opxlen > 0) { |
|---|
| 468 | #else /* CICPP */ |
|---|
| 469 | if (irec && opxlen > 0) { |
|---|
| 470 | #endif /* CICPP */ |
|---|
| 471 | for (xdir=0; xdir < MFRnvf; xdir++) { |
|---|
| 472 | #if INVXTRAC |
|---|
| 473 | printf("xdir,tag: %d,%d \n",xdir,DIRtag(xdir)); |
|---|
| 474 | #endif |
|---|
| 475 | if (DIRtag(xdir) == invxtag) { |
|---|
| 476 | fldp=(unsigned char *)FIELDP(xdir); |
|---|
| 477 | pfxl=DIRlen(xdir); |
|---|
| 478 | pfxp=subfldp(fldp,'p',&pfxl); |
|---|
| 479 | pfxl=subfldn(pfxp,pfxl); |
|---|
| 480 | if (!pfxl) fatal("b7_pfx/invxtag/^p"); |
|---|
| 481 | if (pfxl == 1 && *pfxp == '*') continue; |
|---|
| 482 | dbnl=DIRlen(xdir); |
|---|
| 483 | dbnp=subfldp(fldp,'y',&dbnl); |
|---|
| 484 | dbnl=subfldn(dbnp,dbnl); |
|---|
| 485 | if (!dbnl) fatal("b7_pfx/invxtag/^y"); |
|---|
| 486 | usel=DIRlen(xdir); |
|---|
| 487 | usep=subfldp(fldp,'u',&usel); |
|---|
| 488 | usel=subfldn(usep,usel); |
|---|
| 489 | if (usel > LE2) fatal("b7_pfx/invxtag/^u"); |
|---|
| 490 | if (opxlen >= pfxl) { |
|---|
| 491 | if (strncmp(b7_pfxopx,(const char *)pfxp,pfxl) == 0) { |
|---|
| 492 | memcpy(b7_pfxdbn,dbnp,dbnl); |
|---|
| 493 | b7_pfxdbn[dbnl]='\0'; |
|---|
| 494 | if (usel) memcpy(b7_pfxopx,usep,usel); |
|---|
| 495 | |
|---|
| 496 | /* <R> */ |
|---|
| 497 | if( op[pfxl] == '"' ){ |
|---|
| 498 | aspas=1; |
|---|
| 499 | tmp = strrchr((char *)op+pfxl+1, (int)'"' ); |
|---|
| 500 | if (tmp) /* AOT/RP 03/07/2002 */ *tmp = '\0'; |
|---|
| 501 | }else{ |
|---|
| 502 | aspas=0; |
|---|
| 503 | } |
|---|
| 504 | /* </R> */ |
|---|
| 505 | strcpy(b7_pfxopx+usel,op+pfxl+aspas); |
|---|
| 506 | found=1; |
|---|
| 507 | #if INVXTRAC |
|---|
| 508 | printf("1. dbname=%s,opx=%s<== \n",b7_pfxdbn,b7_pfxopx); |
|---|
| 509 | #endif |
|---|
| 510 | break; |
|---|
| 511 | } |
|---|
| 512 | } |
|---|
| 513 | } |
|---|
| 514 | } |
|---|
| 515 | } |
|---|
| 516 | #if INVXTRAC |
|---|
| 517 | printf("1. defpfx=%s(%d),op,opx: %s,%s[%s] (%d)\n", |
|---|
| 518 | dp,deflen,op,b7_pfxopx,b7_pfxdbn,found); |
|---|
| 519 | #endif |
|---|
| 520 | #if CICPP |
|---|
| 521 | if (found == 0) { |
|---|
| 522 | #else /* CICPP */ |
|---|
| 523 | if (irec && found == 0) { |
|---|
| 524 | #endif /* CICPP */ |
|---|
| 525 | if (strlen(dp)) { |
|---|
| 526 | for (xdir=0; xdir < MFRnvf; xdir++) { |
|---|
| 527 | #if INVXTRAC |
|---|
| 528 | printf("1. xdir,tag: %d,%d \n",xdir,DIRtag(xdir)); |
|---|
| 529 | #endif |
|---|
| 530 | if (DIRtag(xdir) == invxtag) { |
|---|
| 531 | fldp=(unsigned char *)FIELDP(xdir); |
|---|
| 532 | pfxl=DIRlen(xdir); |
|---|
| 533 | pfxp=subfldp(fldp,'p',&pfxl); |
|---|
| 534 | pfxl=subfldn(pfxp,pfxl); |
|---|
| 535 | if (pfxl == 1 && *pfxp == '*') continue; |
|---|
| 536 | if (pfxl < deflen) continue; |
|---|
| 537 | n=pfxl-deflen; |
|---|
| 538 | if (strncmp((const char *)pfxp,dp,deflen) != 0) continue; |
|---|
| 539 | if (strncmp((const char *)(pfxp+deflen),(const char *)kp,n) != 0) continue; |
|---|
| 540 | dbnl=DIRlen(xdir); |
|---|
| 541 | dbnp=subfldp(fldp,'y',&dbnl); |
|---|
| 542 | dbnl=subfldn(dbnp,dbnl); |
|---|
| 543 | usel=DIRlen(xdir); |
|---|
| 544 | usep=subfldp(fldp,'u',&usel); |
|---|
| 545 | usel=subfldn(usep,usel); |
|---|
| 546 | memcpy(b7_pfxdbn,dbnp,dbnl); b7_pfxdbn[dbnl]='\0'; |
|---|
| 547 | if (usel) memcpy(b7_pfxopx,usep,usel); |
|---|
| 548 | /* <R> */ |
|---|
| 549 | if( kp[n] == '"' ){ |
|---|
| 550 | aspas=1; |
|---|
| 551 | tmp = strrchr((char *)kp+n+1, (int)'"' ); |
|---|
| 552 | if (tmp) /* AOT/RP 03/07/2002 */ *tmp = '\0'; |
|---|
| 553 | }else{ |
|---|
| 554 | aspas=0; |
|---|
| 555 | } |
|---|
| 556 | /* </R> */ |
|---|
| 557 | memcpy(b7_pfxopx+usel,kp+n+aspas,kl-n); |
|---|
| 558 | b7_pfxopx[usel+kl-n]='\0'; |
|---|
| 559 | found=2; |
|---|
| 560 | #if INVXTRAC |
|---|
| 561 | printf("2. dbname=%s,opx=%s<== \n",b7_pfxdbn,b7_pfxopx); |
|---|
| 562 | #endif |
|---|
| 563 | break; |
|---|
| 564 | } |
|---|
| 565 | } |
|---|
| 566 | if (!found) |
|---|
| 567 | { |
|---|
| 568 | b7_runerr(B7_THISP b7re_pfx,dp,0); |
|---|
| 569 | return(0); |
|---|
| 570 | /*goto B7_RUNERROR;*/ |
|---|
| 571 | } |
|---|
| 572 | } |
|---|
| 573 | } |
|---|
| 574 | #if INVXTRAC |
|---|
| 575 | printf("2. defpfx=%s(%d),op,opx: %s,%s[%s] (%d)\n", |
|---|
| 576 | dp,deflen,op,opx,b7_pfxdbn,found); |
|---|
| 577 | #endif |
|---|
| 578 | #if !CICPP |
|---|
| 579 | if (irec) { |
|---|
| 580 | #endif /* !CICPP */ |
|---|
| 581 | if (found == 0) { |
|---|
| 582 | for (xdir=0; xdir < MFRnvf; xdir++) { |
|---|
| 583 | #if INVXTRAC |
|---|
| 584 | printf("2. xdir,tag: %d,%d \n",xdir,DIRtag(xdir)); |
|---|
| 585 | #endif |
|---|
| 586 | if (DIRtag(xdir) == invxtag) { |
|---|
| 587 | fldp=(unsigned char *)FIELDP(xdir); |
|---|
| 588 | pfxl=DIRlen(xdir); |
|---|
| 589 | pfxp=subfldp(fldp,'p',&pfxl); |
|---|
| 590 | pfxl=subfldn(pfxp,pfxl); |
|---|
| 591 | if (pfxl != 1) continue; |
|---|
| 592 | if (*pfxp != '*') continue; |
|---|
| 593 | dbnl=DIRlen(xdir); |
|---|
| 594 | dbnp=subfldp(fldp,'y',&dbnl); |
|---|
| 595 | dbnl=subfldn(dbnp,dbnl); |
|---|
| 596 | usel=DIRlen(xdir); |
|---|
| 597 | usep=subfldp(fldp,'u',&usel); |
|---|
| 598 | usel=subfldn(usep,usel); |
|---|
| 599 | memcpy(b7_pfxdbn,dbnp,dbnl); |
|---|
| 600 | b7_pfxdbn[dbnl]='\0'; |
|---|
| 601 | if (usel) memcpy(b7_pfxopx,usep,usel); |
|---|
| 602 | /* <R> */ |
|---|
| 603 | if( op[0] == '"' ){ |
|---|
| 604 | aspas=1; |
|---|
| 605 | tmp = strrchr((char *)op+1, (int)'"' ); |
|---|
| 606 | if (tmp) /* AOT/RP 03/07/2002 */ *tmp = '\0'; |
|---|
| 607 | }else{ |
|---|
| 608 | aspas=0; |
|---|
| 609 | } |
|---|
| 610 | /* </R> */ |
|---|
| 611 | |
|---|
| 612 | strcpy(b7_pfxopx+usel,op+aspas); |
|---|
| 613 | found=3; |
|---|
| 614 | #if INVXTRAC |
|---|
| 615 | printf("3. dbname=%s,opx=%s<== \n",b7_pfxdbn,b7_pfxopx); |
|---|
| 616 | #endif |
|---|
| 617 | break; |
|---|
| 618 | } |
|---|
| 619 | } |
|---|
| 620 | } |
|---|
| 621 | #if !CICPP |
|---|
| 622 | } |
|---|
| 623 | #endif /* !CICPP */ |
|---|
| 624 | if (found) { |
|---|
| 625 | b7_pfxlen=usel; |
|---|
| 626 | msgl=DIRlen(xdir); |
|---|
| 627 | msgp=subfldp((unsigned char *)FIELDP(xdir),'m',&msgl); |
|---|
| 628 | msgl=subfldn(msgp,msgl); |
|---|
| 629 | if (msgl >= sizeof(b7_pfxmsg)) fatal("b7_pfx/invxtag/^m"); |
|---|
| 630 | memcpy(b7_pfxmsg,msgp,msgl); b7_pfxmsg[msgl]='\0'; |
|---|
| 631 | msgl=DIRlen(xdir); |
|---|
| 632 | msgp=subfldp((unsigned char *)FIELDP(xdir),'w',&msgl); |
|---|
| 633 | msgl=subfldn(msgp,msgl); |
|---|
| 634 | if (msgl >= sizeof(b7_pfxtwx)) fatal("b7_pfx/invxtag/^w"); |
|---|
| 635 | memcpy(b7_pfxtwx,msgp,msgl); b7_pfxtwx[msgl]='\0'; |
|---|
| 636 | msgl=DIRlen(xdir); |
|---|
| 637 | msgp=subfldp((unsigned char *)FIELDP(xdir),'x',&msgl); |
|---|
| 638 | b7_pfxmdl = (msgp) ? 1 : 0; |
|---|
| 639 | } |
|---|
| 640 | #if INVXTRAx |
|---|
| 641 | printf("3. defpfx=%s(%d),op,opx: %s,%s[%s] (%d)\n", |
|---|
| 642 | dp,deflen,op,b7_pfxopx,b7_pfxdbn,found); |
|---|
| 643 | #endif |
|---|
| 644 | |
|---|
| 645 | /* 27.Feb.2003 RP - begin */ |
|---|
| 646 | if ( aspas ) |
|---|
| 647 | { |
|---|
| 648 | char *auxString = strdup(b7_pfxopx); |
|---|
| 649 | |
|---|
| 650 | sprintf(b7_pfxopx,"\"%s\"",auxString); |
|---|
| 651 | #if CICPP |
|---|
| 652 | free(auxString); |
|---|
| 653 | #else /* CICPP */ |
|---|
| 654 | FREE(auxString); |
|---|
| 655 | #endif /* CICPP */ |
|---|
| 656 | } |
|---|
| 657 | /* 27.Feb.2003 RP - end */ |
|---|
| 658 | |
|---|
| 659 | return(found); |
|---|
| 660 | } |
|---|
| 661 | |
|---|
| 662 | |
|---|
| 663 | /* |
|---|
| 664 | b7_run() |
|---|
| 665 | ejecuta la búsqueda :-) |
|---|
| 666 | */ |
|---|
| 667 | #if CICPP |
|---|
| 668 | char *CIB7::b7_run(RECSTRU *irecp, char *dbnamp, |
|---|
| 669 | char *buffup, int buffuplen, LONGX tell, |
|---|
| 670 | unsigned char uctab[], char *btch0p, RECSTRU *tlirecp, |
|---|
| 671 | RECSTRU *crecp, int *errnop) |
|---|
| 672 | #else /* CICPP */ |
|---|
| 673 | char *b7_run(cib7p,irec,dbnamp,buffup,buffuplen,tell,uctab, |
|---|
| 674 | btch0p,tlirec,crec,errnop) /* |
|---|
| 675 | |
|---|
| 676 | ------------ |
|---|
| 677 | executa query em dbnamp; |
|---|
| 678 | retorna NULL ou ptr erro |
|---|
| 679 | */ |
|---|
| 680 | b7_CIB7 *cib7p; |
|---|
| 681 | LONGX irec; /* recp, para store */ |
|---|
| 682 | char *dbnamp; /* ptr nome base de dados a ler */ |
|---|
| 683 | char *buffup; /* area addr for fldupdat */ |
|---|
| 684 | int buffuplen; /* buffup length */ |
|---|
| 685 | LONGX tell; /* b7_msg call */ |
|---|
| 686 | unsigned char uctab[]; /* uctab */ |
|---|
| 687 | char *btch0p; /* initial fldupdat */ |
|---|
| 688 | LONGX tlirec; /* invx definition */ |
|---|
| 689 | LONGX crec; /* registro de controle de qrydbnp */ |
|---|
| 690 | int *errnop; /* addr para codigo de erro */ |
|---|
| 691 | #endif /* CICPP */ |
|---|
| 692 | { |
|---|
| 693 | RECSTRU *recp; |
|---|
| 694 | TRMSTRU *trmp; |
|---|
| 695 | PDLSTRU *pdlp; /* pilha de execucao */ |
|---|
| 696 | |
|---|
| 697 | unsigned char *b7p; |
|---|
| 698 | |
|---|
| 699 | unsigned char *q, *p, *op1, *res, *batchp, *p0p, *mtp, *mkp; |
|---|
| 700 | |
|---|
| 701 | char postlen; |
|---|
| 702 | |
|---|
| 703 | int b7opxlen; |
|---|
| 704 | |
|---|
| 705 | /* <R> |
|---|
| 706 | Pasadas a b7_CIB7. |
|---|
| 707 | short unsigned int nqualts,vqualt[MAXQUAL],*qualtp; |
|---|
| 708 | </R> |
|---|
| 709 | */ |
|---|
| 710 | |
|---|
| 711 | int b7rootf; |
|---|
| 712 | LONGX b7rootloop; |
|---|
| 713 | |
|---|
| 714 | unsigned char b7opr; |
|---|
| 715 | unsigned char b7qty; |
|---|
| 716 | unsigned char b7pst; |
|---|
| 717 | unsigned char b7acc; |
|---|
| 718 | unsigned char b7opx[2+LE2+1]; |
|---|
| 719 | LONGX lastmfn; |
|---|
| 720 | LONGX offset, loop; |
|---|
| 721 | |
|---|
| 722 | int xdir_obj0,xdir_dbn0; |
|---|
| 723 | |
|---|
| 724 | int xdir_hmem; |
|---|
| 725 | int xdir_xcts,n; |
|---|
| 726 | FFI nffi; |
|---|
| 727 | |
|---|
| 728 | LONGX nord,mfn,left; |
|---|
| 729 | LONGX hits,hsiz,lastcc,bytes; |
|---|
| 730 | |
|---|
| 731 | time_t wtime; |
|---|
| 732 | |
|---|
| 733 | int b7fd1; |
|---|
| 734 | |
|---|
| 735 | LONGX npdlsb; |
|---|
| 736 | |
|---|
| 737 | char buffup1[1024]; |
|---|
| 738 | |
|---|
| 739 | #if INVXBOOL |
|---|
| 740 | unsigned char /*tl_dbname[CIMPL+1],*/tl_opx[LE2+LE2+1]; |
|---|
| 741 | #endif |
|---|
| 742 | |
|---|
| 743 | int tl_deflen; |
|---|
| 744 | unsigned char tl_defpfx[LE2+1]; |
|---|
| 745 | |
|---|
| 746 | DBXSTRU *dbxp; |
|---|
| 747 | |
|---|
| 748 | #if MIDDLEMSG |
|---|
| 749 | LONGX count; |
|---|
| 750 | #endif |
|---|
| 751 | |
|---|
| 752 | #if CDMDL |
|---|
| 753 | int dctlen,qlflen; |
|---|
| 754 | #endif |
|---|
| 755 | |
|---|
| 756 | //#if CIB7HITLIST /* AOT, 15/01/2002 */ |
|---|
| 757 | // LONGX bytsneed=LONGX_MAX; |
|---|
| 758 | // int hcase=BITSTRING; |
|---|
| 759 | //#endif |
|---|
| 760 | |
|---|
| 761 | #if !CICPP |
|---|
| 762 | RECSTRU *tlirecp; |
|---|
| 763 | #endif /* CICPP */ |
|---|
| 764 | |
|---|
| 765 | *errnop=0; |
|---|
| 766 | |
|---|
| 767 | if (!ndbxs) dbxinit(); /* init vdbxp/vrecp/vtrmp if not yet init - AOT, 28/10/2005 */ |
|---|
| 768 | |
|---|
| 769 | tl_defpfx[0] = '\0'; |
|---|
| 770 | nqualts=0; |
|---|
| 771 | |
|---|
| 772 | #if CICPP |
|---|
| 773 | recp = irecp; |
|---|
| 774 | #else /* CICPP */ |
|---|
| 775 | recp=vrecp[irec]; |
|---|
| 776 | #endif /* CICPP */ |
|---|
| 777 | if (!recp) |
|---|
| 778 | fatal("b7_run/irec"); |
|---|
| 779 | |
|---|
| 780 | #if !CICPP |
|---|
| 781 | tlirecp=vrecp[tlirec]; |
|---|
| 782 | #endif /* CICPP */ |
|---|
| 783 | if (!tlirecp) |
|---|
| 784 | fatal("b7_run/tlirec"); |
|---|
| 785 | |
|---|
| 786 | npdls=0; |
|---|
| 787 | b7itrm=0; |
|---|
| 788 | lastcc=0; |
|---|
| 789 | |
|---|
| 790 | #if CICPP |
|---|
| 791 | trmp = new TRMSTRU(cisisxp); |
|---|
| 792 | trmp->xtrmalloc(IFBSIZ); |
|---|
| 793 | #else /* CICPP */ |
|---|
| 794 | for (b7itrm=maxntrm; --b7itrm > 0; ) |
|---|
| 795 | if (!vtrmp[b7itrm]) { |
|---|
| 796 | trmalloc(b7itrm,IFBSIZ); |
|---|
| 797 | break; |
|---|
| 798 | } |
|---|
| 799 | if (b7itrm == 0) |
|---|
| 800 | b7_runerr(B7_THISP 8,"b7_run/itrm",0); |
|---|
| 801 | #endif /* CICPP */ |
|---|
| 802 | |
|---|
| 803 | B7_RUNERROR: |
|---|
| 804 | if (b7error != 0) { |
|---|
| 805 | #if ERRTRACE |
|---|
| 806 | printf("setjmp - error=%d (%s)\n",b7error,b7errxy); |
|---|
| 807 | #endif |
|---|
| 808 | sprintf(buffup,B7DELADD,MFQTALCC,MFQTALCC,(LONGX)b7error); |
|---|
| 809 | #if CICPP |
|---|
| 810 | recp->xfldupdat(buffup); /* try it */ |
|---|
| 811 | #else /* CICPP */ |
|---|
| 812 | fldupdat(irec,buffup); /* try it */ |
|---|
| 813 | #endif /* CICPP */ |
|---|
| 814 | |
|---|
| 815 | if (RECdbxp) { |
|---|
| 816 | RECtype=TYPEMFR; |
|---|
| 817 | |
|---|
| 818 | #if CICPP |
|---|
| 819 | recp->xrecupdat(); /* put it on disk */ |
|---|
| 820 | #else /* CICPP */ |
|---|
| 821 | recupdat(crec,irec); /* put it on disk */ |
|---|
| 822 | #endif /* CICPP */ |
|---|
| 823 | |
|---|
| 824 | RECtype=TYPEMFQ; |
|---|
| 825 | } |
|---|
| 826 | if (b7error == 222) { |
|---|
| 827 | b7error=0; |
|---|
| 828 | } |
|---|
| 829 | |
|---|
| 830 | *errnop=b7error; |
|---|
| 831 | |
|---|
| 832 | return(b7errxy); |
|---|
| 833 | } |
|---|
| 834 | |
|---|
| 835 | |
|---|
| 836 | #if CICPP |
|---|
| 837 | recp = irecp; |
|---|
| 838 | #else /* CICPP */ |
|---|
| 839 | recp = vrecp[irec]; |
|---|
| 840 | #endif /* CICPP */ |
|---|
| 841 | b7tell = tell; |
|---|
| 842 | b7setno=MFRmfn; |
|---|
| 843 | |
|---|
| 844 | /* setup MFQTXCTS and MFQTAxxx and MFQTHxxx */ |
|---|
| 845 | RECtype=TYPEMFR; |
|---|
| 846 | batchp=(unsigned char *)buffup; |
|---|
| 847 | sprintf((char *)batchp,"A%d|^%c%"_LD_,MFQTXCTS,MFQSWTIM,time(&wtime)); |
|---|
| 848 | batchp+=strlen((const char *)batchp); |
|---|
| 849 | |
|---|
| 850 | #if CICPP |
|---|
| 851 | if ((xdir_dbn0=recp->xfieldx(MFQTDBN0,1)) < 0){ |
|---|
| 852 | #else /* CICPP */ |
|---|
| 853 | if ((xdir_dbn0=fieldx(irec,MFQTDBN0,1)) < 0){ |
|---|
| 854 | #endif /* CICPP */ |
|---|
| 855 | b7_runerr(B7_THISP B7RE_1,"b7_run/xdir_dbn0",0); |
|---|
| 856 | goto B7_RUNERROR; |
|---|
| 857 | } |
|---|
| 858 | |
|---|
| 859 | if (strlen(dbnamp) != DIRlen(xdir_dbn0) || strncmp(dbnamp,FIELDP(xdir_dbn0),DIRlen(xdir_dbn0))) { |
|---|
| 860 | sprintf((char *)batchp,"^%c%s",MFQSWDBN,dbnamp); |
|---|
| 861 | batchp+=strlen((const char *)batchp); |
|---|
| 862 | } |
|---|
| 863 | |
|---|
| 864 | sprintf((char *)batchp,"^%c",MFQSWQTY); |
|---|
| 865 | batchp+=strlen((const char *)batchp); |
|---|
| 866 | sprintf((char *)batchp,B7EDIT1,0L); |
|---|
| 867 | batchp+=strlen((const char *)batchp); |
|---|
| 868 | *batchp++ = '|'; |
|---|
| 869 | sprintf((char *)batchp,B7DELADD,MFQTASET,MFQTASET,0L); |
|---|
| 870 | batchp+=strlen((const char *)batchp); |
|---|
| 871 | sprintf((char *)batchp,B7DELADD,MFQTALCC,MFQTALCC,lastcc); |
|---|
| 872 | batchp+=strlen((const char *)batchp); |
|---|
| 873 | sprintf((char *)batchp,B7DELADD,MFQTHITS,MFQTHITS,0L); |
|---|
| 874 | batchp+=strlen((const char *)batchp); |
|---|
| 875 | sprintf((char *)batchp,B7DELADD,MFQTHCUR,MFQTHCUR,0L); |
|---|
| 876 | batchp+=strlen((const char *)batchp); |
|---|
| 877 | sprintf((char *)batchp,B7DELADD,MFQTHMFN,MFQTHMFN,0L); |
|---|
| 878 | batchp+=strlen((const char *)batchp); |
|---|
| 879 | sprintf((char *)batchp,B7DELADD,MFQTHSIZ,MFQTHSIZ,0L); |
|---|
| 880 | /* batchp+=strlen((const char *)batchp); */ |
|---|
| 881 | |
|---|
| 882 | #if CICPP |
|---|
| 883 | if ((p=(unsigned char *)recp->xfldupdat(buffup)) != NULL) |
|---|
| 884 | b7_runerr(B7_THISP B7RE_2,(char *)p,0); |
|---|
| 885 | if (btch0p) |
|---|
| 886 | if ((p=(unsigned char *)recp->xfldupdat(btch0p)) != NULL) /* btch0p - AOT, 16/01/2002 */ |
|---|
| 887 | b7_runerr(B7_THISP B7RE_2,(char *)p,0); |
|---|
| 888 | |
|---|
| 889 | if ((xdir_hmem=recp->xfieldx(MFQTHMEM,1)) < 0) { |
|---|
| 890 | if (!RECdbxp) |
|---|
| 891 | fatal("b7_run/RECdbxp"); |
|---|
| 892 | sprintf(buffup,"A%d|%s.%03x|",MFQTHMEM,RDBname,(int)b7setno); |
|---|
| 893 | if ((p=(unsigned char *)recp->xfldupdat(buffup)) != NULL) |
|---|
| 894 | b7_runerr(B7_THISP B7RE_2,(char *)p,0); |
|---|
| 895 | sprintf(buffup,"%s.%03x",RDBname,(int)b7setno); |
|---|
| 896 | #else /* CICPP */ |
|---|
| 897 | if ((p=fldupdat(irec,buffup)) != NULL) |
|---|
| 898 | b7_runerr(B7_THISP B7RE_2,(char *)p,0); |
|---|
| 899 | if (btch0p) |
|---|
| 900 | if ((p=fldupdat(irec,btch0p)) != NULL) /* btch0p - AOT, 16/01/2002 */ |
|---|
| 901 | b7_runerr(B7_THISP B7RE_2,(char *)p,0); |
|---|
| 902 | |
|---|
| 903 | if ((xdir_hmem=fieldx(irec,MFQTHMEM,1)) < 0) { |
|---|
| 904 | if (!RECdbxp) |
|---|
| 905 | fatal("b7_run/RECdbxp"); |
|---|
| 906 | sprintf(buffup,"A%d|%s.%03x|",MFQTHMEM,RDBname,(int)b7setno); |
|---|
| 907 | if ((p=fldupdat(irec,buffup)) != NULL) |
|---|
| 908 | b7_runerr(B7_THISP B7RE_2,(char *)p,0); |
|---|
| 909 | sprintf(buffup,"%s.%03x",RDBname,(int)b7setno); /* build file name for results in buffup */ |
|---|
| 910 | #endif /* CICPP */ |
|---|
| 911 | }else { |
|---|
| 912 | memcpy(buffup,FIELDP(xdir_hmem),DIRlen(xdir_hmem)); /* or get it from irec into buffup */ |
|---|
| 913 | buffup[DIRlen(xdir_hmem)]='\0'; |
|---|
| 914 | } |
|---|
| 915 | |
|---|
| 916 | |
|---|
| 917 | #if CIB7TMPNULL |
|---|
| 918 | if (strcmp(buffup,"null")) { /* do not write hits (bit string) to disk |
|---|
| 919 | note: b7_run() alloc b7buffer if needed and |
|---|
| 920 | stores hits in b7buffer at end of execution |
|---|
| 921 | therefore, b7buffer still can be used by b7_hit() |
|---|
| 922 | (or used directly by the caller..) |
|---|
| 923 | AOT - 14/01/2002 |
|---|
| 924 | */ |
|---|
| 925 | #endif /* CIB7TMPNULL */ |
|---|
| 926 | |
|---|
| 927 | b7fd=CREAT(dbxcipar(b7_gidbnp,buffup,'='),PERMIS); |
|---|
| 928 | if (b7fd > 0) |
|---|
| 929 | CLOSE(b7fd); |
|---|
| 930 | |
|---|
| 931 | n=dbxopt_ordwr; dbxopt_ordwr=O_RDWR; |
|---|
| 932 | b7fd=dbxopen(b7_gidbnp,buffup,""); |
|---|
| 933 | dbxopt_ordwr=n; |
|---|
| 934 | |
|---|
| 935 | #if CIB7TMPNULL |
|---|
| 936 | } /* AOT - 14/01/2002 */ |
|---|
| 937 | #endif /* CIB7TMPNULL */ |
|---|
| 938 | |
|---|
| 939 | |
|---|
| 940 | #if CICPP |
|---|
| 941 | if ((xdir_obj0=recp->xfieldx(MFQTOBJ0,1)) < 0){ |
|---|
| 942 | #else /* CICPP */ |
|---|
| 943 | if ((xdir_obj0=fieldx(irec,MFQTOBJ0,1)) < 0){ |
|---|
| 944 | #endif /* CICPP */ |
|---|
| 945 | b7_runerr(B7_THISP B7RE_3,"b7_run/xdir_obj0",0); |
|---|
| 946 | goto B7_RUNERROR; |
|---|
| 947 | } |
|---|
| 948 | |
|---|
| 949 | dbxp = dbxstorp(dbnamp); |
|---|
| 950 | lastmfn = DBXmsmfn; |
|---|
| 951 | |
|---|
| 952 | #if CICPP |
|---|
| 953 | if ((xdir_obj0=recp->xfieldx(MFQTOBJ0,1)) < 0) |
|---|
| 954 | #else /* CICPP */ |
|---|
| 955 | if ((xdir_obj0=fieldx(irec,MFQTOBJ0,1)) < 0) |
|---|
| 956 | #endif /* CICPP */ |
|---|
| 957 | fatal("b7_run/fieldx"); |
|---|
| 958 | |
|---|
| 959 | b7p=(unsigned char *)FIELDP(xdir_obj0); |
|---|
| 960 | |
|---|
| 961 | while (*b7p != OPRXEND) { |
|---|
| 962 | #if RUITRACE |
|---|
| 963 | b7_showpdl( B7_THIS ); |
|---|
| 964 | #endif |
|---|
| 965 | b7opr = *b7p++; |
|---|
| 966 | postlen = *b7p; |
|---|
| 967 | switch (b7opr) { |
|---|
| 968 | case ZQUA: |
|---|
| 969 | for (nqualts=0; *b7p; ) { |
|---|
| 970 | if (*b7p == OPRNULL) |
|---|
| 971 | break; |
|---|
| 972 | for( ;isspace(*b7p); b7p++) ; |
|---|
| 973 | for (n=0; isdigit(*b7p); b7p++) /* convert tag */ |
|---|
| 974 | n = 10 * n + (*b7p - '0'); |
|---|
| 975 | if (nqualts >= MAXQUAL) |
|---|
| 976 | fatal("b7_run/MAXQUAL"); |
|---|
| 977 | vqualt[nqualts++]=n; |
|---|
| 978 | if (*b7p == ',') |
|---|
| 979 | b7p++; |
|---|
| 980 | } |
|---|
| 981 | vqualt[nqualts]=0; /* end */ |
|---|
| 982 | b7pst = '0'; |
|---|
| 983 | b7qty = '0'; |
|---|
| 984 | b7acc = '0'; |
|---|
| 985 | break; |
|---|
| 986 | case ZPFX: |
|---|
| 987 | for (tl_deflen=0; *b7p != OPRNULL; ) |
|---|
| 988 | tl_defpfx[tl_deflen++] = uctab[*b7p++]; |
|---|
| 989 | if (tl_deflen) |
|---|
| 990 | if (isalpha(tl_defpfx[tl_deflen-1])) |
|---|
| 991 | tl_defpfx[tl_deflen++] = ' '; |
|---|
| 992 | tl_defpfx[tl_deflen]='\0'; |
|---|
| 993 | b7pst = '0'; |
|---|
| 994 | b7qty = '0'; |
|---|
| 995 | b7acc = '0'; |
|---|
| 996 | break; |
|---|
| 997 | |
|---|
| 998 | case ZLDV: |
|---|
| 999 | b7pst = *b7p++; |
|---|
| 1000 | b7qty = '0'; |
|---|
| 1001 | b7acc = '0'; |
|---|
| 1002 | break; |
|---|
| 1003 | default: |
|---|
| 1004 | b7pst = '0'; |
|---|
| 1005 | b7qty = *b7p++; |
|---|
| 1006 | b7acc = *b7p++; |
|---|
| 1007 | } |
|---|
| 1008 | |
|---|
| 1009 | |
|---|
| 1010 | q=(unsigned char *)buffup; /* buffup is available */ |
|---|
| 1011 | for (b7opxlen=0; *b7p; ) { |
|---|
| 1012 | if (*b7p == OPRNULL) |
|---|
| 1013 | break; |
|---|
| 1014 | *q++ = *b7p++; |
|---|
| 1015 | b7opxlen++; |
|---|
| 1016 | } |
|---|
| 1017 | *q='\0'; |
|---|
| 1018 | b7rootf=OFF; |
|---|
| 1019 | b7rootloop=0; |
|---|
| 1020 | *b7opx='\0'; |
|---|
| 1021 | |
|---|
| 1022 | if (b7opxlen) { |
|---|
| 1023 | if (buffup[strlen(buffup)-1] == '$') { |
|---|
| 1024 | b7rootf=ON; |
|---|
| 1025 | b7opxlen--; |
|---|
| 1026 | } |
|---|
| 1027 | if (b7_xlkey(B7_THISP (char *)b7opx,buffup,uctab,NULL,&b7opxlen) == NULL) |
|---|
| 1028 | b7_runerr(B7_THISP 10,"b7_xlkey",0); |
|---|
| 1029 | } |
|---|
| 1030 | |
|---|
| 1031 | if (*b7p != OPRNULL) |
|---|
| 1032 | fatal("b7_run/OPRNULL"); |
|---|
| 1033 | b7p++; |
|---|
| 1034 | |
|---|
| 1035 | switch (b7opr) { |
|---|
| 1036 | case ZQUA: |
|---|
| 1037 | #if RUXTRACE |
|---|
| 1038 | if (b70trace) { |
|---|
| 1039 | printf("->"); |
|---|
| 1040 | for (qualtp=vqualt; *qualtp; qualtp++) |
|---|
| 1041 | printf("%d,",*qualtp); |
|---|
| 1042 | printf("nq=%d\n",nqualts); |
|---|
| 1043 | } |
|---|
| 1044 | #endif |
|---|
| 1045 | break; |
|---|
| 1046 | case ZPFX: |
|---|
| 1047 | #if RUXTRACE |
|---|
| 1048 | if (b70trace) { |
|---|
| 1049 | printf("->"); |
|---|
| 1050 | } |
|---|
| 1051 | #endif |
|---|
| 1052 | break; |
|---|
| 1053 | |
|---|
| 1054 | /* |
|---|
| 1055 | <R> |
|---|
| 1056 | Aca empiezan los cambios :-) |
|---|
| 1057 | </R> |
|---|
| 1058 | */ |
|---|
| 1059 | case ZLDV: |
|---|
| 1060 | /* oper _ */ |
|---|
| 1061 | |
|---|
| 1062 | npdlsb = npdls; |
|---|
| 1063 | |
|---|
| 1064 | /*Cargar resultado de búsqueda anterior almacenado en HD */ |
|---|
| 1065 | if (RECdbxp && *b7opx == '#' && b7opxlen > 1) { |
|---|
| 1066 | mfn=atol((const char *)b7opx+1); |
|---|
| 1067 | for (p=b7opx+1; *p; p++) |
|---|
| 1068 | if (!isdigit(*p)) { |
|---|
| 1069 | mfn= -1; |
|---|
| 1070 | break; |
|---|
| 1071 | } |
|---|
| 1072 | if( mfn<0 ) |
|---|
| 1073 | break; |
|---|
| 1074 | |
|---|
| 1075 | pdlp=b7_push(B7_THIS); |
|---|
| 1076 | b7_initpdl(B7_THISP pdlp, 0, lastmfn); |
|---|
| 1077 | |
|---|
| 1078 | if( mfn == 0 ){ /* Marcar todos los registros ... */ |
|---|
| 1079 | /* 1er bit=0 */ |
|---|
| 1080 | *PDLlvel=0x7F; |
|---|
| 1081 | /* resto de los bits a 1 */ |
|---|
| 1082 | memset( PDLlvel+1, 0xFF, PDLsize-1); |
|---|
| 1083 | /* 0s a partir de lmfn */ |
|---|
| 1084 | p0p=PDLlvel+PDLsize-1; /*last byte. */ |
|---|
| 1085 | for( mfn=PDLsize*8-1;mfn>PDLlmfn;mfn--) |
|---|
| 1086 | *p0p &= ~bitmask[mfn&BY8RMASK]; |
|---|
| 1087 | }else{ |
|---|
| 1088 | |
|---|
| 1089 | /* should be read from qrydbnp, field MFQTHMEM - AOT, 28/01/2002 */ |
|---|
| 1090 | sprintf(buffup1,"%s.%03x",RDBname,(int)mfn); |
|---|
| 1091 | b7fd1=dbxopen(b7_gidbnp,buffup1,""); /* result log */ |
|---|
| 1092 | |
|---|
| 1093 | if( ( CIREAD( b7fd1, PDLlvel, PDLsize ) )!= PDLsize ) |
|---|
| 1094 | break; |
|---|
| 1095 | |
|---|
| 1096 | if (b7fd1 > 0) CLOSE(b7fd1); |
|---|
| 1097 | |
|---|
| 1098 | } |
|---|
| 1099 | PDLdocs = b7_hsizh( B7_THISP pdlp, &hsiz ); |
|---|
| 1100 | }else{ |
|---|
| 1101 | |
|---|
| 1102 | #if CICPP |
|---|
| 1103 | int AuxError = b7_pfx(tlirecp,MFQTXTAG,(char *)tl_defpfx,(char *)b7opx,B7RE_PFX); |
|---|
| 1104 | if (b7error) goto B7_RUNERROR; |
|---|
| 1105 | if (AuxError) { |
|---|
| 1106 | #else /* CICPP */ |
|---|
| 1107 | if (b7_pfx(B7_THISP tlirec,MFQTXTAG,(char *)tl_defpfx,(char *)b7opx,B7RE_PFX)) { |
|---|
| 1108 | #endif /* CICPP */ |
|---|
| 1109 | mtp = (unsigned char *)b7_pfxdbn; |
|---|
| 1110 | mkp = (unsigned char *)b7_pfxopx; |
|---|
| 1111 | #if CDMDL |
|---|
| 1112 | /* MDL Medical Subject Heading is [.]mesh[/[xx]] */ |
|---|
| 1113 | if (b7_pfxmdl && b7opxlen > LE2) { |
|---|
| 1114 | dctlen=LE2-1-3; |
|---|
| 1115 | if (tl_opx[0] == '.') dctlen++; |
|---|
| 1116 | qlflen=0; |
|---|
| 1117 | if (tl_opx[b7opxlen-1] == '/') qlflen=1; |
|---|
| 1118 | if (tl_opx[b7opxlen-3] == '/') qlflen=3; |
|---|
| 1119 | memcpy(buffup,tl_opx,dctlen); |
|---|
| 1120 | memcpy(buffup+dctlen,tl_opx+b7opxlen-qlflen,qlflen); |
|---|
| 1121 | b7opxlen=dctlen+qlflen; |
|---|
| 1122 | memcpy(tl_opx,buffup,b7opxlen); |
|---|
| 1123 | tl_opx[b7opxlen]='\0'; |
|---|
| 1124 | } |
|---|
| 1125 | #endif |
|---|
| 1126 | }else{ |
|---|
| 1127 | mtp = (unsigned char *)dbnamp; |
|---|
| 1128 | mkp = (unsigned char *)b7opx; |
|---|
| 1129 | } |
|---|
| 1130 | |
|---|
| 1131 | if( (mkp[0] == '"') && (mkp[strlen((const char *)mkp)-1] == '"' ) ){ |
|---|
| 1132 | int len; |
|---|
| 1133 | mkp++; |
|---|
| 1134 | len = strlen((const char *)mkp)-1; |
|---|
| 1135 | #if BEFORE20020115 /* BC5: Possibly incorrect assignment... */ |
|---|
| 1136 | if( mkp[len-1]='$' ){ |
|---|
| 1137 | #else |
|---|
| 1138 | if( mkp[len-1]=='$' ){ /* AOT 15/01/2002 */ |
|---|
| 1139 | #endif |
|---|
| 1140 | mkp[len-1] = '\0'; |
|---|
| 1141 | b7rootf=ON; |
|---|
| 1142 | }else{ |
|---|
| 1143 | mkp[len] = '\0'; |
|---|
| 1144 | } |
|---|
| 1145 | } |
|---|
| 1146 | |
|---|
| 1147 | #if CDMDL /* D-Day */ |
|---|
| 1148 | #if SOING /* if ^y == TW and key has multiple words then search on MH */ |
|---|
| 1149 | if (b7tw2mh) { |
|---|
| 1150 | if (strcmp(mtp,"TW") == 0) { /* tree */ |
|---|
| 1151 | for (n=0, p=mkp; *p; p++) /* key */ |
|---|
| 1152 | if (!isiswctab[*p]) { n++; break; } |
|---|
| 1153 | if (n) mtp="MH"; |
|---|
| 1154 | } |
|---|
| 1155 | } |
|---|
| 1156 | #endif /* SOING */ |
|---|
| 1157 | #endif /* CDMDL */ |
|---|
| 1158 | |
|---|
| 1159 | #if CICPP |
|---|
| 1160 | trmp->xterm(mtp,mkp); |
|---|
| 1161 | #else /* CICPP */ |
|---|
| 1162 | TERM( b7itrm, mtp,mkp); |
|---|
| 1163 | #endif /* CICPP */ |
|---|
| 1164 | |
|---|
| 1165 | pdlp=b7_push(B7_THIS); |
|---|
| 1166 | b7_initpdl(B7_THISP pdlp, postlen, lastmfn); |
|---|
| 1167 | |
|---|
| 1168 | hits=0; hsiz=0; |
|---|
| 1169 | for(;;){ |
|---|
| 1170 | if( b7rootf ){ /* right truncate ... */ |
|---|
| 1171 | if (TRMrc == RCEOF) break; |
|---|
| 1172 | #if BEFORE20010827 |
|---|
| 1173 | if( strncmp((const char *) TRMkey, b7_pfxopx, strlen( b7_pfxopx ) ) ){ |
|---|
| 1174 | #endif |
|---|
| 1175 | if( strncmp((const char *) TRMkey, (const char *)mkp, strlen( (const char *)mkp ) ) ){ |
|---|
| 1176 | break; |
|---|
| 1177 | } |
|---|
| 1178 | if (b7tell >= 2 ) { |
|---|
| 1179 | count=TRMxytotp; |
|---|
| 1180 | #if !CICPP |
|---|
| 1181 | b7_msg(B7_THISP 1,TRMkey,0,count,b7rootmsg ? 1 : 4); /* 1st_msg */ |
|---|
| 1182 | #endif /* CICPP */ |
|---|
| 1183 | } |
|---|
| 1184 | |
|---|
| 1185 | if( PDLdocs && PDLplen ){ |
|---|
| 1186 | pdlp=b7_push(B7_THIS); |
|---|
| 1187 | b7_initpdl(B7_THISP pdlp, postlen, lastmfn); |
|---|
| 1188 | } |
|---|
| 1189 | |
|---|
| 1190 | }else if (TRMrc != RCNORMAL){ |
|---|
| 1191 | break; |
|---|
| 1192 | } |
|---|
| 1193 | |
|---|
| 1194 | for( nord=0;; ){ |
|---|
| 1195 | #if CICPP |
|---|
| 1196 | mfn=trmp->xposting(++nord); |
|---|
| 1197 | #else /* CICPP */ |
|---|
| 1198 | mfn=posting(b7itrm,++nord); |
|---|
| 1199 | #endif /* CICPP */ |
|---|
| 1200 | if( mfn <= 0 ) |
|---|
| 1201 | break; |
|---|
| 1202 | |
|---|
| 1203 | if (nqualts) { |
|---|
| 1204 | for (n=0, qualtp=vqualt; *qualtp; qualtp++) |
|---|
| 1205 | if (TRMptag == *qualtp) { |
|---|
| 1206 | n=1; break; |
|---|
| 1207 | } |
|---|
| 1208 | if (n) |
|---|
| 1209 | ; /* qualifiers list */ |
|---|
| 1210 | else |
|---|
| 1211 | continue; /* goto next posting */ |
|---|
| 1212 | } |
|---|
| 1213 | #if !LIND |
|---|
| 1214 | if( !PDLplen ){ |
|---|
| 1215 | #endif /* !LIND */ |
|---|
| 1216 | mask =bitmask[mfn&BY8RMASK]; |
|---|
| 1217 | offset = (mfn/8); |
|---|
| 1218 | if( !( PDLlvel[offset] & mask ) ){ |
|---|
| 1219 | PDLdocs++; |
|---|
| 1220 | PDLlvel[offset] |= mask; |
|---|
| 1221 | } |
|---|
| 1222 | #if!LIND |
|---|
| 1223 | }else{ |
|---|
| 1224 | if( mfn != hsiz ){ |
|---|
| 1225 | hsiz = mfn; |
|---|
| 1226 | PDLdocs++; |
|---|
| 1227 | // b7_addk( B7_THISP pdlp, trmp ); |
|---|
| 1228 | } |
|---|
| 1229 | b7_addk( B7_THISP pdlp, trmp ); |
|---|
| 1230 | } |
|---|
| 1231 | #endif /* !LIND */ |
|---|
| 1232 | } |
|---|
| 1233 | |
|---|
| 1234 | if( b7rootf ){ |
|---|
| 1235 | #if CICPP |
|---|
| 1236 | trmp->xnxterm(); |
|---|
| 1237 | #else /* CICPP */ |
|---|
| 1238 | NXTERM(b7itrm); |
|---|
| 1239 | #endif /* CICPP */ |
|---|
| 1240 | }else |
|---|
| 1241 | break; |
|---|
| 1242 | |
|---|
| 1243 | if( b7rootloop ){ /* hacer or entre los resultados. */ |
|---|
| 1244 | #if !LIND |
|---|
| 1245 | if( PDLplen ){ |
|---|
| 1246 | if( npdls > 1 ){ |
|---|
| 1247 | pdlp = b7_push(B7_THIS); /*donde dejar el resultado. */ |
|---|
| 1248 | b7_initpdl( B7_THISP pdlp, postlen, lastmfn ); |
|---|
| 1249 | b7_zorx(B7_THIS); |
|---|
| 1250 | } |
|---|
| 1251 | } |
|---|
| 1252 | #else |
|---|
| 1253 | ; |
|---|
| 1254 | #endif /* !LIND */ |
|---|
| 1255 | }else |
|---|
| 1256 | b7rootloop++; |
|---|
| 1257 | } |
|---|
| 1258 | |
|---|
| 1259 | } |
|---|
| 1260 | |
|---|
| 1261 | /*GOT_ZLDV:*/ |
|---|
| 1262 | |
|---|
| 1263 | if( npdls == npdlsb ){ |
|---|
| 1264 | pdlp = b7_push(B7_THIS); |
|---|
| 1265 | b7_initpdl( B7_THISP pdlp, postlen, lastmfn ); |
|---|
| 1266 | } |
|---|
| 1267 | |
|---|
| 1268 | if (b7tell) { |
|---|
| 1269 | sprintf(buffup,"%s%c",mkp,(b7rootf)? '$' : '\0'); |
|---|
| 1270 | b7_msg(B7_THISP 0,buffup,0,PDLdocs,1); |
|---|
| 1271 | } |
|---|
| 1272 | nqualts=0; |
|---|
| 1273 | break; |
|---|
| 1274 | |
|---|
| 1275 | default: |
|---|
| 1276 | #if !LIND |
|---|
| 1277 | if( !VPDLplen( vpdltop ) ){ /* top tiene nivel 1 */ |
|---|
| 1278 | #endif /* !LIND */ |
|---|
| 1279 | pdlp = vpdlp[ vpdltop ]; |
|---|
| 1280 | res = VPDLlvel( vpdltop - 1 ); |
|---|
| 1281 | op1 = PDLlvel; |
|---|
| 1282 | #if !LIND |
|---|
| 1283 | }else{ |
|---|
| 1284 | pdlp=b7_push(B7_THIS); |
|---|
| 1285 | b7_initpdl( B7_THISP pdlp, b7acc, lastmfn ); |
|---|
| 1286 | } |
|---|
| 1287 | #endif /* !LIND */ |
|---|
| 1288 | loop=PDLsize; |
|---|
| 1289 | switch( b7opr ){ |
|---|
| 1290 | case ZORX: |
|---|
| 1291 | /* oper + */ |
|---|
| 1292 | #if !LIND |
|---|
| 1293 | if( b7acc == '1' ){ |
|---|
| 1294 | #endif /* !LIND */ |
|---|
| 1295 | for( ;loop--; ) |
|---|
| 1296 | *res++ |= *op1++; |
|---|
| 1297 | b7_pop(B7_THIS); |
|---|
| 1298 | #if !LIND |
|---|
| 1299 | }else |
|---|
| 1300 | b7_zorx(B7_THIS); |
|---|
| 1301 | #endif /* !LIND */ |
|---|
| 1302 | break; |
|---|
| 1303 | case ZAND: |
|---|
| 1304 | /* oper * */ |
|---|
| 1305 | #if !LIND |
|---|
| 1306 | if( b7acc == '1' ){ |
|---|
| 1307 | #endif /* !LIND */ |
|---|
| 1308 | for( ;loop--; ) |
|---|
| 1309 | *res++ &= *op1++; |
|---|
| 1310 | b7_pop(B7_THIS); |
|---|
| 1311 | #if !LIND |
|---|
| 1312 | }else |
|---|
| 1313 | b7_zand( B7_THISP 1 ); |
|---|
| 1314 | #endif /* !LIND */ |
|---|
| 1315 | break; |
|---|
| 1316 | case ZANN: |
|---|
| 1317 | /* oper ^ */ |
|---|
| 1318 | #if !LIND |
|---|
| 1319 | if( b7acc == '1' ){ |
|---|
| 1320 | #endif /* !LIND */ |
|---|
| 1321 | for( ;loop--; ) |
|---|
| 1322 | *res++ &= ~(*op1++); |
|---|
| 1323 | b7_pop(B7_THIS); |
|---|
| 1324 | #if !LIND |
|---|
| 1325 | }else |
|---|
| 1326 | b7_zann(B7_THIS); |
|---|
| 1327 | #endif /* !LIND */ |
|---|
| 1328 | break; |
|---|
| 1329 | #if !LIND |
|---|
| 1330 | case ZANG: |
|---|
| 1331 | /* oper (G) */ |
|---|
| 1332 | b7_zand( B7_THISP 2 ); |
|---|
| 1333 | break; |
|---|
| 1334 | case ZANF: |
|---|
| 1335 | /* oper (F) */ |
|---|
| 1336 | b7_zand( B7_THISP 3 ); |
|---|
| 1337 | break; |
|---|
| 1338 | case ZANP: |
|---|
| 1339 | /* oper . */ |
|---|
| 1340 | b7_zanp( B7_THISP 4, b7qty ); |
|---|
| 1341 | break; |
|---|
| 1342 | case ZANE: |
|---|
| 1343 | /* oper $ */ |
|---|
| 1344 | b7_zanp( B7_THISP 5, b7qty ); |
|---|
| 1345 | break; |
|---|
| 1346 | #endif /* !LIND */ |
|---|
| 1347 | } |
|---|
| 1348 | pdlp = vpdlp[vpdltop]; |
|---|
| 1349 | if( !PDLplen ) |
|---|
| 1350 | PDLdocs = b7_hsizh( B7_THISP pdlp, &hsiz ); |
|---|
| 1351 | |
|---|
| 1352 | if (b7tell) { |
|---|
| 1353 | sprintf(buffup,"%c",b7opr); |
|---|
| 1354 | b7_msg(B7_THISP 0,buffup,0,PDLdocs,2); |
|---|
| 1355 | } |
|---|
| 1356 | } |
|---|
| 1357 | } |
|---|
| 1358 | |
|---|
| 1359 | PDLdocs = b7_hsizh( B7_THISP pdlp, &hsiz ); |
|---|
| 1360 | |
|---|
| 1361 | sprintf(buffup,B7EDIT1,b7setno); |
|---|
| 1362 | if (b7tell) |
|---|
| 1363 | b7_msg(B7_THISP 1,buffup,0,PDLdocs,3); /* end_msg */ |
|---|
| 1364 | |
|---|
| 1365 | #if RUITRACE |
|---|
| 1366 | b7_showpdl( B7_THIS ); |
|---|
| 1367 | #endif |
|---|
| 1368 | |
|---|
| 1369 | pdlp = vpdlp[vpdltop]; |
|---|
| 1370 | |
|---|
| 1371 | /* store actual MFQTASET */ |
|---|
| 1372 | sprintf(buffup,B7EDIT1,b7setno); |
|---|
| 1373 | #if CICPP |
|---|
| 1374 | memcpy(FIELDP(irecp->xfieldx(MFQTASET,1)),buffup,B7UPLEN); |
|---|
| 1375 | #else /* CICPP */ |
|---|
| 1376 | memcpy(FIELDP(fieldx(irec,MFQTASET,1)),buffup,B7UPLEN); |
|---|
| 1377 | #endif /* CICPP */ |
|---|
| 1378 | |
|---|
| 1379 | /* store actual MFQTALCC */ |
|---|
| 1380 | sprintf(buffup,B7EDIT1,lastcc); |
|---|
| 1381 | #if CICPP |
|---|
| 1382 | memcpy(FIELDP(irecp->xfieldx(MFQTALCC,1)),buffup,B7UPLEN); |
|---|
| 1383 | #else /* CICPP */ |
|---|
| 1384 | memcpy(FIELDP(fieldx(irec,MFQTALCC,1)),buffup,B7UPLEN); |
|---|
| 1385 | #endif /* CICPP */ |
|---|
| 1386 | |
|---|
| 1387 | /* store actual MFQTHITS */ |
|---|
| 1388 | sprintf(buffup,B7EDIT1,PDLdocs); |
|---|
| 1389 | #if CICPP |
|---|
| 1390 | memcpy(FIELDP(irecp->xfieldx(MFQTHITS,1)),buffup,B7UPLEN); |
|---|
| 1391 | #else /* CICPP */ |
|---|
| 1392 | memcpy(FIELDP(fieldx(irec,MFQTHITS,1)),buffup,B7UPLEN); |
|---|
| 1393 | #endif /* CICPP */ |
|---|
| 1394 | |
|---|
| 1395 | /*..*/ |
|---|
| 1396 | /* actual #bytes of hit list */ |
|---|
| 1397 | hsiz = hsiz/8+1; |
|---|
| 1398 | |
|---|
| 1399 | /* store actual MFQTHSIZ */ |
|---|
| 1400 | sprintf(buffup,B7EDIT1,hsiz); |
|---|
| 1401 | #if CICPP |
|---|
| 1402 | memcpy(FIELDP(irecp->xfieldx(MFQTHSIZ,1)),buffup,B7UPLEN); |
|---|
| 1403 | #else /* CICPP */ |
|---|
| 1404 | memcpy(FIELDP(fieldx(irec,MFQTHSIZ,1)),buffup,B7UPLEN); |
|---|
| 1405 | #endif /* CICPP */ |
|---|
| 1406 | |
|---|
| 1407 | /*..*/ |
|---|
| 1408 | /* update stored MFQTHMEM */ |
|---|
| 1409 | if (b7fd) { |
|---|
| 1410 | |
|---|
| 1411 | for (p0p=PDLlvel, left=hsiz/*, bytes=0*/; left; left-=bytes ) { |
|---|
| 1412 | bytes=hsiz; |
|---|
| 1413 | if (bytes > B72SIZE_MAX) |
|---|
| 1414 | bytes=B72SIZE_MAX; /* < U */ |
|---|
| 1415 | if (bytes > left) |
|---|
| 1416 | bytes=left; |
|---|
| 1417 | if ((unsigned)CIWRITE(b7fd,p0p,(unsigned)bytes) != bytes){ |
|---|
| 1418 | fatal("b73_run/write/6"); |
|---|
| 1419 | } |
|---|
| 1420 | |
|---|
| 1421 | p0p+=bytes; |
|---|
| 1422 | } |
|---|
| 1423 | CLOSE(b7fd); |
|---|
| 1424 | b7fd=0; /* 06/03/95 */ |
|---|
| 1425 | } |
|---|
| 1426 | |
|---|
| 1427 | |
|---|
| 1428 | /* update MFQTXCTS^MFQSWQTY */ |
|---|
| 1429 | sprintf(buffup,B7EDIT1,PDLdocs); |
|---|
| 1430 | #if CICPP |
|---|
| 1431 | if ((xdir_xcts=irecp->xfieldx(MFQTXCTS,irecp->xnocc(MFQTXCTS))) < 0) |
|---|
| 1432 | #else /* CICPP */ |
|---|
| 1433 | if ((xdir_xcts=fieldx(irec,MFQTXCTS,nocc(irec,MFQTXCTS))) < 0) |
|---|
| 1434 | #endif /* CICPP */ |
|---|
| 1435 | fatal("b7_run/xdir_xcts"); |
|---|
| 1436 | n=DIRlen(xdir_xcts); p=(unsigned char *)FIELDP(xdir_xcts); |
|---|
| 1437 | nffi=n; |
|---|
| 1438 | p=subfldp(p,MFQSWQTY,&nffi); |
|---|
| 1439 | memcpy(p,buffup,B7UPLEN); |
|---|
| 1440 | |
|---|
| 1441 | /* put it on disk */ |
|---|
| 1442 | if (RECdbxp) { |
|---|
| 1443 | #if CICPP |
|---|
| 1444 | recp->xrecupdat(); |
|---|
| 1445 | #else /* CICPP */ |
|---|
| 1446 | recupdat(crec,irec); |
|---|
| 1447 | #endif /* CICPP */ |
|---|
| 1448 | } |
|---|
| 1449 | RECtype=TYPEMFQ; |
|---|
| 1450 | |
|---|
| 1451 | |
|---|
| 1452 | #if CIB7HITLIST |
|---|
| 1453 | /* alloc b7bufferp if needed */ |
|---|
| 1454 | if (!b7error) { |
|---|
| 1455 | |
|---|
| 1456 | LONGX bytsneed; // |
|---|
| 1457 | int hcase; // |
|---|
| 1458 | LONGX mfnvar; |
|---|
| 1459 | LONGX xbytes=PDLdocs*sizeof(mfnvar); |
|---|
| 1460 | |
|---|
| 1461 | if (xbytes < hsiz) { |
|---|
| 1462 | bytsneed=xbytes; |
|---|
| 1463 | hcase=MFNSTRING; /* a binary 4-byte integer list ready to use */ |
|---|
| 1464 | } |
|---|
| 1465 | else { |
|---|
| 1466 | bytsneed=hsiz; // |
|---|
| 1467 | hcase=BITSTRING; // |
|---|
| 1468 | } |
|---|
| 1469 | |
|---|
| 1470 | if (b7bufferp) if (b7bufferp->bufsiz < bytsneed) b7_hbfree(B7_THISP &b7bufferp); |
|---|
| 1471 | if (!b7bufferp) b7_hballoc(B7_THISP (bytsneed),&b7bufferp); |
|---|
| 1472 | b7bufferp->setno = b7setno; |
|---|
| 1473 | |
|---|
| 1474 | b7bufferp->hcase = hcase; |
|---|
| 1475 | b7bufferp->ndocs = PDLdocs; |
|---|
| 1476 | |
|---|
| 1477 | if (hcase == MFNSTRING) { |
|---|
| 1478 | |
|---|
| 1479 | unsigned char *hp=PDLlvel; |
|---|
| 1480 | LONGX hsizleft=hsiz; |
|---|
| 1481 | LONGX hitsleft=PDLdocs; |
|---|
| 1482 | |
|---|
| 1483 | LONGX hcur=0; |
|---|
| 1484 | LONGX hmfn=0; |
|---|
| 1485 | int bitloop,by8masked; |
|---|
| 1486 | |
|---|
| 1487 | B7HITLIST *hitlistp=(B7HITLIST *)b7bufferp->area; |
|---|
| 1488 | LONGX *mfnlistp=hitlistp->mfnlist; |
|---|
| 1489 | |
|---|
| 1490 | for (; hitsleft; ) { |
|---|
| 1491 | /* check bytes left */ if (!hsizleft) fatal("b7_run/aotmsa1/hsizleft"); |
|---|
| 1492 | /* skip null bytes */ |
|---|
| 1493 | while (!*hp) { |
|---|
| 1494 | hp++; hmfn+=8; hsizleft--; |
|---|
| 1495 | } |
|---|
| 1496 | /* scan max 8 bits */ |
|---|
| 1497 | bitloop=8-(hmfn&BY8RMASK); |
|---|
| 1498 | for (; bitloop--; hmfn++) { |
|---|
| 1499 | if (*hp&bitmask[by8masked=hmfn&BY8RMASK]) { |
|---|
| 1500 | hcur++; hitsleft--; |
|---|
| 1501 | /* store hit hcur/hmfn and count it */ |
|---|
| 1502 | *mfnlistp++ = hmfn; |
|---|
| 1503 | } /* end if (*hp & bitmask[by8masked]) */ |
|---|
| 1504 | } /* end for (; bitloop--; hmfn++) */ |
|---|
| 1505 | /* increment byte ptr every 8 bits */ |
|---|
| 1506 | if (by8masked == BY8RMASK) { |
|---|
| 1507 | hp++; hsizleft--; |
|---|
| 1508 | } |
|---|
| 1509 | } /* end for (; hitsleft; ) */ |
|---|
| 1510 | } /* end if (hcase == MFNSTRING) */ |
|---|
| 1511 | else { /* else if (hcase == MFNSTRING) */ |
|---|
| 1512 | memcpy(b7bufferp->area,PDLlvel,hsiz); |
|---|
| 1513 | memset(b7bufferp->area+hsiz,0x00,b7bufferp->bufsiz-hsiz); |
|---|
| 1514 | } /* end if (hcase == MFNSTRING) */ |
|---|
| 1515 | } /* end if (!b7error) */ |
|---|
| 1516 | |
|---|
| 1517 | //B7HITLISTLONG 1 |
|---|
| 1518 | //B7HITLISTSHORT 2 |
|---|
| 1519 | |
|---|
| 1520 | #else /* CIB7HITLIST */ |
|---|
| 1521 | |
|---|
| 1522 | /* alloc b7bufferp if needed */ |
|---|
| 1523 | if (!b7error) { |
|---|
| 1524 | if (b7bufferp) if (b7bufferp->bufsiz < (lastmfn/8+1)) b7_hbfree(B7_THISP &b7bufferp); |
|---|
| 1525 | if (!b7bufferp) b7_hballoc(B7_THISP (lastmfn/8+1),&b7bufferp); |
|---|
| 1526 | b7bufferp->setno = b7setno; |
|---|
| 1527 | |
|---|
| 1528 | memcpy(b7bufferp->area,PDLlvel,hsiz); |
|---|
| 1529 | memset(b7bufferp->area+hsiz,0x00,b7bufferp->bufsiz-hsiz); |
|---|
| 1530 | } |
|---|
| 1531 | #endif /* CIB7HITLIST */ |
|---|
| 1532 | |
|---|
| 1533 | /* release tmp area */ |
|---|
| 1534 | b7_pop(B7_THIS); |
|---|
| 1535 | |
|---|
| 1536 | #if CICPP |
|---|
| 1537 | delete trmp; |
|---|
| 1538 | #else |
|---|
| 1539 | free(vtrmp[b7itrm]); /* Chico 03/07/2007 */ |
|---|
| 1540 | vtrmp[b7itrm] = NULL; |
|---|
| 1541 | ntrms--; |
|---|
| 1542 | #endif /* CICPP */ |
|---|
| 1543 | |
|---|
| 1544 | *errnop=b7error; |
|---|
| 1545 | return 0; |
|---|
| 1546 | |
|---|
| 1547 | } |
|---|
| 1548 | |
|---|
| 1549 | #if CICPP |
|---|
| 1550 | int CIB7::b7_hballoc(LONGX bufsiz, B7HITBUF **bufferpp) |
|---|
| 1551 | #else /*CICPP*/ |
|---|
| 1552 | int b7_hballoc(cib7p,bufsiz,bufferpp) /* |
|---|
| 1553 | ------------ |
|---|
| 1554 | allocate b7_hit() processing buffer |
|---|
| 1555 | */ |
|---|
| 1556 | b7_CIB7 *cib7p; |
|---|
| 1557 | LONGX bufsiz; /* buffer size */ |
|---|
| 1558 | B7HITBUF **bufferpp; /* buffer addr */ |
|---|
| 1559 | #endif /*CICPP*/ |
|---|
| 1560 | { |
|---|
| 1561 | if (!*bufferpp) { |
|---|
| 1562 | #if CICPP |
|---|
| 1563 | try { *bufferpp=(B7HITBUF *)new char [sizeof(B7HITBUF)+bufsiz]; } |
|---|
| 1564 | catch (BAD_ALLOC) { *bufferpp = (B7HITBUF *)ALLONULL; } |
|---|
| 1565 | #else /* CICPP */ |
|---|
| 1566 | *bufferpp=(B7HITBUF *)ALLOC((ALLOPARM)(sizeof(B7HITBUF)+bufsiz)); |
|---|
| 1567 | #endif /* CICPP */ |
|---|
| 1568 | if (*bufferpp == (B7HITBUF *)ALLONULL) fatal("b7_hballoc/ALLOC"); |
|---|
| 1569 | (*bufferpp)->bufsiz=bufsiz; |
|---|
| 1570 | } |
|---|
| 1571 | else |
|---|
| 1572 | if ((*bufferpp)->bufsiz != bufsiz) fatal("b7_hballoc/bufsiz"); |
|---|
| 1573 | /* (*bufferpp)->block=(-1L);*/ |
|---|
| 1574 | (*bufferpp)->setno=(-1L); |
|---|
| 1575 | return(0); |
|---|
| 1576 | } |
|---|
| 1577 | |
|---|
| 1578 | |
|---|
| 1579 | #if CICPP |
|---|
| 1580 | int CIB7::b7_hbinit(LONGX setno, B7HITBUF *bufferp) |
|---|
| 1581 | #else /*CICPP*/ |
|---|
| 1582 | int b7_hbinit(cib7p,setno,bufferp) /* |
|---|
| 1583 | ------------ |
|---|
| 1584 | initialize b7_hit() processing buffer |
|---|
| 1585 | */ |
|---|
| 1586 | b7_CIB7 *cib7p; |
|---|
| 1587 | LONGX setno; /* query number */ |
|---|
| 1588 | B7HITBUF *bufferp; /* buffer */ |
|---|
| 1589 | #endif /*CICPP*/ |
|---|
| 1590 | { |
|---|
| 1591 | if (!bufferp) fatal("b7_hbinit/NULL"); |
|---|
| 1592 | /* bufferp->block=(-1L);*/ |
|---|
| 1593 | bufferp->setno=setno; |
|---|
| 1594 | return(0); |
|---|
| 1595 | } |
|---|
| 1596 | |
|---|
| 1597 | #if CICPP |
|---|
| 1598 | int CIB7::b7_hbfree(B7HITBUF **bufferpp) |
|---|
| 1599 | #else /*CICPP*/ |
|---|
| 1600 | int b7_hbfree(cib7p,bufferpp) /* |
|---|
| 1601 | ------------ |
|---|
| 1602 | release b7_hit() processing buffer |
|---|
| 1603 | */ |
|---|
| 1604 | b7_CIB7 *cib7p; |
|---|
| 1605 | B7HITBUF **bufferpp; /* buffer addr */ |
|---|
| 1606 | #endif /*CICPP*/ |
|---|
| 1607 | { |
|---|
| 1608 | if (*bufferpp) { |
|---|
| 1609 | #if CICPP |
|---|
| 1610 | delete [] (char *)*bufferpp; |
|---|
| 1611 | #else /* CICPP */ |
|---|
| 1612 | FREE(*bufferpp); |
|---|
| 1613 | #endif /* CICPP */ |
|---|
| 1614 | *bufferpp=NULL; |
|---|
| 1615 | } |
|---|
| 1616 | return(0); |
|---|
| 1617 | } |
|---|
| 1618 | |
|---|
| 1619 | #if CICPP |
|---|
| 1620 | LONGX CIB7::b7_hit(RECSTRU *irecp, LONGX nord, LONGX setno) |
|---|
| 1621 | #else /* CICPP */ |
|---|
| 1622 | LONGX b7_hit(cib7p,irec,nord,setno) /* |
|---|
| 1623 | ----------- |
|---|
| 1624 | abenda se vrecp nao inicializado; |
|---|
| 1625 | abenda se registro irec nao alocado; |
|---|
| 1626 | abenda se registro irec invalido; |
|---|
| 1627 | retorna total de hits se nord = 0; |
|---|
| 1628 | se nord > total de hits |
|---|
| 1629 | zera hit e mfn correntes e retorna -1; |
|---|
| 1630 | mantem controles para chamadas subsequentes; |
|---|
| 1631 | retorna o mfn correspondente ao hit nord |
|---|
| 1632 | (retorna -2 .. -n se algum erro) |
|---|
| 1633 | */ |
|---|
| 1634 | b7_CIB7 *cib7p; |
|---|
| 1635 | LONGX irec; /* indice de vrecp, para info/store */ |
|---|
| 1636 | LONGX nord; /* numero de ordem do hit a analisar */ |
|---|
| 1637 | LONGX setno; /* query number */ |
|---|
| 1638 | #endif /* CICPP */ |
|---|
| 1639 | { |
|---|
| 1640 | char buffup[B7UPLEN+1]; /* area for fldupdat */ |
|---|
| 1641 | RECSTRU *recp; |
|---|
| 1642 | LONGX hits,hcur,hsiz,hmfn; |
|---|
| 1643 | int xdir_hits,xdir_hcur,xdir_hsiz,xdir_hmfn,xdir_hmem; |
|---|
| 1644 | unsigned char *p; |
|---|
| 1645 | LONGX offset,mfn; |
|---|
| 1646 | LONGX loop; |
|---|
| 1647 | int loop2,n,delta8,delta1; |
|---|
| 1648 | #if CHKFOUND |
|---|
| 1649 | int found; |
|---|
| 1650 | #endif |
|---|
| 1651 | /* Leer de disco */ |
|---|
| 1652 | int fd; |
|---|
| 1653 | char filname[CIMPL+1]; |
|---|
| 1654 | LONGX rslen; |
|---|
| 1655 | #if HITTRACE |
|---|
| 1656 | printf("b7_hit - irec,nord: %"_LD_,%"_LD_" \n",irec,nord); |
|---|
| 1657 | #endif |
|---|
| 1658 | #if SHOWCORE |
|---|
| 1659 | if (b70trace) showcore("b7_hit"); |
|---|
| 1660 | #endif |
|---|
| 1661 | |
|---|
| 1662 | /* Process hit MFNSTRING/LONGX |
|---|
| 1663 | */ |
|---|
| 1664 | #if CIB7HITLIST /* AOT, 28/01/2002 */ |
|---|
| 1665 | if (!b7bufferp) fatal("b7_hit/MFNSTRING/b7bufferp"); |
|---|
| 1666 | if (b7bufferp->setno != setno) fatal("b7_hit/MFNSTRING/setno"); |
|---|
| 1667 | if (b7bufferp->hcase == MFNSTRING) { |
|---|
| 1668 | hits=b7bufferp->ndocs; |
|---|
| 1669 | if (nord == 0 || nord > hits) { |
|---|
| 1670 | if (nord == 0) |
|---|
| 1671 | mfn=hits; /* returning value */ |
|---|
| 1672 | else |
|---|
| 1673 | mfn=(-1L); |
|---|
| 1674 | } |
|---|
| 1675 | else { /* 1 >= nord <= hits */ |
|---|
| 1676 | B7HITLIST *hitlistp; /* hit processing */ |
|---|
| 1677 | LONGX *mfnlistp; /* hit processing */ |
|---|
| 1678 | hitlistp=(B7HITLIST *)b7bufferp->area; |
|---|
| 1679 | mfnlistp=hitlistp->mfnlist; |
|---|
| 1680 | mfnlistp+=(nord-1); |
|---|
| 1681 | mfn = *mfnlistp; |
|---|
| 1682 | } /* end if (nord == 0 || nord > hits) */ |
|---|
| 1683 | |
|---|
| 1684 | return(mfn); |
|---|
| 1685 | |
|---|
| 1686 | } /* if (b7bufferp->hcase == MFNSTRING) */ |
|---|
| 1687 | #endif /* CIB7HITLIST */ |
|---|
| 1688 | |
|---|
| 1689 | |
|---|
| 1690 | /* BTW, b7errxy nao deveria ser resetado antes de return??? - AOT, 28/01/2002 */ |
|---|
| 1691 | strcpy(b7errxy,"b7_hit"); /* b7_hiterr() */ |
|---|
| 1692 | |
|---|
| 1693 | #if !CICPP |
|---|
| 1694 | if (!nrecs) |
|---|
| 1695 | #if CDROM |
|---|
| 1696 | return(-2L); |
|---|
| 1697 | #else |
|---|
| 1698 | fatal("b7_hit/nrecs"); |
|---|
| 1699 | #endif |
|---|
| 1700 | recp=vrecp[irec]; |
|---|
| 1701 | |
|---|
| 1702 | #else /* CICPP */ |
|---|
| 1703 | recp=irecp; |
|---|
| 1704 | #endif /* CICPP */ |
|---|
| 1705 | |
|---|
| 1706 | if (!recp) |
|---|
| 1707 | #if CDROM |
|---|
| 1708 | return(-3L); |
|---|
| 1709 | #else |
|---|
| 1710 | fatal("b7_hit/irec"); |
|---|
| 1711 | #endif |
|---|
| 1712 | if (RECtype != TYPEMFQ || RECrc != RCNORMAL) |
|---|
| 1713 | #if CDROM |
|---|
| 1714 | return(-4L); |
|---|
| 1715 | #else |
|---|
| 1716 | fatal("b7_hit/check"); |
|---|
| 1717 | #endif |
|---|
| 1718 | #if CICPP |
|---|
| 1719 | if ((xdir_hits=recp->xfieldx(MFQTHITS,1)) < 0) |
|---|
| 1720 | #else /* CICPP */ |
|---|
| 1721 | if ((xdir_hits=fieldx(irec,MFQTHITS,1)) < 0) |
|---|
| 1722 | #endif /* CICPP */ |
|---|
| 1723 | |
|---|
| 1724 | #if CDROM |
|---|
| 1725 | return(-5L); |
|---|
| 1726 | #else |
|---|
| 1727 | fatal("b7_hit/xdir_hits"); |
|---|
| 1728 | #endif |
|---|
| 1729 | |
|---|
| 1730 | for (hits=0, p=(unsigned char *)FIELDP(xdir_hits), loop=DIRlen(xdir_hits); loop--; p++) |
|---|
| 1731 | hits = hits * 10 + (*p - '0'); |
|---|
| 1732 | if (nord < 0 || nord > (hits+1)) |
|---|
| 1733 | #if CDROM |
|---|
| 1734 | return(-6L); |
|---|
| 1735 | #else |
|---|
| 1736 | fatal("b7_hit/nord"); |
|---|
| 1737 | #endif |
|---|
| 1738 | #if CICPP |
|---|
| 1739 | if ((xdir_hcur=recp->xfieldx(MFQTHCUR,1)) < 0) |
|---|
| 1740 | #else /* CICPP */ |
|---|
| 1741 | if ((xdir_hcur=fieldx(irec,MFQTHCUR,1)) < 0) |
|---|
| 1742 | #endif /* CICPP */ |
|---|
| 1743 | #if CDROM |
|---|
| 1744 | return(-7L); |
|---|
| 1745 | #else |
|---|
| 1746 | fatal("b7_hit/xdir_hcur"); |
|---|
| 1747 | #endif |
|---|
| 1748 | #if CICPP |
|---|
| 1749 | if ((xdir_hmfn=recp->xfieldx(MFQTHMFN,1)) < 0) |
|---|
| 1750 | #else /* CICPP */ |
|---|
| 1751 | if ((xdir_hmfn=fieldx(irec,MFQTHMFN,1)) < 0) |
|---|
| 1752 | #endif /* CICPP */ |
|---|
| 1753 | #if CDROM |
|---|
| 1754 | return(-8L); |
|---|
| 1755 | #else |
|---|
| 1756 | fatal("b7_hit/xdir_hmfn"); |
|---|
| 1757 | #endif |
|---|
| 1758 | #if CICPP |
|---|
| 1759 | if ((xdir_hsiz=recp->xfieldx(MFQTHSIZ,1)) < 0) |
|---|
| 1760 | #else /* CICPP */ |
|---|
| 1761 | if ((xdir_hsiz=fieldx(irec,MFQTHSIZ,1)) < 0) |
|---|
| 1762 | #endif /* CICPP */ |
|---|
| 1763 | #if CDROM |
|---|
| 1764 | return(-9L); |
|---|
| 1765 | #else |
|---|
| 1766 | fatal("b7_hit/xdir_hsiz"); |
|---|
| 1767 | #endif |
|---|
| 1768 | if (nord == 0 || nord > hits) { |
|---|
| 1769 | hcur=hmfn=0; |
|---|
| 1770 | if (nord == 0) |
|---|
| 1771 | mfn=hits; /* returning value */ |
|---|
| 1772 | else |
|---|
| 1773 | mfn=(-1L); |
|---|
| 1774 | } |
|---|
| 1775 | else { |
|---|
| 1776 | for (hcur=0, p=(unsigned char *)FIELDP(xdir_hcur), loop=DIRlen(xdir_hcur); loop--; p++) |
|---|
| 1777 | hcur = hcur * 10 + (*p - '0'); |
|---|
| 1778 | for (hmfn=0, p=(unsigned char *)FIELDP(xdir_hmfn), loop=DIRlen(xdir_hmfn); loop--; p++) |
|---|
| 1779 | hmfn = hmfn * 10 + (*p - '0'); |
|---|
| 1780 | for (hsiz=0, p=(unsigned char *)FIELDP(xdir_hsiz), loop=DIRlen(xdir_hsiz); loop--; p++) |
|---|
| 1781 | hsiz = hsiz * 10 + (*p - '0'); |
|---|
| 1782 | #if HITTRACx |
|---|
| 1783 | printf("b7_hit - rec - hits=%"_LD_" hcur=%"_LD_" hsiz=%"_LD_" hmfn=%"_LD_"\n", |
|---|
| 1784 | hits,hcur,hsiz,hmfn); |
|---|
| 1785 | #endif |
|---|
| 1786 | if (hcur == nord) |
|---|
| 1787 | mfn=hmfn; |
|---|
| 1788 | else { |
|---|
| 1789 | #if CICPP |
|---|
| 1790 | if ((xdir_hmem=recp->xfieldx(MFQTHMEM,1)) < 0) |
|---|
| 1791 | #else /* CICPP */ |
|---|
| 1792 | if ((xdir_hmem=fieldx(irec,MFQTHMEM,1)) < 0) |
|---|
| 1793 | #endif /* CICPP */ |
|---|
| 1794 | #if CDROM |
|---|
| 1795 | return(-10L); |
|---|
| 1796 | #else |
|---|
| 1797 | fatal("b7_hit/xdir_hmen"); |
|---|
| 1798 | #endif |
|---|
| 1799 | if (nord > hcur) { |
|---|
| 1800 | #if UNIX |
|---|
| 1801 | delta8 = 8; delta1 = 1; |
|---|
| 1802 | #else |
|---|
| 1803 | delta8 = +8; delta1 = +1; |
|---|
| 1804 | #endif |
|---|
| 1805 | } |
|---|
| 1806 | else { |
|---|
| 1807 | delta8 = -8; delta1 = -1; |
|---|
| 1808 | } |
|---|
| 1809 | #if CDUSP |
|---|
| 1810 | mfn = (hcur == 0) ? 0 : hmfn+delta1; |
|---|
| 1811 | #else |
|---|
| 1812 | mfn = (hmfn == 0) ? 0 : hmfn+delta1; |
|---|
| 1813 | #endif |
|---|
| 1814 | offset=(mfn/8); |
|---|
| 1815 | /* Leer de disco */ |
|---|
| 1816 | if (!b7bufferp) fatal("b7_hit/buffer"); |
|---|
| 1817 | if (b7bufferp->bufsiz < hsiz) fatal("b7_hit/bufsiz"); |
|---|
| 1818 | if (b7bufferp->setno != setno) { |
|---|
| 1819 | memcpy(filname,FIELDP(xdir_hmem),n=DIRlen(xdir_hmem)); |
|---|
| 1820 | filname[n]='\0'; |
|---|
| 1821 | dbxopt_fatal=0; fd=dbxopen(b7_gidbnp,filname,""); |
|---|
| 1822 | if (fd <= 0) fatal("b7_hit/open/1"); |
|---|
| 1823 | rslen=(unsigned)CIREAD(fd,b7bufferp->area,hsiz); |
|---|
| 1824 | if (rslen != hsiz) fatal("b7_hit/read/1"); |
|---|
| 1825 | CLOSE(fd); |
|---|
| 1826 | b7bufferp->setno = setno; |
|---|
| 1827 | } |
|---|
| 1828 | |
|---|
| 1829 | /* for (p=FIELDP(xdir_hmem)+offset; hcur != nord; ) {*/ |
|---|
| 1830 | for (p=b7bufferp->area+offset; hcur != nord; ) { |
|---|
| 1831 | loop=(nord > hcur) ? hsiz-(mfn/8) : (mfn/8); |
|---|
| 1832 | #if CHKFOUND |
|---|
| 1833 | found=0; |
|---|
| 1834 | #endif |
|---|
| 1835 | #if HITTRACx |
|---|
| 1836 | printf("b7_hit - hcur=%"_LD_" nord=%"_LD_" mfn=%"_LD_" *p=%02x loop=%"_LD_" - hmfn=%"_LD_"\n", |
|---|
| 1837 | hcur,nord,mfn,*p,loop,hmfn); |
|---|
| 1838 | #endif |
|---|
| 1839 | do { |
|---|
| 1840 | if (!*p) { |
|---|
| 1841 | p+=delta1; mfn+=delta8; |
|---|
| 1842 | #if HITTRACx |
|---|
| 1843 | printf("b7_hit - hcur=%"_LD_" nord=%"_LD_" mfn=%"_LD_" *p=%02x loop=%"_LD_" - continue\n", |
|---|
| 1844 | hcur,nord,mfn,*p,loop); |
|---|
| 1845 | #endif |
|---|
| 1846 | continue; |
|---|
| 1847 | } |
|---|
| 1848 | if (nord > hcur) |
|---|
| 1849 | loop2 = 8 - (mfn&BY8RMASK); |
|---|
| 1850 | else |
|---|
| 1851 | loop2 = (mfn&BY8RMASK) + 1; |
|---|
| 1852 | for (; loop2--; mfn+=delta1) { |
|---|
| 1853 | n=mfn&BY8RMASK; |
|---|
| 1854 | #if HITTRACx |
|---|
| 1855 | printf("b7_hit - hcur=%"_LD_" nord=%"_LD_" mfn=%"_LD_" *p=%02x loop=%"_LD_" loop2=%d n=%d\n", |
|---|
| 1856 | hcur,nord,mfn,*p,loop,loop2,n); |
|---|
| 1857 | #endif |
|---|
| 1858 | if (*p & bitmask[n]) { |
|---|
| 1859 | #if CHKFOUND |
|---|
| 1860 | found=1; |
|---|
| 1861 | #endif |
|---|
| 1862 | hmfn=mfn; hcur+=delta1; |
|---|
| 1863 | if (nord == hcur) |
|---|
| 1864 | break; |
|---|
| 1865 | } |
|---|
| 1866 | } |
|---|
| 1867 | #if CHKFOUND |
|---|
| 1868 | if (found) { |
|---|
| 1869 | #endif |
|---|
| 1870 | if (nord > hcur) { |
|---|
| 1871 | if (n == BY8RMASK) |
|---|
| 1872 | p++; |
|---|
| 1873 | } |
|---|
| 1874 | else |
|---|
| 1875 | if (n == 0) |
|---|
| 1876 | p--; |
|---|
| 1877 | break; |
|---|
| 1878 | #if CHKFOUND |
|---|
| 1879 | } |
|---|
| 1880 | else |
|---|
| 1881 | fatal("b7_hit/bug1"); |
|---|
| 1882 | #endif |
|---|
| 1883 | } while (--loop > 0); |
|---|
| 1884 | #if CHKFOUND |
|---|
| 1885 | if (!found) |
|---|
| 1886 | fatal("b7_hit/bug2"); |
|---|
| 1887 | #endif |
|---|
| 1888 | } /* end for hcur != nord */ |
|---|
| 1889 | } /* end else hcur == nord */ |
|---|
| 1890 | } /* end else nord == 0 || nord > hits */ |
|---|
| 1891 | /* store */ |
|---|
| 1892 | sprintf(buffup,B7EDIT1,hcur); |
|---|
| 1893 | memcpy(FIELDP(xdir_hcur),buffup,B7UPLEN); |
|---|
| 1894 | sprintf(buffup,B7EDIT1,hmfn); |
|---|
| 1895 | memcpy(FIELDP(xdir_hmfn),buffup,B7UPLEN); |
|---|
| 1896 | #if HITTRACE |
|---|
| 1897 | printf("b7_hit - mfn: %"_LD_"\n",mfn); |
|---|
| 1898 | #endif |
|---|
| 1899 | #if SHOWCORE |
|---|
| 1900 | if (b70trace) showcore("b7_hit - exit"); |
|---|
| 1901 | #endif |
|---|
| 1902 | return(mfn); |
|---|
| 1903 | } |
|---|
| 1904 | |
|---|
| 1905 | #if !WWWISIS |
|---|
| 1906 | #if CICPP |
|---|
| 1907 | int CIB7::b7_msg(int tline,char *msg,LONGX psts,LONGX docs,int tmsg) |
|---|
| 1908 | #else |
|---|
| 1909 | int b7_msg(cib7p,tline,msg,psts,docs,tmsg) |
|---|
| 1910 | b7_CIB7 *cib7p; |
|---|
| 1911 | int tline; |
|---|
| 1912 | char *msg; |
|---|
| 1913 | LONGX psts; |
|---|
| 1914 | LONGX docs; |
|---|
| 1915 | int tmsg; |
|---|
| 1916 | #endif |
|---|
| 1917 | { |
|---|
| 1918 | char *q; |
|---|
| 1919 | |
|---|
| 1920 | q = msg+strlen( msg ); |
|---|
| 1921 | if (nqualts) { |
|---|
| 1922 | *q++ = '/'; *q++ = '('; |
|---|
| 1923 | for (qualtp=vqualt; *qualtp; qualtp++) { |
|---|
| 1924 | if (*(qualtp+1)) |
|---|
| 1925 | sprintf(q,"%d,",*qualtp); |
|---|
| 1926 | else |
|---|
| 1927 | sprintf(q,"%d",*qualtp); |
|---|
| 1928 | while (*q) q++; |
|---|
| 1929 | } |
|---|
| 1930 | *q++ = ')'; *q = '\0'; |
|---|
| 1931 | } |
|---|
| 1932 | |
|---|
| 1933 | |
|---|
| 1934 | if (docs) { |
|---|
| 1935 | printf("%8"_LD_" ",docs); //AOT, 22/12/2006 |
|---|
| 1936 | } |
|---|
| 1937 | else { /*12345678 */ |
|---|
| 1938 | printf(" "); //AOT, 22/12/2006 |
|---|
| 1939 | } |
|---|
| 1940 | if (msg) |
|---|
| 1941 | switch (tmsg) { |
|---|
| 1942 | case 1: |
|---|
| 1943 | printf(" %s",msg); |
|---|
| 1944 | break; |
|---|
| 1945 | case 2: |
|---|
| 1946 | printf(" Operation %s",msg); |
|---|
| 1947 | break; |
|---|
| 1948 | case 3: |
|---|
| 1949 | printf(" Set #%s",msg); |
|---|
| 1950 | break; |
|---|
| 1951 | case 4: |
|---|
| 1952 | printf(" %s",msg); |
|---|
| 1953 | break; |
|---|
| 1954 | default: |
|---|
| 1955 | fatal("b7_msg/tmsg"); |
|---|
| 1956 | } |
|---|
| 1957 | #if TOSEETLINE |
|---|
| 1958 | if (tline) |
|---|
| 1959 | printf(" [%d]\n",tline); |
|---|
| 1960 | else |
|---|
| 1961 | #else |
|---|
| 1962 | if (tline == 0 || tline == 1) /* no wrn */ |
|---|
| 1963 | #endif |
|---|
| 1964 | printf("\n"); |
|---|
| 1965 | |
|---|
| 1966 | |
|---|
| 1967 | return(0); |
|---|
| 1968 | } |
|---|
| 1969 | #endif /* WWWISIS */ |
|---|
| 1970 | |
|---|
| 1971 | #if CICPP |
|---|
| 1972 | char * CIB7 :: b7_xlkey(char *opx,char *bufp,unsigned char uctab[],char *xlfilp,int *opxlp) |
|---|
| 1973 | #else |
|---|
| 1974 | char *b7_xlkey(cib7p,opx,bufp,uctab,xlfilp,opxlp) |
|---|
| 1975 | b7_CIB7 *cib7p; |
|---|
| 1976 | char *opx; |
|---|
| 1977 | char *bufp; |
|---|
| 1978 | unsigned char uctab[]; |
|---|
| 1979 | char *xlfilp; |
|---|
| 1980 | int *opxlp; |
|---|
| 1981 | #endif |
|---|
| 1982 | { |
|---|
| 1983 | unsigned char *p; |
|---|
| 1984 | int loop,newlen; |
|---|
| 1985 | #if TRACEXK |
|---|
| 1986 | printf("b7_xlkey - buf=%s (%d)\n",bufp,*opxlp); |
|---|
| 1987 | #endif |
|---|
| 1988 | if (xlfilp) fatal("b7_xlkey/xlfilp"); |
|---|
| 1989 | for (p=(unsigned char *)bufp, loop= *opxlp; loop--; p++) |
|---|
| 1990 | *p = uctab[*p]; |
|---|
| 1991 | newlen= *opxlp; |
|---|
| 1992 | if (newlen > LE2) if (newlen != LE2+2 || (*bufp != '\"' && bufp[newlen-1] != '\"')) |
|---|
| 1993 | newlen=LE2; |
|---|
| 1994 | memcpy(opx,bufp,newlen); |
|---|
| 1995 | opx[newlen]='\0'; |
|---|
| 1996 | *opxlp = newlen; |
|---|
| 1997 | return(opx); |
|---|
| 1998 | } |
|---|
| 1999 | |
|---|
| 2000 | #if CICPP |
|---|
| 2001 | LONGX CIB7::b7_hsizh(PDLSTRU *pdlp,LONGX *hsizp) |
|---|
| 2002 | #else |
|---|
| 2003 | LONGX b7_hsizh(cib7p,pdlp,hsizp) |
|---|
| 2004 | b7_CIB7 *cib7p; |
|---|
| 2005 | PDLSTRU *pdlp; |
|---|
| 2006 | LONGX *hsizp; |
|---|
| 2007 | #endif |
|---|
| 2008 | { |
|---|
| 2009 | LONGX hits,hsiz,loop,mfn,offset; |
|---|
| 2010 | int loop2; |
|---|
| 2011 | unsigned char *p1p; |
|---|
| 2012 | hits=0; hsiz=0; |
|---|
| 2013 | p1p=PDLlvel; |
|---|
| 2014 | for (mfn=0, loop=PDLsize; loop--; ) { |
|---|
| 2015 | offset=(mfn/8); |
|---|
| 2016 | if (!*(PDLlvel+offset)) { |
|---|
| 2017 | mfn+=8; |
|---|
| 2018 | continue; |
|---|
| 2019 | } |
|---|
| 2020 | for (loop2=8; loop2--; mfn++){ |
|---|
| 2021 | if( mfn > PDLlmfn ) |
|---|
| 2022 | break; |
|---|
| 2023 | if (*(p1p+offset) & bitmask[mfn&BY8RMASK]) { |
|---|
| 2024 | hits++; |
|---|
| 2025 | hsiz=mfn; |
|---|
| 2026 | #if MFNTRACE |
|---|
| 2027 | printf("%"_LD_" ",mfn); |
|---|
| 2028 | #endif |
|---|
| 2029 | } |
|---|
| 2030 | } |
|---|
| 2031 | } |
|---|
| 2032 | #if MFNTRACE |
|---|
| 2033 | printf("\n"); |
|---|
| 2034 | #endif |
|---|
| 2035 | *hsizp = hsiz; |
|---|
| 2036 | return(hits); |
|---|
| 2037 | } |
|---|
| 2038 | |
|---|
| 2039 | |
|---|
| 2040 | /* |
|---|
| 2041 | * <R> |
|---|
| 2042 | * funciones utilizadas desde _run() |
|---|
| 2043 | * </R> |
|---|
| 2044 | */ |
|---|
| 2045 | |
|---|
| 2046 | #if !LIND |
|---|
| 2047 | |
|---|
| 2048 | #if CICPP |
|---|
| 2049 | int CIB7::b7_cmp( char *op1, char *op2, int oplen ) |
|---|
| 2050 | #else |
|---|
| 2051 | int b7_cmp( cib7p,op1,op2,oplen ) |
|---|
| 2052 | b7_CIB7 *cib7p; |
|---|
| 2053 | char *op1; /* posting 1 */ |
|---|
| 2054 | char *op2; /* posting 2 */ |
|---|
| 2055 | int oplen; /* tamaño de los posting */ |
|---|
| 2056 | #endif |
|---|
| 2057 | { |
|---|
| 2058 | /* |
|---|
| 2059 | Return value |
|---|
| 2060 | >0 => op1 > op2 |
|---|
| 2061 | <0 => op1 < op2 |
|---|
| 2062 | 0 => op1 = op2 |
|---|
| 2063 | */ |
|---|
| 2064 | int res; |
|---|
| 2065 | int i; |
|---|
| 2066 | |
|---|
| 2067 | oplen = (oplen>3)?oplen:3; |
|---|
| 2068 | |
|---|
| 2069 | if (!op1 || !op2) fatal("cib72/b7_cmp/op1Xop2"); |
|---|
| 2070 | |
|---|
| 2071 | for( i = 0; i < oplen; i++ ){ |
|---|
| 2072 | res = ((int)(unsigned char)*(op1+i) - (unsigned char)*(op2+i)); |
|---|
| 2073 | if( res != 0 ) return res; |
|---|
| 2074 | } |
|---|
| 2075 | return 0; |
|---|
| 2076 | } |
|---|
| 2077 | |
|---|
| 2078 | #if CICPP |
|---|
| 2079 | int CIB7::b7_prox( char *op1, char* op2, short andl, LONGX dist ) |
|---|
| 2080 | #else |
|---|
| 2081 | int b7_prox( cib7p,op1,op2,andl,dist ) |
|---|
| 2082 | b7_CIB7 *cib7p; |
|---|
| 2083 | char *op1; |
|---|
| 2084 | char *op2; |
|---|
| 2085 | short andl; /* 4: oper . ; 5:oper $ */ |
|---|
| 2086 | LONGX dist; /* cant. de operadores. */ |
|---|
| 2087 | #endif |
|---|
| 2088 | { |
|---|
| 2089 | |
|---|
| 2090 | /* |
|---|
| 2091 | retorna 0 si no cumple la condicion de proximidad, |
|---|
| 2092 | dist de 0 en caso contrario. |
|---|
| 2093 | */ |
|---|
| 2094 | |
|---|
| 2095 | int res; |
|---|
| 2096 | short int cnt1, cnt2; |
|---|
| 2097 | |
|---|
| 2098 | if( b7_cmp( B7_THISP op1, op2, 6 ) ) |
|---|
| 2099 | return 0; |
|---|
| 2100 | |
|---|
| 2101 | cnt1 = (unsigned)*(op1+6); |
|---|
| 2102 | cnt1 = (cnt1<<8) + ((unsigned)*(op1+7)); |
|---|
| 2103 | |
|---|
| 2104 | cnt2 = (unsigned)*(op2+6); |
|---|
| 2105 | cnt2 = (cnt2<<8) + ((unsigned)*(op2+7)); |
|---|
| 2106 | |
|---|
| 2107 | switch( andl ){ |
|---|
| 2108 | case 4: |
|---|
| 2109 | res = ( abs( cnt1 - cnt2 ) <= dist ); |
|---|
| 2110 | break; |
|---|
| 2111 | case 5: |
|---|
| 2112 | res = ( abs( cnt1 - cnt2 ) == dist ); |
|---|
| 2113 | break; |
|---|
| 2114 | default: |
|---|
| 2115 | res = 0; |
|---|
| 2116 | } |
|---|
| 2117 | |
|---|
| 2118 | return res; |
|---|
| 2119 | |
|---|
| 2120 | } |
|---|
| 2121 | |
|---|
| 2122 | #if CICPP |
|---|
| 2123 | LONGX CIB7::b7_gmfn( char *str ) |
|---|
| 2124 | #else |
|---|
| 2125 | LONGX b7_gmfn( cib7p,str ) |
|---|
| 2126 | b7_CIB7 *cib7p; |
|---|
| 2127 | char *str; /*posting */ |
|---|
| 2128 | #endif |
|---|
| 2129 | { |
|---|
| 2130 | /* |
|---|
| 2131 | Calcula el MFN del posting almacenado. |
|---|
| 2132 | */ |
|---|
| 2133 | LONGX res; |
|---|
| 2134 | unsigned char mfn1, mfn2, mfn3; |
|---|
| 2135 | |
|---|
| 2136 | mfn1 = *str; |
|---|
| 2137 | mfn2 = *(str+1); |
|---|
| 2138 | mfn3 = *(str+2); |
|---|
| 2139 | |
|---|
| 2140 | res = (LONGX)(mfn1<<16) + (LONGX)(mfn2<<8) + (LONGX) mfn3; |
|---|
| 2141 | |
|---|
| 2142 | return res; |
|---|
| 2143 | } |
|---|
| 2144 | |
|---|
| 2145 | /* |
|---|
| 2146 | Funciones sobre la pila de ejecución, trabajan sobre las listas |
|---|
| 2147 | del tope y subtope de la pila |
|---|
| 2148 | */ |
|---|
| 2149 | |
|---|
| 2150 | |
|---|
| 2151 | /* logical or. */ |
|---|
| 2152 | #if CICPP |
|---|
| 2153 | void CIB7 :: b7_zorx() |
|---|
| 2154 | #else |
|---|
| 2155 | void b7_zorx(cib7p) |
|---|
| 2156 | b7_CIB7 *cib7p; |
|---|
| 2157 | #endif |
|---|
| 2158 | { |
|---|
| 2159 | /* |
|---|
| 2160 | recorrer las 2 listas de posting y crear una nueva |
|---|
| 2161 | almacenando ordenadamente los postings distintos entre si |
|---|
| 2162 | comparandolos en el nivel del resultado. |
|---|
| 2163 | */ |
|---|
| 2164 | char *op1, *op2, *cur, *lp; |
|---|
| 2165 | int reslen, oplen; |
|---|
| 2166 | int iop1, iop2; |
|---|
| 2167 | int cmpf; |
|---|
| 2168 | PDLSTRU *pdlp; |
|---|
| 2169 | LONGX offset; |
|---|
| 2170 | |
|---|
| 2171 | LONGX mfnx, lmfn; |
|---|
| 2172 | |
|---|
| 2173 | iop1 = vpdltop - 2; |
|---|
| 2174 | iop2 = vpdltop - 1; |
|---|
| 2175 | |
|---|
| 2176 | pdlp = vpdlp[ vpdltop ]; |
|---|
| 2177 | |
|---|
| 2178 | op1 = (char *)VPDLlvel( iop1 ); |
|---|
| 2179 | op2 = (char *)VPDLlvel( iop2 ); |
|---|
| 2180 | |
|---|
| 2181 | reslen = PDLplen; |
|---|
| 2182 | oplen = VPDLplen( iop1 ); |
|---|
| 2183 | |
|---|
| 2184 | lmfn = 0; |
|---|
| 2185 | |
|---|
| 2186 | lp=NULL; |
|---|
| 2187 | while( op1 != VPDLnxtp( iop1 ) || op2 != VPDLnxtp( iop2 ) ){ |
|---|
| 2188 | |
|---|
| 2189 | if( op1 == VPDLnxtp( iop1 ) ){ |
|---|
| 2190 | cur = op2; |
|---|
| 2191 | op2 += oplen; |
|---|
| 2192 | }else if( op2 == VPDLnxtp( iop2 ) ){ |
|---|
| 2193 | cur = op1; |
|---|
| 2194 | op1 += oplen; |
|---|
| 2195 | }else{ |
|---|
| 2196 | cmpf = b7_cmp( B7_THISP op1, op2, oplen ); |
|---|
| 2197 | |
|---|
| 2198 | if( cmpf <= 0 ){ |
|---|
| 2199 | cur = op1; |
|---|
| 2200 | op1 += oplen; |
|---|
| 2201 | if( !cmpf ){ |
|---|
| 2202 | op2 += oplen; |
|---|
| 2203 | } |
|---|
| 2204 | }else{ |
|---|
| 2205 | cur = op2; |
|---|
| 2206 | op2 += oplen; |
|---|
| 2207 | } |
|---|
| 2208 | } |
|---|
| 2209 | |
|---|
| 2210 | /*cur esta en el menor de los posting restantes. */ |
|---|
| 2211 | mfnx = b7_gmfn( B7_THISP cur ); |
|---|
| 2212 | |
|---|
| 2213 | if( ( !PDLdocs || ( b7_cmp( B7_THISP cur, lp, reslen ) ) != 0 ) ){ |
|---|
| 2214 | /*no hemos almacenado ninguno o cur apunta a un posting */ |
|---|
| 2215 | /*distinto del último almacenado. */ |
|---|
| 2216 | |
|---|
| 2217 | if( PDLplen ){ |
|---|
| 2218 | b7_copy( B7_THISP pdlp, cur ); |
|---|
| 2219 | }else{ |
|---|
| 2220 | offset = (mfnx/8); |
|---|
| 2221 | mask=bitmask[mfnx&BY8RMASK]; |
|---|
| 2222 | PDLlvel[offset] |= mask; |
|---|
| 2223 | } |
|---|
| 2224 | lp = cur; |
|---|
| 2225 | } |
|---|
| 2226 | |
|---|
| 2227 | if( !lmfn || lmfn != mfnx ){ |
|---|
| 2228 | /*es el primer posting o */ |
|---|
| 2229 | /*tiene mfn distinta del último almacenado. */ |
|---|
| 2230 | |
|---|
| 2231 | PDLdocs++; |
|---|
| 2232 | lmfn = mfnx; |
|---|
| 2233 | } |
|---|
| 2234 | } |
|---|
| 2235 | |
|---|
| 2236 | /*cambiar el tope de la pila con el 3er nivel. */ |
|---|
| 2237 | b7_xpdl( B7_THISP npdls-1, npdls-3); |
|---|
| 2238 | b7_pop(B7_THIS); |
|---|
| 2239 | b7_pop(B7_THIS); |
|---|
| 2240 | |
|---|
| 2241 | } |
|---|
| 2242 | |
|---|
| 2243 | /*logical and, oper (G) and oper (F) */ |
|---|
| 2244 | #if CICPP |
|---|
| 2245 | void CIB7::b7_zand( short andl ) |
|---|
| 2246 | #else |
|---|
| 2247 | void b7_zand( cib7p, andl ) |
|---|
| 2248 | b7_CIB7 *cib7p; |
|---|
| 2249 | short andl; /* 1: *; 2: (G); 3: (F) */ |
|---|
| 2250 | #endif |
|---|
| 2251 | { |
|---|
| 2252 | /* |
|---|
| 2253 | recorrer las 2 listas hasta qeu una de ellas termine, |
|---|
| 2254 | creanndo una nueva con los posting qeu se encuentran en ambas. |
|---|
| 2255 | */ |
|---|
| 2256 | char *op1, *op2, *cur, *lp; |
|---|
| 2257 | int reslen, oplen, andlen; |
|---|
| 2258 | int iop1, iop2; |
|---|
| 2259 | int cmpf; |
|---|
| 2260 | PDLSTRU *pdlp; |
|---|
| 2261 | LONGX offset; |
|---|
| 2262 | |
|---|
| 2263 | LONGX mfnx, lmfn; |
|---|
| 2264 | |
|---|
| 2265 | iop1 = vpdltop - 2; |
|---|
| 2266 | iop2 = vpdltop - 1; |
|---|
| 2267 | |
|---|
| 2268 | pdlp = vpdlp[ vpdltop ]; |
|---|
| 2269 | |
|---|
| 2270 | op1 = (char *)VPDLlvel( iop1 ); |
|---|
| 2271 | op2 = (char *)VPDLlvel( iop2 ); |
|---|
| 2272 | |
|---|
| 2273 | reslen = PDLplen; |
|---|
| 2274 | oplen = VPDLplen( iop1 ); |
|---|
| 2275 | |
|---|
| 2276 | switch( andl ){ |
|---|
| 2277 | case 2: andlen = 5; break; |
|---|
| 2278 | case 3: andlen = 6; break; |
|---|
| 2279 | default: andlen = 3; |
|---|
| 2280 | } |
|---|
| 2281 | |
|---|
| 2282 | lmfn = 0; |
|---|
| 2283 | lp = 0; |
|---|
| 2284 | |
|---|
| 2285 | |
|---|
| 2286 | while( op1 != VPDLnxtp( iop1 ) && op2 != VPDLnxtp( iop2 ) ){ |
|---|
| 2287 | |
|---|
| 2288 | cur = 0; |
|---|
| 2289 | cmpf = b7_cmp( B7_THISP op1, op2, andlen ); |
|---|
| 2290 | if( cmpf < 0 ){ |
|---|
| 2291 | if( lp && !b7_cmp( B7_THISP op1, lp, andlen ) ){ |
|---|
| 2292 | cur = op1; |
|---|
| 2293 | } |
|---|
| 2294 | op1 += oplen; |
|---|
| 2295 | }else if( cmpf > 0 ){ |
|---|
| 2296 | if( lp && !b7_cmp( B7_THISP op2, lp, andlen ) ){ |
|---|
| 2297 | cur = op2; |
|---|
| 2298 | } |
|---|
| 2299 | op2 += oplen; |
|---|
| 2300 | }else{ |
|---|
| 2301 | cmpf = b7_cmp( B7_THISP op1, op2, oplen ); |
|---|
| 2302 | if( cmpf <= 0 ){ |
|---|
| 2303 | cur = op1; |
|---|
| 2304 | op1 += oplen; |
|---|
| 2305 | if( !cmpf ) |
|---|
| 2306 | op2 += oplen; |
|---|
| 2307 | }else{ |
|---|
| 2308 | cur = op2; |
|---|
| 2309 | op2 += oplen; |
|---|
| 2310 | } |
|---|
| 2311 | } |
|---|
| 2312 | |
|---|
| 2313 | if( cur ){ |
|---|
| 2314 | mfnx = b7_gmfn( B7_THISP cur ); |
|---|
| 2315 | |
|---|
| 2316 | if( !PDLdocs || ( b7_cmp( B7_THISP cur, lp, reslen ) ) != 0 ){ |
|---|
| 2317 | |
|---|
| 2318 | if( PDLplen ){ |
|---|
| 2319 | b7_copy( B7_THISP pdlp, cur ); |
|---|
| 2320 | }else{ |
|---|
| 2321 | offset = (mfnx/8); |
|---|
| 2322 | mask=bitmask[mfnx&BY8RMASK]; |
|---|
| 2323 | PDLlvel[offset] |= mask; |
|---|
| 2324 | } |
|---|
| 2325 | lp = cur; |
|---|
| 2326 | } |
|---|
| 2327 | |
|---|
| 2328 | if( !lmfn || lmfn != mfnx ){ |
|---|
| 2329 | PDLdocs++; |
|---|
| 2330 | lmfn = mfnx; |
|---|
| 2331 | } |
|---|
| 2332 | } |
|---|
| 2333 | } |
|---|
| 2334 | |
|---|
| 2335 | b7_xpdl( B7_THISP npdls-1, npdls-3); |
|---|
| 2336 | b7_pop(B7_THIS); |
|---|
| 2337 | b7_pop(B7_THIS); |
|---|
| 2338 | |
|---|
| 2339 | |
|---|
| 2340 | } |
|---|
| 2341 | |
|---|
| 2342 | /*logical not. */ |
|---|
| 2343 | #if CICPP |
|---|
| 2344 | void CIB7::b7_zann() |
|---|
| 2345 | #else |
|---|
| 2346 | void b7_zann( cib7p ) |
|---|
| 2347 | b7_CIB7 *cib7p; |
|---|
| 2348 | #endif |
|---|
| 2349 | { |
|---|
| 2350 | |
|---|
| 2351 | /* |
|---|
| 2352 | Por cada elemento de la lista 1, incluirlo en la lista de resultados |
|---|
| 2353 | sino se encuentra en la lista 2. |
|---|
| 2354 | */ |
|---|
| 2355 | |
|---|
| 2356 | char *op1, *op2, *cur, *lp, *tmp; |
|---|
| 2357 | int reslen, oplen; |
|---|
| 2358 | int iop1, iop2; |
|---|
| 2359 | int cmpf; |
|---|
| 2360 | PDLSTRU *pdlp; |
|---|
| 2361 | LONGX offset; |
|---|
| 2362 | |
|---|
| 2363 | LONGX mfnx, lmfn; |
|---|
| 2364 | |
|---|
| 2365 | iop1 = vpdltop - 2; |
|---|
| 2366 | iop2 = vpdltop - 1; |
|---|
| 2367 | |
|---|
| 2368 | pdlp = vpdlp[ vpdltop ]; |
|---|
| 2369 | |
|---|
| 2370 | op1 = (char *)VPDLlvel( iop1 ); |
|---|
| 2371 | op2 = (char *)VPDLlvel( iop2 ); |
|---|
| 2372 | |
|---|
| 2373 | reslen = PDLplen; |
|---|
| 2374 | oplen = VPDLplen( iop1 ); |
|---|
| 2375 | |
|---|
| 2376 | |
|---|
| 2377 | lp=NULL; lmfn=0; |
|---|
| 2378 | while( op1 != VPDLnxtp( iop1 ) ){ |
|---|
| 2379 | cur = 0; |
|---|
| 2380 | cmpf = b7_cmp( B7_THISP op1, op2, 3 ); |
|---|
| 2381 | if( cmpf < 0 ){ |
|---|
| 2382 | cur = op1; |
|---|
| 2383 | op1 += oplen; |
|---|
| 2384 | }else if( cmpf > 0 ){ |
|---|
| 2385 | op2 += oplen; |
|---|
| 2386 | }else{ |
|---|
| 2387 | tmp = op1; |
|---|
| 2388 | while( !b7_cmp( B7_THISP tmp, op1, 3 ) ) |
|---|
| 2389 | op1 += oplen; |
|---|
| 2390 | |
|---|
| 2391 | tmp = op2; |
|---|
| 2392 | while( !b7_cmp( B7_THISP tmp, op2, 3 ) ) |
|---|
| 2393 | op2 += oplen; |
|---|
| 2394 | } |
|---|
| 2395 | |
|---|
| 2396 | if( cur ){ |
|---|
| 2397 | mfnx = b7_gmfn( B7_THISP cur ); |
|---|
| 2398 | |
|---|
| 2399 | if( !PDLdocs || ( b7_cmp( B7_THISP cur, lp, reslen ) ) != 0 ){ |
|---|
| 2400 | |
|---|
| 2401 | if( PDLplen ){ |
|---|
| 2402 | b7_copy( B7_THISP pdlp, cur ); |
|---|
| 2403 | }else{ |
|---|
| 2404 | offset = (mfnx/8); |
|---|
| 2405 | mask=bitmask[mfnx&BY8RMASK]; |
|---|
| 2406 | PDLlvel[offset] |= mask; |
|---|
| 2407 | } |
|---|
| 2408 | lp = cur; |
|---|
| 2409 | } |
|---|
| 2410 | |
|---|
| 2411 | if( !lmfn || lmfn != mfnx ){ |
|---|
| 2412 | PDLdocs++; |
|---|
| 2413 | lmfn = mfnx; |
|---|
| 2414 | } |
|---|
| 2415 | } |
|---|
| 2416 | |
|---|
| 2417 | } |
|---|
| 2418 | |
|---|
| 2419 | |
|---|
| 2420 | b7_xpdl( B7_THISP npdls-1, npdls-3); |
|---|
| 2421 | b7_pop(B7_THIS); |
|---|
| 2422 | b7_pop(B7_THIS); |
|---|
| 2423 | |
|---|
| 2424 | |
|---|
| 2425 | } |
|---|
| 2426 | |
|---|
| 2427 | /*proximidad. */ |
|---|
| 2428 | #if CICPP |
|---|
| 2429 | void CIB7::b7_zanp( short andl, unsigned char b7qty ) |
|---|
| 2430 | #else |
|---|
| 2431 | void b7_zanp( cib7p,andl,b7qty ) |
|---|
| 2432 | b7_CIB7 *cib7p; |
|---|
| 2433 | short andl; /*4: .; 5: $ */ |
|---|
| 2434 | unsigned char b7qty; |
|---|
| 2435 | #endif |
|---|
| 2436 | { |
|---|
| 2437 | /* |
|---|
| 2438 | Por cada elemento de la lista 1 |
|---|
| 2439 | si existe elemento en la lista 2 que cumpla condicion de proximidad |
|---|
| 2440 | adicionarlos a ambos en el resultado ( si son distintos en el nivel del resultado ) |
|---|
| 2441 | */ |
|---|
| 2442 | char *op1, *op2, *lp; |
|---|
| 2443 | int oplen; |
|---|
| 2444 | int iop1, iop2; |
|---|
| 2445 | int cmpf; |
|---|
| 2446 | PDLSTRU *pdlp; |
|---|
| 2447 | LONGX offset; |
|---|
| 2448 | |
|---|
| 2449 | LONGX mfnx, lmfn; |
|---|
| 2450 | short dist; |
|---|
| 2451 | |
|---|
| 2452 | //HB dist = atoi((const char *) &b7qty ); |
|---|
| 2453 | dist = (short)b7qty; |
|---|
| 2454 | |
|---|
| 2455 | iop1 = vpdltop - 2; |
|---|
| 2456 | iop2 = vpdltop - 1; |
|---|
| 2457 | |
|---|
| 2458 | pdlp = vpdlp[ vpdltop ]; |
|---|
| 2459 | |
|---|
| 2460 | op1 = (char *)VPDLlvel( iop1 ); |
|---|
| 2461 | op2 = (char *)VPDLlvel( iop2 ); |
|---|
| 2462 | |
|---|
| 2463 | oplen = VPDLplen( iop1 ); |
|---|
| 2464 | |
|---|
| 2465 | lmfn = 0; |
|---|
| 2466 | lp = 0; |
|---|
| 2467 | |
|---|
| 2468 | while( op1 != VPDLnxtp( iop1 ) ){ |
|---|
| 2469 | cmpf = b7_cmp( B7_THISP op1, op2, 6 ); |
|---|
| 2470 | if( cmpf < 0 ){ |
|---|
| 2471 | op1 += oplen; |
|---|
| 2472 | op2 = (char *)VPDLlvel( iop2 ); |
|---|
| 2473 | }else if( cmpf > 0 ){ |
|---|
| 2474 | op2 += oplen; |
|---|
| 2475 | }else{ |
|---|
| 2476 | if( b7_prox( B7_THISP op1, op2, andl, dist) ){ |
|---|
| 2477 | mfnx = b7_gmfn( B7_THISP op1 ); |
|---|
| 2478 | if( !PDLplen ){ |
|---|
| 2479 | offset = (mfnx/8); |
|---|
| 2480 | mask=bitmask[mfnx&BY8RMASK]; |
|---|
| 2481 | PDLlvel[offset] |= mask; |
|---|
| 2482 | }else if( PDLplen < 7 ){ |
|---|
| 2483 | if( !lp || b7_cmp( B7_THISP op1, lp, PDLplen ) ){ |
|---|
| 2484 | b7_copy( B7_THISP pdlp, op1 ); |
|---|
| 2485 | lp = op1; |
|---|
| 2486 | } |
|---|
| 2487 | }else{ |
|---|
| 2488 | cmpf = b7_cmp( B7_THISP op1, op2, PDLplen ); |
|---|
| 2489 | if( cmpf <= 0 ){ |
|---|
| 2490 | b7_inst( B7_THISP pdlp, op1 ); |
|---|
| 2491 | b7_inst( B7_THISP pdlp, op2 ); |
|---|
| 2492 | if( !lp || b7_cmp( B7_THISP op2, lp, PDLplen ) > 0 ) |
|---|
| 2493 | lp = op2; |
|---|
| 2494 | }else{ |
|---|
| 2495 | b7_inst( B7_THISP pdlp, op2 ); |
|---|
| 2496 | b7_inst( B7_THISP pdlp, op1 ); |
|---|
| 2497 | if( !lp || b7_cmp( B7_THISP op1, lp, PDLplen ) > 0 ) |
|---|
| 2498 | lp = op1; |
|---|
| 2499 | } |
|---|
| 2500 | } |
|---|
| 2501 | if( !lmfn || lmfn != mfnx ){ |
|---|
| 2502 | PDLdocs++; |
|---|
| 2503 | lmfn = mfnx; |
|---|
| 2504 | } |
|---|
| 2505 | } |
|---|
| 2506 | op2 += oplen; |
|---|
| 2507 | } |
|---|
| 2508 | } |
|---|
| 2509 | b7_xpdl( B7_THISP npdls-1, npdls-3); |
|---|
| 2510 | b7_pop(B7_THIS); |
|---|
| 2511 | b7_pop(B7_THIS); |
|---|
| 2512 | |
|---|
| 2513 | } |
|---|
| 2514 | |
|---|
| 2515 | |
|---|
| 2516 | #if CICPP |
|---|
| 2517 | void CIB7::b7_copy( PDLSTRU *pdlp, char *src ) |
|---|
| 2518 | #else |
|---|
| 2519 | void b7_copy(cib7p,pdlp,src ) |
|---|
| 2520 | b7_CIB7 *cib7p; |
|---|
| 2521 | PDLSTRU *pdlp; |
|---|
| 2522 | char *src; |
|---|
| 2523 | #endif |
|---|
| 2524 | { |
|---|
| 2525 | /* |
|---|
| 2526 | adicionar un posting en el pdllvel del pdlp, siempre al final. |
|---|
| 2527 | */ |
|---|
| 2528 | |
|---|
| 2529 | LONGX offset; |
|---|
| 2530 | if( !PDLleft ){ |
|---|
| 2531 | #if BEFORE20020319 |
|---|
| 2532 | offset = (UCHR *)PDLnxtp - PDLlvel; |
|---|
| 2533 | PDLlvel = (unsigned char *)realloc( PDLlvel, PDLsize+PDLisiz ); |
|---|
| 2534 | if( !PDLlvel ) |
|---|
| 2535 | fatal( "cib72/b7_copy/realloc" ); |
|---|
| 2536 | |
|---|
| 2537 | PDLsize += PDLisiz; |
|---|
| 2538 | PDLnxtp = (char *)(PDLlvel+offset); |
|---|
| 2539 | memset( PDLnxtp, 0x00, PDLisiz ); |
|---|
| 2540 | #else |
|---|
| 2541 | UCHR *newlvel; |
|---|
| 2542 | |
|---|
| 2543 | /* |
|---|
| 2544 | offset = (UCHR *)PDLnxtp - PDLlvel; |
|---|
| 2545 | */ |
|---|
| 2546 | offset = PDLsize; |
|---|
| 2547 | |
|---|
| 2548 | #if CICPP |
|---|
| 2549 | newlvel = (UCHR*)new char[(ALLOPARM)(PDLsize+PDLisiz)]; |
|---|
| 2550 | #else /* CICPP */ |
|---|
| 2551 | newlvel = (UCHR*)ALLOC((ALLOPARM)(PDLsize+PDLisiz)); |
|---|
| 2552 | #endif /* CICPP */ |
|---|
| 2553 | if( !newlvel ) |
|---|
| 2554 | fatal( "cib72/b7_addk/realloc" ); |
|---|
| 2555 | memset( newlvel, 0x00, PDLsize+PDLisiz ); |
|---|
| 2556 | memcpy( newlvel, PDLlvel, PDLsize ); |
|---|
| 2557 | #if CICPP |
|---|
| 2558 | delete[] PDLlvel; |
|---|
| 2559 | #else /* CICPP */ |
|---|
| 2560 | FREE( PDLlvel ); |
|---|
| 2561 | #endif /* CICPP */ |
|---|
| 2562 | PDLlvel = newlvel; |
|---|
| 2563 | PDLsize += PDLisiz; |
|---|
| 2564 | PDLnxtp = (char *)(PDLlvel+offset); |
|---|
| 2565 | PDLleft = PDLisiz; |
|---|
| 2566 | #endif |
|---|
| 2567 | } |
|---|
| 2568 | |
|---|
| 2569 | memcpy( PDLnxtp, src, PDLplen ); |
|---|
| 2570 | |
|---|
| 2571 | PDLleft-= PDLplen; |
|---|
| 2572 | PDLnxtp += PDLplen; |
|---|
| 2573 | } |
|---|
| 2574 | |
|---|
| 2575 | #if CICPP |
|---|
| 2576 | void CIB7::b7_inst( PDLSTRU *pdlp, char *src ) |
|---|
| 2577 | #else |
|---|
| 2578 | void b7_inst( cib7p,pdlp,src ) |
|---|
| 2579 | b7_CIB7 *cib7p; |
|---|
| 2580 | PDLSTRU *pdlp; |
|---|
| 2581 | char *src; |
|---|
| 2582 | #endif |
|---|
| 2583 | { |
|---|
| 2584 | /* |
|---|
| 2585 | Adicionar un posting en el pdllvel del pdlp, pero ordenado. |
|---|
| 2586 | */ |
|---|
| 2587 | |
|---|
| 2588 | LONGX offset; |
|---|
| 2589 | char *cur; |
|---|
| 2590 | |
|---|
| 2591 | if( PDLlvel == (unsigned char *)PDLnxtp ){ |
|---|
| 2592 | b7_copy( B7_THISP pdlp, src ); |
|---|
| 2593 | return; |
|---|
| 2594 | } |
|---|
| 2595 | |
|---|
| 2596 | if( !PDLleft ){ |
|---|
| 2597 | #if BEFORE20020319 |
|---|
| 2598 | offset = (UCHR *)PDLnxtp - PDLlvel; |
|---|
| 2599 | PDLlvel = (unsigned char *)realloc( PDLlvel, PDLsize+PDLisiz ); |
|---|
| 2600 | if( !PDLlvel ) |
|---|
| 2601 | fatal( "cib72/b7_copy/realloc" ); |
|---|
| 2602 | |
|---|
| 2603 | PDLsize += PDLisiz; |
|---|
| 2604 | PDLnxtp = (char *)(PDLlvel+offset); |
|---|
| 2605 | memset( PDLnxtp, 0x00, PDLisiz ); |
|---|
| 2606 | #else |
|---|
| 2607 | UCHR *newlvel; |
|---|
| 2608 | |
|---|
| 2609 | /* |
|---|
| 2610 | offset = (UCHR *)PDLnxtp - PDLlvel; |
|---|
| 2611 | */ |
|---|
| 2612 | offset = PDLsize; |
|---|
| 2613 | |
|---|
| 2614 | #if CICPP |
|---|
| 2615 | newlvel = (UCHR*)new char[(ALLOPARM)(PDLsize+PDLisiz)]; |
|---|
| 2616 | #else /* CICPP */ |
|---|
| 2617 | newlvel = (UCHR*)ALLOC((ALLOPARM)(PDLsize+PDLisiz)); |
|---|
| 2618 | #endif /* CICPP */ |
|---|
| 2619 | if( !newlvel ) |
|---|
| 2620 | fatal( "cib72/b7_addk/realloc" ); |
|---|
| 2621 | memset( newlvel, 0x00, PDLsize+PDLisiz ); |
|---|
| 2622 | memcpy( newlvel, PDLlvel, PDLsize ); |
|---|
| 2623 | #if CICPP |
|---|
| 2624 | delete[] PDLlvel; |
|---|
| 2625 | #else /* CICPP */ |
|---|
| 2626 | FREE( PDLlvel ); |
|---|
| 2627 | #endif /* CICPP */ |
|---|
| 2628 | PDLlvel = newlvel; |
|---|
| 2629 | PDLsize += PDLisiz; |
|---|
| 2630 | PDLnxtp = (char *)(PDLlvel+offset); |
|---|
| 2631 | PDLleft = PDLisiz; |
|---|
| 2632 | #endif |
|---|
| 2633 | } |
|---|
| 2634 | |
|---|
| 2635 | cur = PDLnxtp; |
|---|
| 2636 | |
|---|
| 2637 | while( cur-PDLplen != (char *)PDLlvel && b7_cmp( B7_THISP cur-PDLplen, src, PDLplen ) > 0 ){ |
|---|
| 2638 | cur -= PDLplen; |
|---|
| 2639 | } |
|---|
| 2640 | |
|---|
| 2641 | if( !b7_cmp( B7_THISP cur-PDLplen, src, PDLplen ) ) |
|---|
| 2642 | return; |
|---|
| 2643 | |
|---|
| 2644 | if( cur != PDLnxtp ) |
|---|
| 2645 | memmove( cur, cur+PDLplen, PDLnxtp-cur ); |
|---|
| 2646 | |
|---|
| 2647 | memcpy( cur, src, PDLplen ); |
|---|
| 2648 | |
|---|
| 2649 | PDLleft-=PDLplen; |
|---|
| 2650 | PDLnxtp += PDLplen; |
|---|
| 2651 | } |
|---|
| 2652 | |
|---|
| 2653 | #if CICPP |
|---|
| 2654 | void CIB7::b7_addk( PDLSTRU *pdlp, TRMSTRU *trmp ) |
|---|
| 2655 | #else |
|---|
| 2656 | void b7_addk( cib7p,pdlp,trmp ) |
|---|
| 2657 | b7_CIB7 *cib7p; |
|---|
| 2658 | PDLSTRU *pdlp; |
|---|
| 2659 | TRMSTRU *trmp; |
|---|
| 2660 | #endif |
|---|
| 2661 | { |
|---|
| 2662 | /* |
|---|
| 2663 | Adicionar un posting al final del pdllvel del pdlp, |
|---|
| 2664 | partiendo de la información del trmp. |
|---|
| 2665 | */ |
|---|
| 2666 | |
|---|
| 2667 | LONGX offset; |
|---|
| 2668 | char *p; |
|---|
| 2669 | LONGX pmfn; |
|---|
| 2670 | UWORD ptag, pocc, pcnt; |
|---|
| 2671 | |
|---|
| 2672 | if( !PDLplen ) return; |
|---|
| 2673 | |
|---|
| 2674 | if( !PDLleft ){ |
|---|
| 2675 | #if BEFORE20020319 |
|---|
| 2676 | offset = (UCHR *)PDLnxtp - PDLlvel; |
|---|
| 2677 | PDLlvel = (unsigned char *)realloc( PDLlvel, PDLsize+PDLisiz ); |
|---|
| 2678 | if( !PDLlvel ) |
|---|
| 2679 | fatal( "cib72/b7_copy/realloc" ); |
|---|
| 2680 | |
|---|
| 2681 | PDLsize += PDLisiz; |
|---|
| 2682 | PDLnxtp = (char *)(PDLlvel+offset); |
|---|
| 2683 | memset( PDLnxtp, 0x00, PDLisiz ); |
|---|
| 2684 | #else |
|---|
| 2685 | UCHR *newlvel; |
|---|
| 2686 | |
|---|
| 2687 | /* |
|---|
| 2688 | offset = (UCHR *)PDLnxtp - PDLlvel; |
|---|
| 2689 | */ |
|---|
| 2690 | offset = PDLsize; |
|---|
| 2691 | |
|---|
| 2692 | #if CICPP |
|---|
| 2693 | newlvel = (UCHR*)new char[(ALLOPARM)(PDLsize+PDLisiz)]; |
|---|
| 2694 | #else /* CICPP */ |
|---|
| 2695 | newlvel = (UCHR*)ALLOC((ALLOPARM)(PDLsize+PDLisiz)); |
|---|
| 2696 | #endif /* CICPP */ |
|---|
| 2697 | if( !newlvel ) |
|---|
| 2698 | fatal( "cib72/b7_addk/realloc" ); |
|---|
| 2699 | memset( newlvel, 0x00, PDLsize+PDLisiz ); |
|---|
| 2700 | memcpy( newlvel, PDLlvel, PDLsize ); |
|---|
| 2701 | #if CICPP |
|---|
| 2702 | delete[] PDLlvel; |
|---|
| 2703 | #else /* CICPP */ |
|---|
| 2704 | FREE( PDLlvel ); |
|---|
| 2705 | #endif /* CICPP */ |
|---|
| 2706 | PDLlvel = newlvel; |
|---|
| 2707 | PDLsize += PDLisiz; |
|---|
| 2708 | PDLnxtp = (char *)(PDLlvel+offset); |
|---|
| 2709 | PDLleft = PDLisiz; |
|---|
| 2710 | #endif |
|---|
| 2711 | } |
|---|
| 2712 | |
|---|
| 2713 | p = PDLnxtp; |
|---|
| 2714 | |
|---|
| 2715 | pmfn = TRMpmfn; |
|---|
| 2716 | |
|---|
| 2717 | *p= (pmfn>>16)&0xFF; |
|---|
| 2718 | *(p+1)=(pmfn>>8)&0xFF; |
|---|
| 2719 | *(p+2)= (pmfn)&0xFF; |
|---|
| 2720 | |
|---|
| 2721 | |
|---|
| 2722 | ptag = TRMptag; |
|---|
| 2723 | |
|---|
| 2724 | p += 3; |
|---|
| 2725 | *p = (ptag>>8)&0xFF; |
|---|
| 2726 | *(p+1)=ptag & 0xFF; |
|---|
| 2727 | |
|---|
| 2728 | |
|---|
| 2729 | if( PDLplen > 5 ){ |
|---|
| 2730 | pocc = TRMpocc; |
|---|
| 2731 | p+=2; |
|---|
| 2732 | *p = pocc; |
|---|
| 2733 | } |
|---|
| 2734 | |
|---|
| 2735 | if( PDLplen > 6 ){ |
|---|
| 2736 | pcnt = TRMpcnt; |
|---|
| 2737 | p+=1; |
|---|
| 2738 | *p = (pcnt>>8)&0xFF; |
|---|
| 2739 | *(p+1) = pcnt & 0xFF; |
|---|
| 2740 | } |
|---|
| 2741 | |
|---|
| 2742 | PDLleft-=PDLplen; |
|---|
| 2743 | PDLnxtp += PDLplen; |
|---|
| 2744 | |
|---|
| 2745 | } |
|---|
| 2746 | |
|---|
| 2747 | #endif /* !LIND */ |
|---|
| 2748 | |
|---|
| 2749 | /*utilidades para mostrar el contenido de la pila de ejecución */ |
|---|
| 2750 | #if CICPP |
|---|
| 2751 | void CIB7::b7_print( char *str, short int len ) |
|---|
| 2752 | #else |
|---|
| 2753 | void b7_print( cib7p,str, len ) |
|---|
| 2754 | b7_CIB7 *cib7p; |
|---|
| 2755 | char *str; |
|---|
| 2756 | short int len; |
|---|
| 2757 | #endif |
|---|
| 2758 | { |
|---|
| 2759 | LONGX val; |
|---|
| 2760 | |
|---|
| 2761 | val=(unsigned char)*str; |
|---|
| 2762 | val=(val<<16)+(*(str+1)<<8)+(unsigned char)(*(str+2)); |
|---|
| 2763 | |
|---|
| 2764 | printf( "mfn: %u", val ); |
|---|
| 2765 | |
|---|
| 2766 | val=(unsigned char)*(str+3); |
|---|
| 2767 | val=(val<<8)+(unsigned char)(*(str+4)); |
|---|
| 2768 | printf( ", tag: %u", val ); |
|---|
| 2769 | |
|---|
| 2770 | if( len > 5 ){ |
|---|
| 2771 | val = (unsigned char)*(str+5); |
|---|
| 2772 | printf( ", occ: %u", val ); |
|---|
| 2773 | } |
|---|
| 2774 | |
|---|
| 2775 | if( len > 6 ){ |
|---|
| 2776 | val=(unsigned char)*(str+6); |
|---|
| 2777 | val=(val<<8)+(unsigned char)(*(str+7)); |
|---|
| 2778 | printf( ", cnt: %u", val ); |
|---|
| 2779 | } |
|---|
| 2780 | |
|---|
| 2781 | } |
|---|
| 2782 | |
|---|
| 2783 | #if CICPP |
|---|
| 2784 | void CIB7::b7_showpdl() |
|---|
| 2785 | #else |
|---|
| 2786 | void b7_showpdl( cib7p ) |
|---|
| 2787 | b7_CIB7 *cib7p; |
|---|
| 2788 | #endif |
|---|
| 2789 | { |
|---|
| 2790 | LONGX i; |
|---|
| 2791 | PDLSTRU *pdlp; |
|---|
| 2792 | char *str; |
|---|
| 2793 | LONGX mfn, offset, hits; |
|---|
| 2794 | |
|---|
| 2795 | printf( "%d levels\n", npdls ); |
|---|
| 2796 | |
|---|
| 2797 | for( i = 0; i < npdls; i++ ){ |
|---|
| 2798 | pdlp = vpdlp[i]; |
|---|
| 2799 | printf( "\tlevel:%i\n", i ); |
|---|
| 2800 | printf( "lvel: %d, nxtp: %d\n", (int)PDLlvel, PDLnxtp ); |
|---|
| 2801 | printf( "size: %d, plen: %d,docs: %d, lvel:\n", PDLsize, PDLplen, PDLdocs ); |
|---|
| 2802 | if( PDLplen ){ |
|---|
| 2803 | str = (char *)PDLlvel; |
|---|
| 2804 | while( str != PDLnxtp ){ |
|---|
| 2805 | b7_print( B7_THISP str, PDLplen ); |
|---|
| 2806 | str += PDLplen; |
|---|
| 2807 | printf( "\n" ); |
|---|
| 2808 | } |
|---|
| 2809 | }else{ |
|---|
| 2810 | for( mfn=1, hits=0; mfn<=PDLlmfn && hits < PDLdocs; mfn++ ){ |
|---|
| 2811 | offset = (mfn/8); |
|---|
| 2812 | mask=bitmask[mfn&BY8RMASK]; |
|---|
| 2813 | if( PDLlvel[offset] & mask ){ |
|---|
| 2814 | printf( "%d | ", mfn ); |
|---|
| 2815 | hits++; |
|---|
| 2816 | } |
|---|
| 2817 | } |
|---|
| 2818 | } |
|---|
| 2819 | printf( "\n" ); |
|---|
| 2820 | } |
|---|
| 2821 | fflush( stdout ); |
|---|
| 2822 | |
|---|
| 2823 | } |
|---|
| 2824 | |
|---|
| 2825 | #if CICPP |
|---|
| 2826 | CIB7::CIB7(CISISX *parm_cisisxp) { |
|---|
| 2827 | cisisxp = parm_cisisxp; |
|---|
| 2828 | |
|---|
| 2829 | b70trace=0; /* ja' esta' inicializada em cidbx/cisisx */ |
|---|
| 2830 | and2gf=0; /* AOT&RP 28/05/98 */ |
|---|
| 2831 | subst_and=NULL; /* RP 29/05/98 */ |
|---|
| 2832 | b7_gidbnp=NULL; /* dbn.par */ |
|---|
| 2833 | b7fd=0; /* open() - 06/03/95 */ |
|---|
| 2834 | b7bufferp = NULL; /* b7_run() processing buffer */ |
|---|
| 2835 | b7_pfxmdl=0; |
|---|
| 2836 | b7error=0; |
|---|
| 2837 | b7rootmsg=OFF; |
|---|
| 2838 | } |
|---|
| 2839 | #endif |
|---|