| 1 | #include <stdio.h> |
|---|
| 2 | #include <string.h> |
|---|
| 3 | #include "cisis.h" |
|---|
| 4 | |
|---|
| 5 | #if CICPP |
|---|
| 6 | #include <cirec.hpp> |
|---|
| 7 | #define CIREC_SOURCE |
|---|
| 8 | #include <cirun.hpp> |
|---|
| 9 | /* ------------------------- CIREC.HPP --------------------------------- */ |
|---|
| 10 | #define recallok(irec,nbytes) xrecalloc(nbytes) /* internal use */ |
|---|
| 11 | #define record(irec,dbnamp,mfn) xrecord(dbnamp,mfn) /* internal use */ |
|---|
| 12 | #define recread(recp,mfn) xrecread(mfn) /* internal use */ |
|---|
| 13 | #define recxref(recp,mfn,comb,comp) xrecxref(mfn,comb,comp) /* internal use */ |
|---|
| 14 | #define nocc(irec,tag) xnocc(tag) /* internal use */ |
|---|
| 15 | #define fieldn(irec,tag,occ) xfieldn(tag,occ) /* internal use */ |
|---|
| 16 | #define fieldx(irec,tag,occ) xfieldx(tag,occ) /* internal use */ |
|---|
| 17 | #define mstsetup xmstsetup /* internal use */ |
|---|
| 18 | #if MULTI |
|---|
| 19 | #define recunlck(irec,option) xrecunlck(option) /* internal use */ |
|---|
| 20 | #endif |
|---|
| 21 | /*#define recisis0 xrecisis0 moved to CISISX */ |
|---|
| 22 | #define recupdat(crec,irec) xrecupdat() /* internal use */ |
|---|
| 23 | #define recwrite xrecwrite /* internal use */ |
|---|
| 24 | #define recwmast xrecwmast /* internal use */ |
|---|
| 25 | #define recwxref xrecwxref /* internal use */ |
|---|
| 26 | #define fldupdat(irec,batchp) xfldupdat(batchp) /* internal use */ |
|---|
| 27 | //#if IFUPDATE |
|---|
| 28 | /*#define recreset xrecreset moved to CISISX */ |
|---|
| 29 | //#endif |
|---|
| 30 | //#define recfield xrecfield /* internal use */ |
|---|
| 31 | /* ---------------------------------------------------------------------- */ |
|---|
| 32 | #endif /* CICPP */ |
|---|
| 33 | |
|---|
| 34 | /* ----------------------------- rec.c ------------------------------ */ |
|---|
| 35 | |
|---|
| 36 | #define RECTRACE 0 |
|---|
| 37 | #define REATRACE 0 |
|---|
| 38 | #define RERTRACE 0 |
|---|
| 39 | #define REXTRACE 0 |
|---|
| 40 | #define REYTRACE 0 |
|---|
| 41 | #define RESXRACE 02 |
|---|
| 42 | #define RESTRACE 01111 |
|---|
| 43 | |
|---|
| 44 | #if !CICPP |
|---|
| 45 | |
|---|
| 46 | char lastrecread[CIMPL+1] = ""; /* 950724 */ |
|---|
| 47 | |
|---|
| 48 | LONGX recxrefb=0; /* recxref() comb */ |
|---|
| 49 | int recxrefp=0; /* recxref() comp */ |
|---|
| 50 | int recxrefn=0; /* recxref() flagnew */ |
|---|
| 51 | int recxrefm=0; /* recxref() flagmod */ |
|---|
| 52 | FFI recreadl=0; /* force recread() mfrl */ |
|---|
| 53 | |
|---|
| 54 | #if IFUPDATE |
|---|
| 55 | LONGX recreadb=0; /* force recread() comb = mfbwb */ |
|---|
| 56 | int recreadp=0; /* force recread() comp = mfbwp */ |
|---|
| 57 | #endif |
|---|
| 58 | |
|---|
| 59 | #endif /* CICPP */ |
|---|
| 60 | |
|---|
| 61 | #if CICPP |
|---|
| 62 | #define NO_IREC -1L |
|---|
| 63 | #endif /* CICPP */ |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | #if CICPP |
|---|
| 67 | |
|---|
| 68 | RECSTRU :: RECSTRU (CISISX *cxp): cisisxp(cxp), |
|---|
| 69 | recnbytes(0L), rectype(0), recdbxp(NULL), recrc(0), |
|---|
| 70 | #if MULTI |
|---|
| 71 | reclock(0), recwlock(0), |
|---|
| 72 | #endif |
|---|
| 73 | recgdbl(0), recgdbw(0), recmfp(NULL) |
|---|
| 74 | { |
|---|
| 75 | if (cisisxp == NULL) |
|---|
| 76 | fatal("RECSTRU/cisisxp==NULL"); |
|---|
| 77 | }; |
|---|
| 78 | |
|---|
| 79 | RECSTRU :: RECSTRU (CISISX *cxp, |
|---|
| 80 | CONST RECSTRU &other) |
|---|
| 81 | { |
|---|
| 82 | recnbytes = other.recnbytes; |
|---|
| 83 | rectype = other.rectype; |
|---|
| 84 | recdbxp = other.recdbxp; |
|---|
| 85 | #if MULTI |
|---|
| 86 | reclock = other.reclock; |
|---|
| 87 | recwlock = other.recwlock; |
|---|
| 88 | #endif // MULTI |
|---|
| 89 | recgdbl = other.recgdbl; |
|---|
| 90 | recgdbw = other.recgdbw; |
|---|
| 91 | |
|---|
| 92 | try {recmfp = (MFUNION *) new char [recnbytes];} |
|---|
| 93 | catch (BAD_ALLOC) {fatal("RECSTRU/ALLOC");} |
|---|
| 94 | memcpy (recmfp,other.recmfp,recnbytes); |
|---|
| 95 | cisisxp = cxp; |
|---|
| 96 | if (cisisxp == NULL) |
|---|
| 97 | fatal("RECSTRU/cisisxp==NULL"); |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | RECSTRU :: ~RECSTRU(void) |
|---|
| 101 | { |
|---|
| 102 | if (recmfp) |
|---|
| 103 | delete [] recmfp; |
|---|
| 104 | } |
|---|
| 105 | #endif /* CICPP */ |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | #if !CICPP |
|---|
| 109 | #if ANSI |
|---|
| 110 | void recinit(void) /* |
|---|
| 111 | ------------ */ |
|---|
| 112 | #else |
|---|
| 113 | void recinit() /* |
|---|
| 114 | ------- */ |
|---|
| 115 | #endif |
|---|
| 116 | /* |
|---|
| 117 | inicializa vrecp |
|---|
| 118 | */ |
|---|
| 119 | { |
|---|
| 120 | for (nrecs=maxnrec;nrecs--;) |
|---|
| 121 | vrecp[nrecs]=NULL; |
|---|
| 122 | |
|---|
| 123 | nrecs=0; |
|---|
| 124 | } |
|---|
| 125 | #endif /* CICPP */ |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | #if CICPP |
|---|
| 129 | LONGX RECSTRU :: xrecalloc(LONGX nbytes) |
|---|
| 130 | #else |
|---|
| 131 | LONGX recallok(irec,nbytes) |
|---|
| 132 | /* |
|---|
| 133 | ------------- |
|---|
| 134 | abenda se nbytes menor do que primeiro move; |
|---|
| 135 | abenda se ja' alocado; |
|---|
| 136 | aloca RECHSIZE+nbytes bytes; |
|---|
| 137 | aponta por vrecp[irec]; |
|---|
| 138 | garante inicializacao com zeros; |
|---|
| 139 | armazena vrecp[irec]->recnbytes; |
|---|
| 140 | retorna irec |
|---|
| 141 | */ |
|---|
| 142 | LONGX irec; /* indice de vrecp, para ALLOC */ |
|---|
| 143 | LONGX nbytes; /* tamanho da area util em bytes */ |
|---|
| 144 | #endif /* CICPP */ |
|---|
| 145 | { |
|---|
| 146 | RECSTRU *recp; |
|---|
| 147 | |
|---|
| 148 | #if CICPP |
|---|
| 149 | LONGX irec = NO_IREC; |
|---|
| 150 | recp=this; |
|---|
| 151 | #else /* CICPP */ |
|---|
| 152 | |
|---|
| 153 | if (!nrecs) |
|---|
| 154 | recinit(); |
|---|
| 155 | |
|---|
| 156 | if (irec < 0 || irec >= maxnrec) |
|---|
| 157 | fatal("recallok/index"); |
|---|
| 158 | |
|---|
| 159 | if (nrecs >= maxnrec) |
|---|
| 160 | fatal("recallok/overflow"); |
|---|
| 161 | #endif /* CICPP */ |
|---|
| 162 | |
|---|
| 163 | if (nbytes < MSNVSPLT) |
|---|
| 164 | fatal("recallok/MSNVSPLT"); |
|---|
| 165 | |
|---|
| 166 | #if CICPP |
|---|
| 167 | if (!recmfp || nbytes != RECnbytes) { |
|---|
| 168 | if (recmfp) delete [] recmfp; |
|---|
| 169 | try { recmfp = (MFUNION *) new char [nbytes];} |
|---|
| 170 | catch (BAD_ALLOC) {recmfp = (MFUNION *)ALLONULL; } |
|---|
| 171 | if (recmfp == (MFUNION *)ALLONULL) |
|---|
| 172 | fatal("recallok/ALLOC"); |
|---|
| 173 | } |
|---|
| 174 | memset(recmfp,0x00,(size_t)nbytes); |
|---|
| 175 | |
|---|
| 176 | #else /* CICPP */ |
|---|
| 177 | |
|---|
| 178 | if (vrecp[irec]) fatal("recallok/again"); |
|---|
| 179 | |
|---|
| 180 | if ((RECHSIZE+nbytes) > ALLOMAXV) |
|---|
| 181 | fatal("recallok/ALLOMAXV/RECHSIZE+nbytes"); |
|---|
| 182 | |
|---|
| 183 | recp=(RECSTRU *)ALLOC((ALLOPARM)(RECHSIZE+nbytes)); |
|---|
| 184 | if (recp == (RECSTRU *)ALLONULL) |
|---|
| 185 | fatal("recallok/ALLOC"); |
|---|
| 186 | |
|---|
| 187 | vrecp[irec]=recp; |
|---|
| 188 | nrecs++; |
|---|
| 189 | memset(recp,0x00,(size_t)(RECHSIZE+nbytes)); |
|---|
| 190 | |
|---|
| 191 | #endif /* CICPP */ |
|---|
| 192 | |
|---|
| 193 | RECnbytes=nbytes; |
|---|
| 194 | RECtype=0; /* init */ |
|---|
| 195 | |
|---|
| 196 | #if MULTI |
|---|
| 197 | RECwlock=WUNLOCK; /* 28/07/94 */ |
|---|
| 198 | #endif |
|---|
| 199 | |
|---|
| 200 | #if REATRACE |
|---|
| 201 | #if CICPP |
|---|
| 202 | printf("recallok - recp=%p RECtype=%d RECnbytes=%"_LD_"\n", |
|---|
| 203 | recp,RECtype,RECnbytes); |
|---|
| 204 | #else |
|---|
| 205 | printf("recallok - vrecp[%"_LD_"]=%p nrecs=%"_LD_" RECtype=%d RECnbytes=%"_LD_"\n", |
|---|
| 206 | irec,vrecp[irec],nrecs,RECtype,RECnbytes); |
|---|
| 207 | #endif /* CICPP */ |
|---|
| 208 | #endif |
|---|
| 209 | |
|---|
| 210 | return(irec); |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | #if CICPP |
|---|
| 215 | LONGX RECSTRU :: xrecord(char *dbnamp, |
|---|
| 216 | LONGX mfn) |
|---|
| 217 | #else /* CICPP */ |
|---|
| 218 | LONGX record(irec,dbnamp,mfn) /* |
|---|
| 219 | ----------- |
|---|
| 220 | inicializa vrecp, se necessario; |
|---|
| 221 | aloca o registro irec, se ainda nao alocado; |
|---|
| 222 | seta dbxp com o resultado de dbxstorp(dbnamp); |
|---|
| 223 | le o registro mfn da base de dados descrita em dbxp; |
|---|
| 224 | armazena retorno de recread() em RECrc; |
|---|
| 225 | retorna irec |
|---|
| 226 | */ |
|---|
| 227 | LONGX irec; /* indice de vrecp, para store */ |
|---|
| 228 | char *dbnamp; /* ptr nome base de dados a ler */ |
|---|
| 229 | LONGX mfn; /* numero do registro a ler */ |
|---|
| 230 | #endif /* CICPP */ |
|---|
| 231 | { |
|---|
| 232 | RECSTRU *recp; |
|---|
| 233 | DBXSTRU *dbxp; |
|---|
| 234 | #if RECGIZM |
|---|
| 235 | VGIZPSTRU *vgizmap; |
|---|
| 236 | #endif |
|---|
| 237 | |
|---|
| 238 | #if RECTRACE |
|---|
| 239 | FFI i,n; |
|---|
| 240 | #endif |
|---|
| 241 | char *p; |
|---|
| 242 | |
|---|
| 243 | #if CICPP |
|---|
| 244 | LONGX irec = NO_IREC; |
|---|
| 245 | #endif |
|---|
| 246 | |
|---|
| 247 | /* forca carga de rec_maxmfrl - AOT, 02/06/99 */ |
|---|
| 248 | p=dbxcipar(NULL,"maxmfrl",'='); if (dbxcipok) sscanf(p,"%"_LD_,&rec_maxmfrl); |
|---|
| 249 | |
|---|
| 250 | #if CICPP |
|---|
| 251 | recp=this; |
|---|
| 252 | if (!recmfp) xrecalloc(rec_maxmfrl); |
|---|
| 253 | #else /* CICPP */ |
|---|
| 254 | if (!nrecs) |
|---|
| 255 | recinit(); |
|---|
| 256 | recp=vrecp[irec]; |
|---|
| 257 | if (!recp) |
|---|
| 258 | recp=vrecp[recallok(irec,rec_maxmfrl)]; |
|---|
| 259 | #endif /* CICPP */ |
|---|
| 260 | |
|---|
| 261 | dbxp=dbxstorp(dbnamp); |
|---|
| 262 | |
|---|
| 263 | #if BEFORE950724 |
|---|
| 264 | #else |
|---|
| 265 | if (strcmp(dbnamp,lastrecread)) { |
|---|
| 266 | if (lastrecread[0]) { |
|---|
| 267 | DBXSTRU *lastdbxp=dbxsrchp(lastrecread); /* "" - 22/01/97 */ |
|---|
| 268 | if (lastdbxp) { |
|---|
| 269 | if (lastdbxp->dbxmflush) mstflush(lastrecread); else |
|---|
| 270 | if (lastdbxp->dbxmclose) mstclose(lastdbxp); |
|---|
| 271 | } |
|---|
| 272 | } |
|---|
| 273 | strcpy(lastrecread,dbnamp); |
|---|
| 274 | } |
|---|
| 275 | #endif |
|---|
| 276 | |
|---|
| 277 | #if BEFOREGIZMO |
|---|
| 278 | if (RECdbxp == dbxp) |
|---|
| 279 | if (MFRmfn == mfn) |
|---|
| 280 | return(irec); |
|---|
| 281 | #endif |
|---|
| 282 | |
|---|
| 283 | RECdbxp=dbxp; |
|---|
| 284 | |
|---|
| 285 | #if RECTRACE |
|---|
| 286 | printf("record - irec=%"_LD_" recp=%p dbxp=%p=%s mfn=%"_LD_"\n", |
|---|
| 287 | irec,recp,dbxp,dbnamp,mfn); |
|---|
| 288 | #endif |
|---|
| 289 | |
|---|
| 290 | recread(recp,mfn); |
|---|
| 291 | |
|---|
| 292 | if (RECtype == TYPEMFR) { |
|---|
| 293 | #if RECXPND |
|---|
| 294 | if (RDBxpn01) |
|---|
| 295 | #if CICPP |
|---|
| 296 | recxpnmo(recp); |
|---|
| 297 | #else |
|---|
| 298 | recxpnmo(irec); /* v4.2 */ |
|---|
| 299 | #endif /* CICPP */ |
|---|
| 300 | #endif |
|---|
| 301 | |
|---|
| 302 | #if RECGIZM |
|---|
| 303 | for (vgizmap=RDBvgzrp; vgizmap; vgizmap=vgizmap->nextp) |
|---|
| 304 | #if CICPP |
|---|
| 305 | recgizmo(cisisxp,recp,vgizmap); |
|---|
| 306 | #else |
|---|
| 307 | recgizmo(irec,vgizmap); /* v3.4 */ |
|---|
| 308 | #endif /* CICPP */ |
|---|
| 309 | #endif |
|---|
| 310 | |
|---|
| 311 | #if RECDECO |
|---|
| 312 | if (RDBvderp) { |
|---|
| 313 | #if CICPP |
|---|
| 314 | recdecex(cisisxp, recp); |
|---|
| 315 | #else |
|---|
| 316 | recdecex(irec); /* decod */ |
|---|
| 317 | #endif /* CICPP */ |
|---|
| 318 | } |
|---|
| 319 | #endif |
|---|
| 320 | } |
|---|
| 321 | |
|---|
| 322 | #if RECTRACE |
|---|
| 323 | if (RECtype == TYPEMF0) { |
|---|
| 324 | printf("record - RECrc=%d Ctlmfr: %"_LD_,%"_LD_,%"_LD_,%d,%d,%"_LD_,%"_LD_,%"_LD_,%"_LD_"\n", |
|---|
| 325 | RECrc, |
|---|
| 326 | MF0ctlmfn,MF0nxtmfn,MF0nxtmfb,MF0nxtmfp, |
|---|
| 327 | MF0mftype,MF0reccnt,MF0mfcxx1,MF0mfcxx2,MF0mfcxx3); |
|---|
| 328 | } |
|---|
| 329 | else { |
|---|
| 330 | printf("record - RECrc=%d Leader: %"_LD_,%d,%"_LD_,%d,%d,%d,%d\n", |
|---|
| 331 | RECrc,MFRmfn,MFRmfrl,MFRmfbwb,MFRmfbwp,MFRbase,MFRnvf,MFRstatus); |
|---|
| 332 | #if RECTRACE |
|---|
| 333 | if (RECrc == RCNORMAL || RECrc == RCLDEL) |
|---|
| 334 | for (i=0;i<MFRnvf;i++) { |
|---|
| 335 | printf("record - tag[%d],pos[%d],len[%d]=%d,%d,%d\n", |
|---|
| 336 | i,i,i,MFRdir[i].tag,MFRdir[i].pos,MFRdir[i].len); |
|---|
| 337 | for (p=FIELDP(i), n=DIRlen(i); n--;) |
|---|
| 338 | putchar(*p++); |
|---|
| 339 | putchar('\n'); |
|---|
| 340 | } |
|---|
| 341 | #endif |
|---|
| 342 | } |
|---|
| 343 | #endif |
|---|
| 344 | |
|---|
| 345 | #define RECMSTFLUSH 0 |
|---|
| 346 | #if RECMSTFLUSH /* 950724 */ |
|---|
| 347 | mstflush(DBXname); |
|---|
| 348 | #endif |
|---|
| 349 | |
|---|
| 350 | return(irec); |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | |
|---|
| 354 | #if CICPP |
|---|
| 355 | int RECSTRU :: xrecread(LONGX mfn) |
|---|
| 356 | #else /* CICPP */ |
|---|
| 357 | int recread(recp,mfn) /* |
|---|
| 358 | ----------- |
|---|
| 359 | seta dbxp; |
|---|
| 360 | obtem ptr para .mst e seu (mfn) status em .xrf; |
|---|
| 361 | se Active / Logical deleted: |
|---|
| 362 | chama dbxopen para dbxp->dbxname+.mst, se necessario; |
|---|
| 363 | aloca dbxp->dbxmsibp, se ainda nao alocado; |
|---|
| 364 | posiciona e le .mst blk; |
|---|
| 365 | move mfr neversplit para recp->recmf.mx; |
|---|
| 366 | move possivel para recp->recmf.mx[MSNVSPLT]; |
|---|
| 367 | le restante ja' em recp->recmf.mx[MSNVSPLT+i]; |
|---|
| 368 | retorna gdb record rc ou aborta |
|---|
| 369 | */ |
|---|
| 370 | RECSTRU *recp; /* elemento de vrecp, para store */ |
|---|
| 371 | LONGX mfn; /* numero do registro a ler */ |
|---|
| 372 | #endif /* CICPP */ |
|---|
| 373 | { |
|---|
| 374 | DBXSTRU *dbxp; |
|---|
| 375 | |
|---|
| 376 | FFI n,n1,n2,nr,moveok; |
|---|
| 377 | #if VAX |
|---|
| 378 | FFI left; |
|---|
| 379 | int d; |
|---|
| 380 | #endif |
|---|
| 381 | |
|---|
| 382 | LONGX comb; /* gdb getmfr comb */ |
|---|
| 383 | int comp; /* gdb getmfr comp */ |
|---|
| 384 | |
|---|
| 385 | char *p,*inp,*msyyp; /* v3.3 */ |
|---|
| 386 | off_t xseek; |
|---|
| 387 | int fd,rc; |
|---|
| 388 | #if CNV_PCBINUM |
|---|
| 389 | FFI wlen; |
|---|
| 390 | #endif |
|---|
| 391 | |
|---|
| 392 | #if MULTI |
|---|
| 393 | #if CNV_PCFILES |
|---|
| 394 | char unibuff[MSNVSPLT]; /* CNV_PCFILES/recread - EWL/DE/RL */ |
|---|
| 395 | #endif |
|---|
| 396 | #endif |
|---|
| 397 | |
|---|
| 398 | #if CICPP |
|---|
| 399 | RECSTRU *recp = this; |
|---|
| 400 | #endif /* CICPP */ |
|---|
| 401 | |
|---|
| 402 | dbxp=RECdbxp; |
|---|
| 403 | |
|---|
| 404 | #if RERTRACE |
|---|
| 405 | printf("recread - recp=%p dbxp=%p mfn=%"_LD_"\n",recp,dbxp,mfn); |
|---|
| 406 | #endif |
|---|
| 407 | |
|---|
| 408 | #if CICPP |
|---|
| 409 | recp->xmstsetup(DBXname,0L,0L); |
|---|
| 410 | #else |
|---|
| 411 | mstsetup(DBXname,0L,0L); |
|---|
| 412 | #endif /* CICPP */ |
|---|
| 413 | |
|---|
| 414 | if (strcmp(DBXname,"null") == 0) { |
|---|
| 415 | if (mfn == 0) { |
|---|
| 416 | memset(MFX,0x00,sizeof(M0STRU)); |
|---|
| 417 | MF0nxtmfn=1L; |
|---|
| 418 | RECtype=TYPEMF0; |
|---|
| 419 | } |
|---|
| 420 | else { |
|---|
| 421 | memset(MFX,0x00,LEADER); |
|---|
| 422 | MFRmfn=mfn; MFRmfrl=MFRbase=LEADER; |
|---|
| 423 | RECtype=TYPEMFR; |
|---|
| 424 | } |
|---|
| 425 | return(RECrc=RCNORMAL); |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | RECgdbl=RECgdbw=0; |
|---|
| 429 | #if MULTI |
|---|
| 430 | #if RERTRACE |
|---|
| 431 | printf("recread - %s/%"_LD_" lock=%d\n",DBXname,mfn,REClock); |
|---|
| 432 | #endif |
|---|
| 433 | /* if operation is single user then reset locking option */ |
|---|
| 434 | if (DBXnetws == MONONETS) REClock=NOLOCK; |
|---|
| 435 | rc=RCNORMAL; |
|---|
| 436 | if (REClock) { |
|---|
| 437 | dbxopenw(DBXname,DBXname,xx1extp,&DBXxropn,&DBXxropw,"recread/xropn/w"); |
|---|
| 438 | dbxopenw(DBXname,DBXname,mx1extp,&DBXmsopn,&DBXmsopw,"recread/msopn/w"); |
|---|
| 439 | } |
|---|
| 440 | #endif |
|---|
| 441 | |
|---|
| 442 | if (mfn == 0) { |
|---|
| 443 | RECtype=TYPEMF0; |
|---|
| 444 | comb=1; comp=0; |
|---|
| 445 | rc=RCNORMAL; |
|---|
| 446 | } |
|---|
| 447 | else { |
|---|
| 448 | RECtype=TYPEMFR; |
|---|
| 449 | #if IFUPDATE |
|---|
| 450 | if (recreadb) { |
|---|
| 451 | rc=RECrc=RCNORMAL; |
|---|
| 452 | comb=recreadb; recreadb=0; |
|---|
| 453 | comp=recreadp; recreadp=0; |
|---|
| 454 | } |
|---|
| 455 | else |
|---|
| 456 | #endif |
|---|
| 457 | if ((rc=recxref(recp,mfn,&comb,&comp)) == RCEOF || rc == RCPDEL) { |
|---|
| 458 | MFRmfn=mfn; |
|---|
| 459 | MFRmfrl=LEADER; |
|---|
| 460 | MFRmfbwb=0; MFRmfbwp=0; |
|---|
| 461 | MFRbase=LEADER; |
|---|
| 462 | MFRnvf=0; |
|---|
| 463 | MFRstatus=DELETED; |
|---|
| 464 | #if MULTI |
|---|
| 465 | if (REClock) { |
|---|
| 466 | if (multrace) |
|---|
| 467 | printf("<r> %s/%"_LD_" is inexistent or beyond EOF\n", |
|---|
| 468 | DBXname,mfn); |
|---|
| 469 | } |
|---|
| 470 | #endif |
|---|
| 471 | return(RECrc=rc); |
|---|
| 472 | } |
|---|
| 473 | } |
|---|
| 474 | |
|---|
| 475 | #if RERTRACE |
|---|
| 476 | printf("recread - recp=%p dbxp=%p mfn=%"_LD_" comb=%"_LD_" comp=%d rc=%d\n", |
|---|
| 477 | recp,dbxp,mfn,comb,comp,rc); |
|---|
| 478 | #endif |
|---|
| 479 | |
|---|
| 480 | if ((msyyp=DBXmsyyp) == NULL) /* v3.3 */ |
|---|
| 481 | if ((fd=DBXmsopn) <= 0) |
|---|
| 482 | fatal("recread/DBXmsopn"); |
|---|
| 483 | |
|---|
| 484 | if (!DBXmsibp) |
|---|
| 485 | fatal("recread/DBXmsibp"); |
|---|
| 486 | |
|---|
| 487 | #if MULTI |
|---|
| 488 | /* step 1: lock the .mst file */ |
|---|
| 489 | if (REClock) { |
|---|
| 490 | /* initial check */ |
|---|
| 491 | if (mfn == 0) { |
|---|
| 492 | if (REClock == EWLOCK) { /* Great Richard! */ |
|---|
| 493 | /* user's exclusive write lock must be off */ |
|---|
| 494 | if (DBXewlxx) fatal("recread/lock/exclusive write lock is on"); |
|---|
| 495 | } |
|---|
| 496 | else |
|---|
| 497 | /* user's data entry lock must be off */ |
|---|
| 498 | if (DBXdelxx) fatal("recread/lock/data entry lock is on"); |
|---|
| 499 | } |
|---|
| 500 | else { |
|---|
| 501 | /* user's data entry lock must be on */ |
|---|
| 502 | if (!DBXdelxx) fatal("recread/lock/data entry lock is off"); |
|---|
| 503 | } |
|---|
| 504 | /* .mst file lock: lock */ |
|---|
| 505 | if (multrace) printf("<r> %s .mst lock \n",DBXname); |
|---|
| 506 | if (dbxflock(dbxp,"M")) { |
|---|
| 507 | if (multrace) printf("<r> %s .mst lock/denied \n",DBXname); |
|---|
| 508 | if (dbxewlrc) return(RECrc=RCLOCK); |
|---|
| 509 | fatal("recread/lock/file lock"); |
|---|
| 510 | } |
|---|
| 511 | /* wait another's exclusive write lock */ |
|---|
| 512 | if (dbxwlock(dbxp,MFX,dbxwloop)) { |
|---|
| 513 | if (multrace) printf("<r> %s .mst ewl is on !!!\n",DBXname); |
|---|
| 514 | if (dbxewlrc) return(RECrc=RCLOCK); |
|---|
| 515 | fatal("recread/lock/must wait ewl"); |
|---|
| 516 | } |
|---|
| 517 | if (REClock == EWLOCK) |
|---|
| 518 | /* check another's DEL (allow user's DEL) */ |
|---|
| 519 | if (MF0mfcxx2 > 1 || (MF0mfcxx2 == 1 && !DBXdelxx)) { |
|---|
| 520 | if (multrace) printf("<r> %s .mst del is on !!!\n",DBXname); |
|---|
| 521 | if (dbxulock(dbxp,"M")) fatal("recread/lock/file unlock/del"); |
|---|
| 522 | return(RECrc=RCLOCK); |
|---|
| 523 | } |
|---|
| 524 | } |
|---|
| 525 | #endif |
|---|
| 526 | |
|---|
| 527 | n1=MSBSIZ; /* ok */ |
|---|
| 528 | |
|---|
| 529 | #if MULTI |
|---|
| 530 | if (DBXnetws != MONONETS || comb != DBXmsibp->msbufn) { |
|---|
| 531 | #else |
|---|
| 532 | if (comb != DBXmsibp->msbufn) { |
|---|
| 533 | #endif |
|---|
| 534 | xseek=(((off_t)(comb-1))<<MSBSHIFT); |
|---|
| 535 | if (msyyp == NULL) { /* v3.3 */ |
|---|
| 536 | #if RERTRACE |
|---|
| 537 | printf("recread - fd,lseek=%"_LD_",%"P_OFF_T"\n",fd,(LONG_LONG)xseek); |
|---|
| 538 | #endif |
|---|
| 539 | if (LSEEK64(fd,xseek,SEEK_SET) != xseek) |
|---|
| 540 | fatal("recread/lseek"); |
|---|
| 541 | if ((n1=CIREAD(fd,DBXmsibp->msbuff,MSBSIZ)) < MSBSIZ) |
|---|
| 542 | fatal("recread/read"); |
|---|
| 543 | } |
|---|
| 544 | else { |
|---|
| 545 | #if RERTRACE |
|---|
| 546 | printf("recread - msyyp=%p fd,lseek=%"P_OFF_T",%"_LD_"\n",msyyp,fd,(LONG_LONG)xseek); |
|---|
| 547 | #endif |
|---|
| 548 | memcpy(DBXmsibp,msyyp+xseek,MSBSIZ); |
|---|
| 549 | } |
|---|
| 550 | DBXmsibp->msbufn=comb; |
|---|
| 551 | } |
|---|
| 552 | |
|---|
| 553 | inp=DBXmsibp->msbuff+comp; |
|---|
| 554 | |
|---|
| 555 | if (RECtype == TYPEMF0) { |
|---|
| 556 | |
|---|
| 557 | #if RERTRACE |
|---|
| 558 | printf("recread- RECtype=%d n1=%d n=%d MFX=%p inp=%p\n", |
|---|
| 559 | RECtype,n1,sizeof(M0STRU),MFX,inp); |
|---|
| 560 | #endif |
|---|
| 561 | if (n1 < (n=sizeof(M0STRU))) fatal("recread/block"); |
|---|
| 562 | memcpy(MFX,inp,n); /* ok */ |
|---|
| 563 | #if CNV_PCBINUM |
|---|
| 564 | ConvertMST_CTLSTRUCT(MFX); |
|---|
| 565 | if (rectrace) prtcontrol(recp,DBXname); |
|---|
| 566 | #endif |
|---|
| 567 | if (MF0ctlmfn != mfn) fatal("recread/check/ctlmfn"); |
|---|
| 568 | DBXmsmfn=MF0nxtmfn; /* 31/12/90 */ |
|---|
| 569 | |
|---|
| 570 | #if MULTI |
|---|
| 571 | /* step 2: perform a DEL or an EWL lock (MF0) */ |
|---|
| 572 | if (REClock) { |
|---|
| 573 | if (REClock == EWLOCK) { /* EWL */ |
|---|
| 574 | MF0mfcxx3++; |
|---|
| 575 | DBXewlxx++; |
|---|
| 576 | } |
|---|
| 577 | else { /* DEL */ /* is DELOCK ? */ |
|---|
| 578 | MF0mfcxx2++; |
|---|
| 579 | DBXdelxx++; |
|---|
| 580 | } |
|---|
| 581 | if (LSEEK64(fd,0L,SEEK_SET) != 0) fatal("recread/lock/lseek/ctl"); |
|---|
| 582 | #if CNV_PCBINUM |
|---|
| 583 | memcpy(cnv_pcbuff,MFX,sizeof(M0STRU)); |
|---|
| 584 | ConvertMST_CTLSTRUCT(cnv_pcbuff); |
|---|
| 585 | if (CIWRITE(fd,cnv_pcbuff,sizeof(M0STRU)) != sizeof(M0STRU)) |
|---|
| 586 | #else |
|---|
| 587 | if (CIWRITE(fd,MFX,sizeof(M0STRU)) != sizeof(M0STRU)) |
|---|
| 588 | #endif |
|---|
| 589 | fatal("recread/lock/write/ctl"); |
|---|
| 590 | /* update input buffer */ |
|---|
| 591 | ((M0STRU *)DBXmsibp)->m0mfcxx2=MF0mfcxx2; |
|---|
| 592 | #if BEFORE20000413 |
|---|
| 593 | #else |
|---|
| 594 | ((M0STRU *)DBXmsibp)->m0mfcxx3=MF0mfcxx3; |
|---|
| 595 | #endif |
|---|
| 596 | /* .mst file lock: unlock */ |
|---|
| 597 | if (multrace) printf("<r> %s .mst unlock [%s on] \n", |
|---|
| 598 | DBXname,(REClock == EWLOCK)?"EWL":"DEL"); |
|---|
| 599 | if (dbxulock(dbxp,"M")) fatal("recread/lock/file unlock/ctl"); |
|---|
| 600 | } |
|---|
| 601 | #endif |
|---|
| 602 | #if DBXMSTXL /* reseta apos fazer o DE/EWL, AOT 18/06/2002 */ |
|---|
| 603 | /* DBXmstxl is assigned by mstsetup() */ |
|---|
| 604 | MF0mftype = MF0mftype & 0x00FF; |
|---|
| 605 | if (rectrace) printf("+++ recread - %s/mstxl=%d\n",DBXname,DBXmstxl); |
|---|
| 606 | #endif |
|---|
| 607 | return(RECrc=RCNORMAL); /* MULTI ok */ |
|---|
| 608 | } |
|---|
| 609 | |
|---|
| 610 | #if CNV_PCBINUM |
|---|
| 611 | memcpy(cnv_pcbuff,inp,MSNVSPLT); |
|---|
| 612 | ConvertMST_LEADER(cnv_pcbuff,0,MSNVSPLT); |
|---|
| 613 | p=inp; /* save inp */ |
|---|
| 614 | inp=cnv_pcbuff; |
|---|
| 615 | #endif |
|---|
| 616 | |
|---|
| 617 | #if CNV_PCFILES |
|---|
| 618 | memcpy(MFX+0,inp+0,4); /* mfn= */ /* unibuff */ |
|---|
| 619 | memcpy(MFX+4,inp+6,4); /* mfbwb= */ /* unibuff */ |
|---|
| 620 | memcpy(MFX+8,inp+4,2); /* mfrl= */ /* unibuff */ |
|---|
| 621 | memcpy(MFX+10,inp+10,MSNVSPLT-10); /* unibuff */ |
|---|
| 622 | if (rectrace) prtleader(recp,mfn); |
|---|
| 623 | #else |
|---|
| 624 | memcpy(MFX,inp,MSNVSPLT); |
|---|
| 625 | #endif |
|---|
| 626 | |
|---|
| 627 | #if CNV_PCBINUM |
|---|
| 628 | inp=p; /* restore inp */ |
|---|
| 629 | #endif |
|---|
| 630 | |
|---|
| 631 | p=MFX+MSNVSPLT; inp+=MSNVSPLT; moveok=MSNVSPLT; |
|---|
| 632 | |
|---|
| 633 | #if MULTI |
|---|
| 634 | /* step 3: process existing record lock */ |
|---|
| 635 | if (MFRmfrl > (FFI)MFRL_MAX) { |
|---|
| 636 | if (multrace) |
|---|
| 637 | printf("<r> %s/%"_LD_" mfrl=%04x=%d \n",DBXname,mfn,MFRmfrl,MFRmfrl); |
|---|
| 638 | RECgdbl=0; RECgdbw=MFRmfrl; |
|---|
| 639 | MFRmfrl=(FFI)0-MFRmfrl; |
|---|
| 640 | if (multrace) |
|---|
| 641 | printf("<r> %s/%"_LD_" mfrl=%04x=+%d\n",DBXname,mfn,RECgdbl,MFRmfrl); |
|---|
| 642 | if (REClock) rc=RCLOCK; |
|---|
| 643 | } |
|---|
| 644 | #endif |
|---|
| 645 | |
|---|
| 646 | n=MFRmfrl; /* to read */ |
|---|
| 647 | if (recreadl) { |
|---|
| 648 | if (recreadl == 1) n=LEADER; /* leader */ |
|---|
| 649 | else if (recreadl == 2) n=MFRbase; /* + dir */ |
|---|
| 650 | else n=recreadl; /* waall! */ |
|---|
| 651 | #if CNV_PCBINUM |
|---|
| 652 | wlen=recreadl; |
|---|
| 653 | #endif |
|---|
| 654 | recreadl=0; |
|---|
| 655 | } |
|---|
| 656 | |
|---|
| 657 | if (n < (FFI)LEADER || n > (FFI)RECnbytes) { |
|---|
| 658 | #if RERTRACE |
|---|
| 659 | if (rectrace) { |
|---|
| 660 | memset(p,0x00,LEADER-MSNVSPLT); |
|---|
| 661 | prtleader(recp,mfn); |
|---|
| 662 | } |
|---|
| 663 | #endif |
|---|
| 664 | fatal("recread/check/mfrl"); |
|---|
| 665 | } |
|---|
| 666 | |
|---|
| 667 | n-=moveok; /* more */ |
|---|
| 668 | n2=n1-comp-moveok; /* left in buffer */ |
|---|
| 669 | if (n < n2) n2=n; /* this */ |
|---|
| 670 | n-=n2; /* next */ |
|---|
| 671 | |
|---|
| 672 | #if RERTRACE |
|---|
| 673 | printf("recread - moveok=%d n=%d n2=%d p=%p \n",moveok,n,n2,p); |
|---|
| 674 | #endif |
|---|
| 675 | |
|---|
| 676 | if (n2) { |
|---|
| 677 | if (n2 <= 0) fatal("recread/n2"); |
|---|
| 678 | memcpy(p,inp,n2); p+=n2; moveok+=n2; |
|---|
| 679 | #if RERTRACE |
|---|
| 680 | printf("recread - moveok=%d n=%d n2=%d p=%p \n",moveok,n,n2,p); |
|---|
| 681 | #endif |
|---|
| 682 | } |
|---|
| 683 | |
|---|
| 684 | if (n) { |
|---|
| 685 | if (n <= 0) fatal("recread/n"); |
|---|
| 686 | xseek=(((off_t)(comb-0))<<MSBSHIFT); |
|---|
| 687 | #if RERTRACE |
|---|
| 688 | printf("recread - fd,lseek2=%"_LD_",%"P_OFF_T"\n",fd,(LONG_LONG)xseek); |
|---|
| 689 | #endif |
|---|
| 690 | if (msyyp == NULL) { /* v3.3 */ |
|---|
| 691 | if (LSEEK64(fd,xseek,SEEK_SET) != xseek) fatal("recread/lseek2"); |
|---|
| 692 | nr=n; |
|---|
| 693 | #if VAX |
|---|
| 694 | for (left=nr; left > 0; ) { |
|---|
| 695 | nr = (left > MSBSIZ) ? MSBSIZ : left; |
|---|
| 696 | #endif |
|---|
| 697 | if ((n2=CIREAD(fd,p,nr)) != nr) { |
|---|
| 698 | if (rectrace) |
|---|
| 699 | printf("\n*** mfn=%"_LD_" seek=%"_LD_"/%d=%"P_OFF_T" read=%d/%d\n", |
|---|
| 700 | mfn,comb,comp,(LONG_LONG)xseek,nr,n2); |
|---|
| 701 | fatal("recread/read2"); |
|---|
| 702 | } |
|---|
| 703 | #if VAX |
|---|
| 704 | left-=n2; p+=n2; |
|---|
| 705 | } |
|---|
| 706 | #endif |
|---|
| 707 | } |
|---|
| 708 | else { |
|---|
| 709 | #if RERTRACE |
|---|
| 710 | printf("recread - p=%p msyyp=%p fd,lseek2=%"_LD_",%"P_OFF_T"\n",p,msyyp,fd,(LONG_LONG)xseek); |
|---|
| 711 | #endif |
|---|
| 712 | memcpy(p,msyyp+xseek,n); |
|---|
| 713 | } |
|---|
| 714 | } |
|---|
| 715 | |
|---|
| 716 | #if CNV_PCBINUM |
|---|
| 717 | ConvertMST_LEADER(MFX,MSNVSPLT,LEADER); /* CNV_PCFILES ok */ |
|---|
| 718 | #endif |
|---|
| 719 | |
|---|
| 720 | #if VAX |
|---|
| 721 | d = MFRbase - (LEADER + MFRnvf*sizeof(DIRSTRU)); |
|---|
| 722 | if (d) if (d < 0 || d > sizeof(int)) { |
|---|
| 723 | if (rectrace) prtleader(recp,mfn); |
|---|
| 724 | #else |
|---|
| 725 | if (MFRbase != LEADER + MFRnvf*sizeof(DIRSTRU)) { |
|---|
| 726 | #endif |
|---|
| 727 | #if RERTRACE |
|---|
| 728 | if (rectrace) prtleader(recp,mfn); |
|---|
| 729 | #endif |
|---|
| 730 | fatal("recread/check/base"); |
|---|
| 731 | } |
|---|
| 732 | |
|---|
| 733 | #if CNV_PCBINUM |
|---|
| 734 | if (wlen != 1) ConvertMST_DIR(MFX,MFRnvf); |
|---|
| 735 | #endif |
|---|
| 736 | |
|---|
| 737 | #if MULTI |
|---|
| 738 | /* step 4: perform a record lock (MFR) */ |
|---|
| 739 | if (REClock) { |
|---|
| 740 | if (rc != RCLOCK) { |
|---|
| 741 | /* mfr lock */ |
|---|
| 742 | MFRmfrl=(FFI)0-MFRmfrl; /* set */ |
|---|
| 743 | xseek=(((off_t)(comb-1))<<MSBSHIFT); xseek+=comp; |
|---|
| 744 | if (LSEEK64(fd,xseek,SEEK_SET) != xseek) |
|---|
| 745 | fatal("recread/lock/lseek/mfr"); |
|---|
| 746 | #if CNV_PCFILES |
|---|
| 747 | memcpy(unibuff,MFX,MSNVSPLT); |
|---|
| 748 | memcpy(MFX+0,unibuff+0,4); /* mfn= */ |
|---|
| 749 | memcpy(MFX+6,unibuff+4,4); /* mfbwb= */ |
|---|
| 750 | memcpy(MFX+4,unibuff+8,2); /* mfrl= */ |
|---|
| 751 | #endif |
|---|
| 752 | #if CNV_PCBINUM |
|---|
| 753 | memcpy(cnv_pcbuff,MFX,MSNVSPLT); |
|---|
| 754 | ConvertMST_LEADER(cnv_pcbuff,0,MSNVSPLT); |
|---|
| 755 | if (CIWRITE(fd,cnv_pcbuff,MSNVSPLT) != MSNVSPLT) |
|---|
| 756 | #else |
|---|
| 757 | if (CIWRITE(fd,MFX,MSNVSPLT) != MSNVSPLT) |
|---|
| 758 | #endif |
|---|
| 759 | fatal("recread/lock/write/mfr"); |
|---|
| 760 | #if CNV_PCFILES |
|---|
| 761 | memcpy(MFX,unibuff,MSNVSPLT); |
|---|
| 762 | #endif |
|---|
| 763 | RECgdbl=RECgdbw=MFRmfrl; |
|---|
| 764 | MFRmfrl=(FFI)0-MFRmfrl; /* reset */ |
|---|
| 765 | /* update input buffer */ |
|---|
| 766 | if (comb != DBXmsibp->msbufn) fatal("recread/lock/msbufn"); |
|---|
| 767 | p=(char *)DBXmsibp; p+=comp; |
|---|
| 768 | ((M1STRU *)p)->m1mfrl=RECgdbl; |
|---|
| 769 | } |
|---|
| 770 | /* .mst file lock: unlock */ |
|---|
| 771 | if (multrace) |
|---|
| 772 | if (rc == RCLOCK) |
|---|
| 773 | printf("<r> %s .mst unlock [RL denied] \n",DBXname); |
|---|
| 774 | else |
|---|
| 775 | printf("<r> %s .mst unlock [RL on] \n",DBXname); |
|---|
| 776 | if (dbxulock(dbxp,"M")) fatal("recread/lock/file unlock/mfr"); |
|---|
| 777 | } |
|---|
| 778 | #endif |
|---|
| 779 | |
|---|
| 780 | return(RECrc=rc); |
|---|
| 781 | } |
|---|
| 782 | |
|---|
| 783 | |
|---|
| 784 | #if CICPP |
|---|
| 785 | int RECSTRU :: xrecxref(LONGX mfn, |
|---|
| 786 | LONGX *comb, |
|---|
| 787 | int *comp) |
|---|
| 788 | #else /* CICPP */ |
|---|
| 789 | int recxref(recp,mfn,comb,comp) /* |
|---|
| 790 | ----------- |
|---|
| 791 | seta dbxp; |
|---|
| 792 | chama dbxopen para dbxp->dbxname+.xrf se necessario; |
|---|
| 793 | aloca dbxp->dbxxribp, se ainda nao alocado; |
|---|
| 794 | abenda se mfn < 1; |
|---|
| 795 | calcula .xrf blk = f(mfn); |
|---|
| 796 | posiciona e le .xrf blk, se nao o carregado; |
|---|
| 797 | seta *comb e *comp; |
|---|
| 798 | retorna gdb record rc |
|---|
| 799 | */ |
|---|
| 800 | RECSTRU *recp; /* elemento de vrecp, para info */ |
|---|
| 801 | LONGX mfn; /* numero do registro a ler */ |
|---|
| 802 | LONGX *comb; /* block number of MF block containing the rec */ |
|---|
| 803 | int *comp; /* offset in block of 1st char position of MFR */ |
|---|
| 804 | #endif /* CICPP */ |
|---|
| 805 | { |
|---|
| 806 | DBXSTRU *dbxp; |
|---|
| 807 | |
|---|
| 808 | int rc; |
|---|
| 809 | FFI n; |
|---|
| 810 | LONGX newpos; |
|---|
| 811 | LONGX xrftiv; |
|---|
| 812 | LONGX xrftiva; |
|---|
| 813 | |
|---|
| 814 | off_t xbyte; |
|---|
| 815 | char *xryyp; /* v3.3 */ |
|---|
| 816 | |
|---|
| 817 | #if CICPP |
|---|
| 818 | RECSTRU *recp = this; |
|---|
| 819 | #endif /* CICPP */ |
|---|
| 820 | |
|---|
| 821 | dbxp=RECdbxp; |
|---|
| 822 | |
|---|
| 823 | if ((xryyp=DBXxryyp) == NULL) /* v3.3 */ |
|---|
| 824 | if (!DBXxropn) |
|---|
| 825 | fatal("recxref/DBXxropn"); |
|---|
| 826 | |
|---|
| 827 | if (!DBXxribp) |
|---|
| 828 | fatal("recxref/DBXxribp"); |
|---|
| 829 | |
|---|
| 830 | #if REXTRACE |
|---|
| 831 | printf("recxref - DBXxribp->xrxrpos=%"_LD_"\n",DBXxribp->xrxrpos); |
|---|
| 832 | #endif |
|---|
| 833 | |
|---|
| 834 | if (mfn < 1) |
|---|
| 835 | fatal("recxref/mfn"); |
|---|
| 836 | |
|---|
| 837 | if (DBXmsmfn <= 0) /* v3.0 */ |
|---|
| 838 | fatal("recxref/DBXmsmfn"); |
|---|
| 839 | |
|---|
| 840 | newpos=(mfn+XRMAXTV1)/XRMAXTIV; |
|---|
| 841 | #if MULTI |
|---|
| 842 | if (DBXnetws != MONONETS || newpos != labs(DBXxribp->xrxrpos)) { |
|---|
| 843 | #else |
|---|
| 844 | if (newpos != labs(DBXxribp->xrxrpos)) { |
|---|
| 845 | #endif |
|---|
| 846 | if (mfn > DBXmsmfn) { /* 127 ok */ |
|---|
| 847 | DBXxribp->xrxrpos = -newpos; |
|---|
| 848 | xrftiv = (0)*XRXDIVIDE + (0); /* inexistent records */ |
|---|
| 849 | for (n=0; n < XRMAXTIV; ) |
|---|
| 850 | DBXxribp->xrmfptr[n++]=xrftiv; |
|---|
| 851 | #if REXTRACE |
|---|
| 852 | printf("recxref - para mfn=%"_LD_" xrpos=%"_LD_" xrftiv=%"_LD_"\n",mfn, |
|---|
| 853 | DBXxribp->xrxrpos,xrftiv); |
|---|
| 854 | #endif |
|---|
| 855 | } |
|---|
| 856 | else { |
|---|
| 857 | xbyte=((off_t)(newpos-1))<<XRSHIFT; |
|---|
| 858 | if (xryyp == NULL) { |
|---|
| 859 | if (LSEEK64(DBXxropn,xbyte,SEEK_SET) != xbyte) |
|---|
| 860 | fatal("recxref/lseek"); |
|---|
| 861 | #if REXTRACE |
|---|
| 862 | printf("recxref - mfn=%"_LD_" newpos=%"_LD_" lseek=%"P_OFF_T" DBXmsmfn=%"_LD_"\n", |
|---|
| 863 | mfn,newpos,(LONG_LONG)xbyte,DBXmsmfn); |
|---|
| 864 | #endif |
|---|
| 865 | if ((n=CIREAD(DBXxropn,(char *)DBXxribp,XRBSIZ)) != XRBSIZ) |
|---|
| 866 | fatal("recxref/read"); |
|---|
| 867 | } |
|---|
| 868 | else { |
|---|
| 869 | #if REXTRACE |
|---|
| 870 | printf("recxref - xryyp=%p mfn=%"_LD_" newpos=%"_LD_" lseek=%"P_OFF_T" DBXmsmfn=%"_LD_"\n", |
|---|
| 871 | xryyp,mfn,newpos,(LONG_LONG)xbyte,DBXmsmfn); |
|---|
| 872 | #endif |
|---|
| 873 | xryyp+=(xbyte); |
|---|
| 874 | n=XRBSIZ; |
|---|
| 875 | memcpy((char *)DBXxribp,xryyp,(size_t)n); |
|---|
| 876 | } |
|---|
| 877 | #if CNV_PCBINUM |
|---|
| 878 | ConvertXRF_REC((char *)DBXxribp); |
|---|
| 879 | #endif |
|---|
| 880 | } |
|---|
| 881 | |
|---|
| 882 | if (labs(DBXxribp->xrxrpos) != newpos) |
|---|
| 883 | fatal("recxref/xrfpos"); |
|---|
| 884 | } |
|---|
| 885 | |
|---|
| 886 | xrftiv=DBXxribp->xrmfptr[(mfn-1)%XRMAXTIV]; |
|---|
| 887 | xrftiva=labs(xrftiv); |
|---|
| 888 | #if DBXMSTXL |
|---|
| 889 | *comb = xrftiv / (XRXDIVIDE>>DBXmstxl); |
|---|
| 890 | *comp = xrftiva & (XRXMASK>>DBXmstxl); |
|---|
| 891 | *comp = *comp << DBXmstxl; |
|---|
| 892 | recxrefn = xrftiva & (XRXMASKN>>DBXmstxl); |
|---|
| 893 | recxrefm = xrftiva & (XRXMASKU>>DBXmstxl); |
|---|
| 894 | recxrefn = recxrefn<<DBXmstxl; /* 1024 */ |
|---|
| 895 | recxrefm = recxrefm<<DBXmstxl; /* 512 */ |
|---|
| 896 | #else |
|---|
| 897 | *comb = xrftiv / XRXDIVIDE; |
|---|
| 898 | *comp = xrftiva & XRXMASK; |
|---|
| 899 | recxrefn = xrftiva & XRXMASKN; |
|---|
| 900 | recxrefm = xrftiva & XRXMASKU; |
|---|
| 901 | #endif |
|---|
| 902 | |
|---|
| 903 | #if 1 /* REXTRACE */ |
|---|
| 904 | if (rectrace) |
|---|
| 905 | printf("recxref - mfn=%"_LD_" xrftiv=%"_LD_",%08lx comb=%"_LD_" comp=%d (n=%d m=%d)\n", |
|---|
| 906 | mfn,xrftiv,xrftiv,*comb,*comp,recxrefn,recxrefm); |
|---|
| 907 | #endif |
|---|
| 908 | |
|---|
| 909 | if (*comp+MSNVSPLT > MSBSIZ) |
|---|
| 910 | fatal("recxref/comp+MSNVSPLT"); |
|---|
| 911 | |
|---|
| 912 | if (*comb == 0) |
|---|
| 913 | if (*comp != 0) |
|---|
| 914 | fatal("recxref/comb=0/comp"); |
|---|
| 915 | |
|---|
| 916 | if (*comb != 0) |
|---|
| 917 | if (*comb > 0) |
|---|
| 918 | rc=RCNORMAL; /* Record Active */ |
|---|
| 919 | else { |
|---|
| 920 | rc=RCLDEL; /* Record Logical Deleted */ |
|---|
| 921 | if (*comb == -1) |
|---|
| 922 | if (*comp == 0) |
|---|
| 923 | rc=RCPDEL; /* Record Physical Deleted */ |
|---|
| 924 | *comb= -(*comb); |
|---|
| 925 | } |
|---|
| 926 | else |
|---|
| 927 | rc=RCEOF; /* End of File */ |
|---|
| 928 | |
|---|
| 929 | #if REXTRACE |
|---|
| 930 | printf("recxref - xrftiv=%"_LD_,"%08lx comb=%"_LD_" comp=%d rc=%d\n", |
|---|
| 931 | xrftiv,xrftiv,*comb,*comp,rc); |
|---|
| 932 | printf("recxref - flagnew=%d flagmod=%d\n",recxrefn,recxrefm); |
|---|
| 933 | #endif |
|---|
| 934 | |
|---|
| 935 | recxrefb = *comb; |
|---|
| 936 | recxrefp = *comp; |
|---|
| 937 | |
|---|
| 938 | return(rc); |
|---|
| 939 | } |
|---|
| 940 | |
|---|
| 941 | |
|---|
| 942 | |
|---|
| 943 | /* ----------------------------- fld.c ------------------------------ */ |
|---|
| 944 | |
|---|
| 945 | #define FLDTRACE 0 |
|---|
| 946 | |
|---|
| 947 | #if CICPP |
|---|
| 948 | int RECSTRU :: xnocc(int tag) |
|---|
| 949 | #else /* CICPP */ |
|---|
| 950 | int nocc(irec,tag) /* |
|---|
| 951 | -------- |
|---|
| 952 | seta recp=vrec[irec]; |
|---|
| 953 | aponta inicio do diretorio do registro recp; |
|---|
| 954 | pesquisa sequencialmente todas as entradas; |
|---|
| 955 | retorna o numero de ocorrencias desse tag |
|---|
| 956 | */ |
|---|
| 957 | LONGX irec; /* indice de vrecp */ |
|---|
| 958 | int tag; /* tag field */ |
|---|
| 959 | #endif /* CICPP */ |
|---|
| 960 | { |
|---|
| 961 | RECSTRU *recp; /* elemento de vrecp */ |
|---|
| 962 | |
|---|
| 963 | int loop,n; |
|---|
| 964 | DIRSTRU *dirp; |
|---|
| 965 | |
|---|
| 966 | #if CICPP |
|---|
| 967 | recp=this; |
|---|
| 968 | #else /* CICPP */ |
|---|
| 969 | recp=vrecp[irec]; |
|---|
| 970 | #endif /* CICPP */ |
|---|
| 971 | |
|---|
| 972 | for (n=0, dirp=MFRdir, loop=MFRnvf; loop--; dirp++) { |
|---|
| 973 | |
|---|
| 974 | if (dirp->tag == tag) n++; |
|---|
| 975 | |
|---|
| 976 | #if FLDTRACE |
|---|
| 977 | printf("nocc - recp=%p tag=%d loop=%d dirp=%p dirp->tag=%d n=%d\n", |
|---|
| 978 | recp,tag,loop,dirp,dirp->tag,n); |
|---|
| 979 | #endif |
|---|
| 980 | } |
|---|
| 981 | |
|---|
| 982 | #if FLDTRACE |
|---|
| 983 | printf("nocc - recp=%p tag=%d n=%d\n", |
|---|
| 984 | recp,tag,n); |
|---|
| 985 | #endif |
|---|
| 986 | |
|---|
| 987 | return(n); |
|---|
| 988 | } |
|---|
| 989 | |
|---|
| 990 | |
|---|
| 991 | #if CICPP |
|---|
| 992 | int RECSTRU :: xfieldn(int tag, |
|---|
| 993 | int occ) |
|---|
| 994 | #else /* CICPP */ |
|---|
| 995 | int fieldn(irec,tag,occ) /* |
|---|
| 996 | ---------- |
|---|
| 997 | seta recp=vrec[irec]; |
|---|
| 998 | aponta inicio do diretorio do registro recp; |
|---|
| 999 | pesquisa sequencialmente as entradas; |
|---|
| 1000 | retorna zero ou o numero de ordem dessa ocorrencia |
|---|
| 1001 | */ |
|---|
| 1002 | LONGX irec; /* indice de vrecp */ |
|---|
| 1003 | int tag; /* tag field */ |
|---|
| 1004 | int occ; /* ocorrencia */ |
|---|
| 1005 | #endif /* CICPP */ |
|---|
| 1006 | { |
|---|
| 1007 | RECSTRU *recp; /* elemento de vrecp */ |
|---|
| 1008 | |
|---|
| 1009 | int loop,n,fn; |
|---|
| 1010 | DIRSTRU *dirp; |
|---|
| 1011 | |
|---|
| 1012 | #if CICPP |
|---|
| 1013 | recp=this; |
|---|
| 1014 | #else /* CICPP */ |
|---|
| 1015 | recp=vrecp[irec]; |
|---|
| 1016 | #endif /* CICPP */ |
|---|
| 1017 | |
|---|
| 1018 | for (fn=n=0, dirp=MFRdir, loop=MFRnvf; loop--; dirp++) { |
|---|
| 1019 | |
|---|
| 1020 | if (dirp->tag == tag) n++; |
|---|
| 1021 | |
|---|
| 1022 | #if FLDTRACE |
|---|
| 1023 | printf("fieldn - recp=%p tag=%d occ=%d loop=%d dirp->tag=%d n=%d\n", |
|---|
| 1024 | recp,tag,occ,loop,dirp->tag,n); |
|---|
| 1025 | #endif |
|---|
| 1026 | if (n == occ) { |
|---|
| 1027 | fn=MFRnvf-loop; /* already decremented */ |
|---|
| 1028 | break; |
|---|
| 1029 | } |
|---|
| 1030 | } |
|---|
| 1031 | |
|---|
| 1032 | #if FLDTRACE |
|---|
| 1033 | printf("fieldn - recp=%p tag=%d occ=%d n=%d fn=%d\n", |
|---|
| 1034 | recp,tag,occ,n,fn); |
|---|
| 1035 | #endif |
|---|
| 1036 | |
|---|
| 1037 | return(fn); |
|---|
| 1038 | } |
|---|
| 1039 | |
|---|
| 1040 | |
|---|
| 1041 | #if CICPP |
|---|
| 1042 | int RECSTRU :: xfieldx(int tag, |
|---|
| 1043 | int occ) |
|---|
| 1044 | #else /* CICPP */ |
|---|
| 1045 | int fieldx(irec,tag,occ) /* |
|---|
| 1046 | ---------- |
|---|
| 1047 | seta recp=vrec[irec]; |
|---|
| 1048 | aponta inicio do diretorio do registro recp; |
|---|
| 1049 | pesquisa sequencialmente as entradas; |
|---|
| 1050 | retorna RCEOF ou o indice no diretorio dessa ocorrencia |
|---|
| 1051 | */ |
|---|
| 1052 | LONGX irec; /* indice de vrecp */ |
|---|
| 1053 | int tag; /* tag field */ |
|---|
| 1054 | int occ; /* ocorrencia */ |
|---|
| 1055 | #endif /* CICPP */ |
|---|
| 1056 | { |
|---|
| 1057 | RECSTRU *recp; /* elemento de vrecp */ |
|---|
| 1058 | |
|---|
| 1059 | int loop,n,fx; |
|---|
| 1060 | DIRSTRU *dirp; |
|---|
| 1061 | |
|---|
| 1062 | #if CICPP |
|---|
| 1063 | recp=this; |
|---|
| 1064 | #else /* CICPP */ |
|---|
| 1065 | recp=vrecp[irec]; |
|---|
| 1066 | #endif /* CICPP */ |
|---|
| 1067 | |
|---|
| 1068 | for (fx=RCEOF, n=0, dirp=MFRdir, loop=MFRnvf; loop--; dirp++) { |
|---|
| 1069 | |
|---|
| 1070 | if (dirp->tag == tag) n++; |
|---|
| 1071 | |
|---|
| 1072 | #if FLDTRACE |
|---|
| 1073 | printf("fieldx - recp=%p tag=%d occ=%d loop=%d dirp->tag=%d n=%d\n" |
|---|
| 1074 | recp,tag,occ,loop,dirp->tag,n); |
|---|
| 1075 | #endif |
|---|
| 1076 | if (n == occ) { |
|---|
| 1077 | fx=MFRnvf-loop-1; /* already decremented */ |
|---|
| 1078 | break; |
|---|
| 1079 | } |
|---|
| 1080 | } |
|---|
| 1081 | |
|---|
| 1082 | #if FLDTRACE |
|---|
| 1083 | printf("fieldx - recp=%p tag=%d occ=%d n=%d fx=%d\n", |
|---|
| 1084 | recp,tag,occ,n,fx); |
|---|
| 1085 | #endif |
|---|
| 1086 | |
|---|
| 1087 | return(fx); |
|---|
| 1088 | } |
|---|
| 1089 | |
|---|
| 1090 | |
|---|
| 1091 | #if CICPP |
|---|
| 1092 | void RECSTRU :: xmstsetup(char *dbnamp, |
|---|
| 1093 | LONGX loadxrf, |
|---|
| 1094 | LONGX loadmst) |
|---|
| 1095 | #else /* CICPP */ |
|---|
| 1096 | void mstsetup(dbnamp,loadxrf,loadmst) /* |
|---|
| 1097 | ------------- |
|---|
| 1098 | seta dbxp; |
|---|
| 1099 | abre .xrf; |
|---|
| 1100 | se loadxrf inicializa estrutura xy e carrega e fecha .xrf; |
|---|
| 1101 | abre .mst |
|---|
| 1102 | se loadmst inicializa estrutura my e carrega e fecha .mst; |
|---|
| 1103 | */ |
|---|
| 1104 | char *dbnamp; /* ptr nome base de dados a ler */ /* v3.3 */ |
|---|
| 1105 | LONGX loadxrf; /* carga total de .xrf */ /* v3.3 */ |
|---|
| 1106 | LONGX loadmst; /* carga total de .mst */ /* v3.3 */ |
|---|
| 1107 | #endif /* CICPP */ |
|---|
| 1108 | { |
|---|
| 1109 | DBXSTRU *dbxp; |
|---|
| 1110 | int fd; |
|---|
| 1111 | char *p; |
|---|
| 1112 | FFI pagesize; |
|---|
| 1113 | off_t npages,nbytes,loop; |
|---|
| 1114 | |
|---|
| 1115 | if (rec_mstload) loadxrf=loadmst=rec_mstload; /* 28/03/97 */ |
|---|
| 1116 | |
|---|
| 1117 | dbxp=dbxstorp(dbnamp); |
|---|
| 1118 | |
|---|
| 1119 | #if RESXRACE |
|---|
| 1120 | if (rectrace) { |
|---|
| 1121 | if (!DBXxropn && DBXxryyp == NULL || |
|---|
| 1122 | !DBXmsopn && DBXmsyyp == NULL) |
|---|
| 1123 | printf("mstsetup - %s [%p]\n",dbnamp,dbxp); |
|---|
| 1124 | } |
|---|
| 1125 | #endif |
|---|
| 1126 | |
|---|
| 1127 | #if BEFORE950102 |
|---|
| 1128 | DBXxropn=DBXxropw=0; |
|---|
| 1129 | DBXxryyp=NULL; |
|---|
| 1130 | #endif |
|---|
| 1131 | |
|---|
| 1132 | if (strcmp(DBXname,"null") != 0 && !DBXxropn && DBXxryyp == NULL) { |
|---|
| 1133 | fd=DBXxropn=dbxopen(DBXname,DBXname,xx1extp); if (dbxordwr) DBXxropw++; |
|---|
| 1134 | pagesize=XRBSIZ; |
|---|
| 1135 | if (loadxrf) { |
|---|
| 1136 | #if MULTI |
|---|
| 1137 | if (DBXnetws != MONONETS) fatal("mstsetup/loadxrf/MULTI"); |
|---|
| 1138 | #endif |
|---|
| 1139 | nbytes=LSEEK64(fd,0L,SEEK_END); LSEEK64(fd,0L,SEEK_SET); |
|---|
| 1140 | npages=nbytes/pagesize; |
|---|
| 1141 | if (loadxrf > ALLOMAXV) |
|---|
| 1142 | fatal("mstsetup/ALLOMAXV/.xrf"); |
|---|
| 1143 | if (nbytes <= loadxrf) { |
|---|
| 1144 | #if CICPP |
|---|
| 1145 | try { DBXxryyp= new char [nbytes]; } |
|---|
| 1146 | catch (BAD_ALLOC) { DBXxryyp = (char *)ALLONULL; } |
|---|
| 1147 | #else /* CICPP */ |
|---|
| 1148 | DBXxryyp=(char *)ALLOC((ALLOPARM)(nbytes)); |
|---|
| 1149 | #endif /* CICPP */ |
|---|
| 1150 | if (DBXxryyp == (char *)ALLONULL) |
|---|
| 1151 | fatal("mstsetup/ALLOC/xypages"); |
|---|
| 1152 | #if RESTRACE |
|---|
| 1153 | if (rectrace) { |
|---|
| 1154 | printf("mstsetup - DBXxryyp =%p %6Ld/%6Ld=%6Ld bytes/pages fd=%d\n", |
|---|
| 1155 | DBXxryyp,(double)nbytes,(double)npages,(double)nbytes/npages,fd); |
|---|
| 1156 | } |
|---|
| 1157 | #endif |
|---|
| 1158 | for (p=DBXxryyp, loop=npages; loop--; p+=pagesize) |
|---|
| 1159 | if (CIREAD(fd,p,pagesize) != pagesize) |
|---|
| 1160 | fatal("mstsetup/read/xypages"); |
|---|
| 1161 | CLOSE(fd); DBXxropn=DBXxropw=0; |
|---|
| 1162 | } |
|---|
| 1163 | } |
|---|
| 1164 | } |
|---|
| 1165 | |
|---|
| 1166 | if (!DBXxribp) { |
|---|
| 1167 | #if CICPP |
|---|
| 1168 | try { DBXxribp=(XRSTRU *) new char [XRBSIZ]; } |
|---|
| 1169 | catch (BAD_ALLOC) { DBXxribp = (XRSTRU *)ALLONULL; } |
|---|
| 1170 | #else /* CICPP */ |
|---|
| 1171 | DBXxribp=(XRSTRU *)ALLOC((ALLOPARM)(XRBSIZ)); |
|---|
| 1172 | #endif /* CICPP */ |
|---|
| 1173 | if (DBXxribp == (XRSTRU *)ALLONULL) fatal("mstsetup/ALLOC/xribp"); |
|---|
| 1174 | memset(DBXxribp,0x00,(size_t)XRBSIZ), |
|---|
| 1175 | DBXxribp->xrxrpos=0; |
|---|
| 1176 | #if REYTRACE |
|---|
| 1177 | printf("mstsetup - DBXxryyp =%p DBXxropn=%d DBXxribp=%p [%"_LD_"]\n", |
|---|
| 1178 | DBXxryyp,DBXxropn,DBXxribp,DBXmsmfn); |
|---|
| 1179 | #endif |
|---|
| 1180 | } |
|---|
| 1181 | |
|---|
| 1182 | #if BEFORE950102 |
|---|
| 1183 | DBXmsopn=DBXmsopw=DBXmsopv=0; |
|---|
| 1184 | DBXmsyyp=NULL; |
|---|
| 1185 | #endif |
|---|
| 1186 | |
|---|
| 1187 | if (strcmp(DBXname,"null") != 0 && !DBXmsopn && DBXmsyyp == NULL) { |
|---|
| 1188 | fd=DBXmsopn=dbxopen(DBXname,DBXname,mx1extp); if (dbxordwr) DBXmsopw++; |
|---|
| 1189 | pagesize=MSBSIZ; |
|---|
| 1190 | if (loadmst) { |
|---|
| 1191 | #if MULTI |
|---|
| 1192 | if (DBXnetws != MONONETS) fatal("mstsetup/loadmst/MULTI"); |
|---|
| 1193 | #endif |
|---|
| 1194 | nbytes=LSEEK64(fd,0L,SEEK_END); LSEEK64(fd,0L,SEEK_SET); |
|---|
| 1195 | npages=nbytes/pagesize; |
|---|
| 1196 | if (loadmst > ALLOMAXV) |
|---|
| 1197 | fatal("mstsetup/ALLOMAXV/.mst"); |
|---|
| 1198 | if (nbytes <= loadmst) { |
|---|
| 1199 | #if CICPP |
|---|
| 1200 | try { DBXmsyyp= new char [nbytes]; } |
|---|
| 1201 | catch (BAD_ALLOC) { DBXmsyyp = (char *)ALLONULL; } |
|---|
| 1202 | #else /* CICPP */ |
|---|
| 1203 | DBXmsyyp=(char *)ALLOC((ALLOPARM)(nbytes)); |
|---|
| 1204 | #endif /* CICPP */ |
|---|
| 1205 | if (DBXmsyyp == (char *)ALLONULL) |
|---|
| 1206 | fatal("mstsetup/ALLOC/mypages"); |
|---|
| 1207 | #if RESTRACE |
|---|
| 1208 | if (rectrace) { |
|---|
| 1209 | printf("mstsetup - DBXmsyyp =%p %6"_LD_"/%6"_LD_"=%6"_LD_" bytes/pages fd=%d\n", |
|---|
| 1210 | DBXmsyyp,nbytes,npages,nbytes/npages,fd); |
|---|
| 1211 | } |
|---|
| 1212 | #endif |
|---|
| 1213 | for (p=DBXmsyyp, loop=npages; loop--; p+=pagesize) |
|---|
| 1214 | if (CIREAD(fd,p,pagesize) != pagesize) |
|---|
| 1215 | fatal("mstsetup/read/mypages"); |
|---|
| 1216 | } |
|---|
| 1217 | } |
|---|
| 1218 | } |
|---|
| 1219 | |
|---|
| 1220 | if (!DBXmsibp) { |
|---|
| 1221 | #if CICPP |
|---|
| 1222 | try { DBXmsibp=(MSSTRU *)new char [sizeof(MSSTRU)]; } |
|---|
| 1223 | catch (BAD_ALLOC) { DBXmsibp = (MSSTRU *)ALLONULL; } |
|---|
| 1224 | #else /* CICPP */ |
|---|
| 1225 | DBXmsibp=(MSSTRU *)ALLOC((ALLOPARM)sizeof(MSSTRU)); |
|---|
| 1226 | #endif /* CICPP */ |
|---|
| 1227 | if (DBXmsibp == (MSSTRU *)ALLONULL) fatal("mstsetup/ALLOC/msibp"); |
|---|
| 1228 | memset(DBXmsibp,0x00,sizeof(MSSTRU)); |
|---|
| 1229 | |
|---|
| 1230 | if (strcmp(DBXname,"null") != 0) { |
|---|
| 1231 | if (!DBXmsopn) fatal("mstsetup/DBXmsopn"); |
|---|
| 1232 | if (LSEEK64(DBXmsopn,SEEK_SET,0L)) fatal("mstsetup/seek/msibp"); |
|---|
| 1233 | if (CIREAD(DBXmsopn,DBXmsibp,MSBSIZ) != MSBSIZ) |
|---|
| 1234 | fatal("mstsetup/read/msibp"); |
|---|
| 1235 | DBXmsibp->msbufn=1; |
|---|
| 1236 | DBXmsmfn=((M0STRU *)DBXmsibp)->m0nxtmfn; |
|---|
| 1237 | #if DBXMSTXL |
|---|
| 1238 | /* DBXmstxl = ((M0STRU *)DBXmsibp)->m0mftype / 0x00FF; NAO 255*/ |
|---|
| 1239 | DBXmstxl = ((M0STRU *)DBXmsibp)->m0mftype / 256; /* AOT/AARG 05/01/99 */ |
|---|
| 1240 | if (rectrace) printf("+++ recread - %s/mstxl=%d\n",DBXname,DBXmstxl); |
|---|
| 1241 | // if (DBXmstxl > 3) fatal("mstsetup/DBXmstxl"); |
|---|
| 1242 | #endif |
|---|
| 1243 | } |
|---|
| 1244 | #if REYTRACE |
|---|
| 1245 | printf("mstsetup - DBXmsyyp =%p DBXmsopn=%d DBXmsibp=%p [%"_LD_"]\n", |
|---|
| 1246 | DBXmsyyp,DBXmsopn,DBXmsibp,DBXmsmfn); |
|---|
| 1247 | #endif |
|---|
| 1248 | } |
|---|
| 1249 | if (DBXmsopn) |
|---|
| 1250 | if (DBXmsyyp) {CLOSE(DBXmsopn); DBXmsopn=DBXmsopw=DBXmsopv=0; } |
|---|
| 1251 | |
|---|
| 1252 | return; |
|---|
| 1253 | } |
|---|
| 1254 | |
|---|
| 1255 | /* ------------ Substitutes the macros RECORD and RECALLOC ----------------*/ |
|---|
| 1256 | #if HBARB |
|---|
| 1257 | #if CICPP |
|---|
| 1258 | |
|---|
| 1259 | RECSTRU * RECSTRU :: xRecord (char *dbname, |
|---|
| 1260 | LONGX mfn) |
|---|
| 1261 | { |
|---|
| 1262 | xrecord(dbname,mfn); |
|---|
| 1263 | return this; |
|---|
| 1264 | } |
|---|
| 1265 | |
|---|
| 1266 | RECSTRU * RECSTRU :: xRecAlloc (LONGX nbytes) |
|---|
| 1267 | { |
|---|
| 1268 | xrecalloc(nbytes); |
|---|
| 1269 | return this; |
|---|
| 1270 | } |
|---|
| 1271 | |
|---|
| 1272 | #endif /* CICPP */ |
|---|
| 1273 | #endif /* HBARB */ |
|---|
| 1274 | /* ------------------------------------------------------------------------*/ |
|---|