| 1 | /* ------------------------------ decs9b.c ----------------------------- */ |
|---|
| 2 | |
|---|
| 3 | /* ======================================================================== |
|---|
| 4 | Link file generation for the MeSH Headings field - STEP b |
|---|
| 5 | |
|---|
| 6 | Author: decs9a.c/AOT, Oct 31 1990 (Halloween) |
|---|
| 7 | |
|---|
| 8 | Alter: AOT/RSP, 07/03/94 |
|---|
| 9 | 1. Parametro -bug2 (para LILACS !!!) |
|---|
| 10 | ======================================================================== */ |
|---|
| 11 | |
|---|
| 12 | #include <stdio.h> |
|---|
| 13 | #include <string.h> |
|---|
| 14 | |
|---|
| 15 | #include "cisis.h" /* CISIS Interface */ |
|---|
| 16 | #include "cirun.h" /* runtime area and defines by AOT */ |
|---|
| 17 | |
|---|
| 18 | #define TRACE 0 |
|---|
| 19 | #define TRACEUC 0 |
|---|
| 20 | #define TRACEAC 0 |
|---|
| 21 | |
|---|
| 22 | #if PC && !DOS32BITS |
|---|
| 23 | #define OPEN30 1 |
|---|
| 24 | #endif |
|---|
| 25 | #if OPEN30 |
|---|
| 26 | #include <dos.h> |
|---|
| 27 | #endif |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | /* DECS */ |
|---|
| 31 | |
|---|
| 32 | #define TOFFSET 700 |
|---|
| 33 | #define TAGTING (1+TOFFSET) |
|---|
| 34 | #define TAGTESP (2+TOFFSET) |
|---|
| 35 | #define TAGTPOR (3+TOFFSET) |
|---|
| 36 | #define TAGPROI (50+TOFFSET) |
|---|
| 37 | #define TAGCATN 720 |
|---|
| 38 | |
|---|
| 39 | #define TAGQUAL 14 /* CHECK /xx */ |
|---|
| 40 | |
|---|
| 41 | char delim[] = { 'i','e','p' }; /* 1st = Author */ |
|---|
| 42 | |
|---|
| 43 | #define wx(tag) ((tag != TAGCATN) ? (tag-TOFFSET-1) : 3) |
|---|
| 44 | |
|---|
| 45 | char wxchr[] = { 'i','e','p','c' }; |
|---|
| 46 | |
|---|
| 47 | LONGX totpost; |
|---|
| 48 | int totpmfnok[sizeof(wxchr)]; |
|---|
| 49 | |
|---|
| 50 | int optbug2=0; |
|---|
| 51 | |
|---|
| 52 | FILE *fplst; |
|---|
| 53 | int fdout[4]; |
|---|
| 54 | |
|---|
| 55 | char *dbnp; |
|---|
| 56 | char *decs,*l1Ip,*l2Ip,*l1Ep,*l2Ep,*l1Pp,*l2Pp,*l1Cp,*l2Cp; |
|---|
| 57 | |
|---|
| 58 | int vfd[4][2]; |
|---|
| 59 | LONGX vc[4][2] = { 0,0,0,0,0,0,0,0 }; |
|---|
| 60 | |
|---|
| 61 | #if OUTONISIS |
|---|
| 62 | LONGX crecout; /* indice registro controle saida */ |
|---|
| 63 | LONGX irecout; /* indice registro saida */ |
|---|
| 64 | #endif |
|---|
| 65 | |
|---|
| 66 | unsigned char buffup[MAXMFRL+MAXMFRL]; |
|---|
| 67 | unsigned char line[BUFSIZ],meshkey[BUFSIZ],key2[BUFSIZ],keynew[BUFSIZ]; |
|---|
| 68 | |
|---|
| 69 | unsigned char *keyinp; |
|---|
| 70 | unsigned char prefkey[BUFSIZ],qualkey[BUFSIZ]; |
|---|
| 71 | int n1,n2,n3,qualcase,prefcase,qualx; |
|---|
| 72 | int lreclx; |
|---|
| 73 | |
|---|
| 74 | #if MPE |
|---|
| 75 | int vlrecl[2]; |
|---|
| 76 | char dcb0[32],dcb1[32],dcbx[32],mpe='"'; |
|---|
| 77 | #else |
|---|
| 78 | char mpe=' '; |
|---|
| 79 | #endif |
|---|
| 80 | |
|---|
| 81 | #if OPEN30 |
|---|
| 82 | union REGS d33_regs; |
|---|
| 83 | struct SREGS d33_sregs; |
|---|
| 84 | unsigned short d33_newax,d33_n; |
|---|
| 85 | #endif |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | /* prototypes */ |
|---|
| 89 | #if ANSI |
|---|
| 90 | int outlink(LONGX mfn, int tag, int occ, int cnt, char *kp, int klen, int sn); |
|---|
| 91 | int genlk1(int occ, int tag, RECSTRU *recp, int xdir, char dlm, int sn); |
|---|
| 92 | #else |
|---|
| 93 | int outlink(); |
|---|
| 94 | int genlk1(); |
|---|
| 95 | #endif |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | /* main */ |
|---|
| 99 | #if ANSI |
|---|
| 100 | void main (int argc, char *argv[]) |
|---|
| 101 | #else |
|---|
| 102 | main(argc,argv) |
|---|
| 103 | int argc; |
|---|
| 104 | char *argv[]; |
|---|
| 105 | #endif |
|---|
| 106 | { |
|---|
| 107 | RECSTRU *recp; /* RECORD */ |
|---|
| 108 | TRMSTRU *trmp; /* TERM/NXTERM */ |
|---|
| 109 | LONGX irec; /* indice registro decs */ |
|---|
| 110 | LONGX itrm; /* indice invertido decs */ |
|---|
| 111 | LONGX itrmin; /* indice invertido entrada */ |
|---|
| 112 | LONGX mfn; |
|---|
| 113 | |
|---|
| 114 | int xdir,occ,tag; |
|---|
| 115 | |
|---|
| 116 | FILE *fp; |
|---|
| 117 | |
|---|
| 118 | LONGX ecount,count,xtell; |
|---|
| 119 | int loop,n,len; |
|---|
| 120 | unsigned char *p; |
|---|
| 121 | unsigned char *meshp,*startp; |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | #if OPEN30 |
|---|
| 125 | d33_n=32; |
|---|
| 126 | d33_regs.h.ah = 0x67; /* Set handle count */ |
|---|
| 127 | d33_regs.x.bx = d33_n; /* no of handles */ |
|---|
| 128 | d33_newax=intdosx(&d33_regs,&d33_regs,&d33_sregs); |
|---|
| 129 | if (d33_regs.x.cflag) |
|---|
| 130 | fprintf(stderr,"AX = %04x [%02d]\n",d33_newax,d33_n); |
|---|
| 131 | #endif |
|---|
| 132 | |
|---|
| 133 | if (argc < 11 || argc > 12) { |
|---|
| 134 | printf("%s",cicopyr("Utility MDL/DECS9B")); |
|---|
| 135 | printf("\n"); |
|---|
| 136 | printf("decs9b <dbB> <decs> <I1> <I2> <E1> <E2> <P1> <P2> <C1> <C2> [key1/-bug2]\n"); |
|---|
| 137 | printf("\n"); |
|---|
| 138 | printf("generate I/E/P link files for authorized english mesh headings \n"); |
|---|
| 139 | printf("from mdlmf <dbB>, according to decs <decs> \n"); |
|---|
| 140 | printf("\n"); |
|---|
| 141 | printf("\n"); |
|---|
| 142 | exit(1); |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | /* get parms */ |
|---|
| 146 | dbnp=argv[1]; |
|---|
| 147 | decs=argv[2]; |
|---|
| 148 | l1Ip=argv[3]; |
|---|
| 149 | l2Ip=argv[4]; |
|---|
| 150 | l1Ep=argv[5]; |
|---|
| 151 | l2Ep=argv[6]; |
|---|
| 152 | l1Pp=argv[7]; |
|---|
| 153 | l2Pp=argv[8]; |
|---|
| 154 | l1Cp=argv[9]; |
|---|
| 155 | l2Cp=argv[10]; |
|---|
| 156 | startp="!"; |
|---|
| 157 | if (argc > 11) { |
|---|
| 158 | if (strcmp(argv[11],"-bug2") == 0) optbug2=1; |
|---|
| 159 | else startp=argv[11]; |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | |
|---|
| 163 | /* ve invertido de entrada */ |
|---|
| 164 | TERM((itrmin=ntrms),dbnp,startp); |
|---|
| 165 | |
|---|
| 166 | xtell=(TDBifmap->cn[0].fmaxpos+TDBifmap->cn[1].fmaxpos)*TWORDF; |
|---|
| 167 | xtell/=10; |
|---|
| 168 | if (xtell < 1) |
|---|
| 169 | xtell=1; |
|---|
| 170 | if (*startp != '!') |
|---|
| 171 | xtell=1; |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | /* ve master e invertido decs */ |
|---|
| 176 | RECORD((irec=nrecs),decs,0L); |
|---|
| 177 | |
|---|
| 178 | /* ve invertido decs */ |
|---|
| 179 | TERM((itrm=ntrms),decs,"!"); |
|---|
| 180 | |
|---|
| 181 | /* open link files */ |
|---|
| 182 | #if PC || UNIX |
|---|
| 183 | vfd[0][0]=creat(l1Ip,0644); |
|---|
| 184 | vfd[0][1]=creat(l2Ip,0644); |
|---|
| 185 | vfd[1][0]=creat(l1Ep,0644); |
|---|
| 186 | vfd[1][1]=creat(l2Ep,0644); |
|---|
| 187 | vfd[2][0]=creat(l1Pp,0644); |
|---|
| 188 | vfd[2][1]=creat(l2Pp,0644); |
|---|
| 189 | vfd[3][0]=creat(l1Cp,0644); |
|---|
| 190 | vfd[3][1]=creat(l2Cp,0644); |
|---|
| 191 | #endif |
|---|
| 192 | #if MPE |
|---|
| 193 | vlrecl[0]=25+LE1; |
|---|
| 194 | vlrecl[1]=25+LE2; |
|---|
| 195 | sprintf(dcb0,"R%d Bl%d",vlrecl[0],8192/vlrecl[0]); |
|---|
| 196 | sprintf(dcb1,"R%d Bl%d",vlrecl[1],8192/vlrecl[1]); |
|---|
| 197 | vfd[0][0]=open(l1Ip,O_WRONLY|O_CREAT|O_TRUNC|O_MPEOPTS,0644,dcb0); |
|---|
| 198 | vfd[0][1]=open(l2Ip,O_WRONLY|O_CREAT|O_TRUNC|O_MPEOPTS,0644,dcb1); |
|---|
| 199 | vfd[1][0]=open(l1Ep,O_WRONLY|O_CREAT|O_TRUNC|O_MPEOPTS,0644,dcb0); |
|---|
| 200 | vfd[1][1]=open(l2Ep,O_WRONLY|O_CREAT|O_TRUNC|O_MPEOPTS,0644,dcb1); |
|---|
| 201 | vfd[2][0]=open(l1Pp,O_WRONLY|O_CREAT|O_TRUNC|O_MPEOPTS,0644,dcb0); |
|---|
| 202 | vfd[2][1]=open(l2Pp,O_WRONLY|O_CREAT|O_TRUNC|O_MPEOPTS,0644,dcb1); |
|---|
| 203 | vfd[3][0]=open(l1Cp,O_WRONLY|O_CREAT|O_TRUNC|O_MPEOPTS,0644,dcb0); |
|---|
| 204 | vfd[3][1]=open(l2Cp,O_WRONLY|O_CREAT|O_TRUNC|O_MPEOPTS,0644,dcb1); |
|---|
| 205 | #endif |
|---|
| 206 | if (vfd[0][0] == EOF) fatal(l1Ip); |
|---|
| 207 | if (vfd[0][1] == EOF) fatal(l2Ip); |
|---|
| 208 | if (vfd[1][0] == EOF) fatal(l1Ep); |
|---|
| 209 | if (vfd[1][1] == EOF) fatal(l2Ep); |
|---|
| 210 | if (vfd[2][0] == EOF) fatal(l1Pp); |
|---|
| 211 | if (vfd[2][1] == EOF) fatal(l2Pp); |
|---|
| 212 | if (vfd[3][0] == EOF) fatal(l1Cp); |
|---|
| 213 | if (vfd[3][1] == EOF) fatal(l2Cp); |
|---|
| 214 | |
|---|
| 215 | /* open lst and output files */ |
|---|
| 216 | if ((fplst =fopen("decs9b.lst", "w")) == NULL) fatal("decs9b.lst"); |
|---|
| 217 | |
|---|
| 218 | lreclx = 6+1 + LE2+1 + 1+1+1+1 + LE2+1 + 2+1+3+1 + 2+1+2+1+1+1+1+1 + 9+1; |
|---|
| 219 | |
|---|
| 220 | #if PC || UNIX |
|---|
| 221 | if ((fdout[0]=creat("decs9bI.lst",0644)) == EOF) fatal("decs9bI.lst"); |
|---|
| 222 | if ((fdout[1]=creat("decs9bE.lst",0644)) == EOF) fatal("decs9bE.lst"); |
|---|
| 223 | if ((fdout[2]=creat("decs9bP.lst",0644)) == EOF) fatal("decs9bP.lst"); |
|---|
| 224 | if ((fdout[3]=creat("decs9bC.lst",0644)) == EOF) fatal("decs9bC.lst"); |
|---|
| 225 | #endif |
|---|
| 226 | #if MPE |
|---|
| 227 | sprintf(dcbx,"R%d Bl%d",lreclx,8192/lreclx); |
|---|
| 228 | fdout[0]=open("decs9bI.lst",O_WRONLY|O_CREAT|O_TRUNC|O_MPEOPTS,0644,dcbx); |
|---|
| 229 | fdout[1]=open("decs9bE.lst",O_WRONLY|O_CREAT|O_TRUNC|O_MPEOPTS,0644,dcbx); |
|---|
| 230 | fdout[2]=open("decs9bP.lst",O_WRONLY|O_CREAT|O_TRUNC|O_MPEOPTS,0644,dcbx); |
|---|
| 231 | fdout[3]=open("decs9bC.lst",O_WRONLY|O_CREAT|O_TRUNC|O_MPEOPTS,0644,dcbx); |
|---|
| 232 | #endif |
|---|
| 233 | if (fdout[0] == EOF) fatal("decs9bI.lst"); |
|---|
| 234 | if (fdout[1] == EOF) fatal("decs9bE.lst"); |
|---|
| 235 | if (fdout[2] == EOF) fatal("decs9bP.lst"); |
|---|
| 236 | if (fdout[3] == EOF) fatal("decs9bC.lst"); |
|---|
| 237 | |
|---|
| 238 | #if OUTONISIS |
|---|
| 239 | /* create decs9b */ |
|---|
| 240 | recisis0("decs9b"); |
|---|
| 241 | record((crecout=nrecs),"decs9b",0L); |
|---|
| 242 | record((irecout=nrecs),"decs9b",1L); |
|---|
| 243 | #endif |
|---|
| 244 | |
|---|
| 245 | ecount=count=0; |
|---|
| 246 | |
|---|
| 247 | /* |
|---|
| 248 | processing loop |
|---|
| 249 | */ |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | keyinp=VTRMkey(itrmin); |
|---|
| 253 | if (*startp != '!') |
|---|
| 254 | printf("term . = %s\n",keyinp); |
|---|
| 255 | |
|---|
| 256 | for (TERM(itrmin,dbnp,keyinp); TRMrc != RCEOF; NXTERM(itrmin)) { |
|---|
| 257 | |
|---|
| 258 | totpost=TRMxytotp; |
|---|
| 259 | memset(totpmfnok,0x00,sizeof(totpmfnok)); |
|---|
| 260 | |
|---|
| 261 | |
|---|
| 262 | keyinp=VTRMkey(itrmin); |
|---|
| 263 | if (*startp != '!') |
|---|
| 264 | printf("term %"_LD_" = %s\n",count,keyinp); |
|---|
| 265 | |
|---|
| 266 | meshp=keyinp; n1=n3=0; len=n2=(TRMlcase)?LE2:LE1; |
|---|
| 267 | |
|---|
| 268 | prefcase=0; |
|---|
| 269 | if (*meshp == '.') { |
|---|
| 270 | prefkey[n1++]= *meshp; meshp++; n2--; prefcase+=1; |
|---|
| 271 | } |
|---|
| 272 | #if STRIP1STSLASH |
|---|
| 273 | if (*meshp == '/') { |
|---|
| 274 | prefkey[n1++]= *meshp; meshp++; n2--; prefcase+=2; |
|---|
| 275 | } |
|---|
| 276 | #endif |
|---|
| 277 | prefkey[n1]='\0'; |
|---|
| 278 | |
|---|
| 279 | for (p=keyinp+len; n2; ) if (*--p == ' ') n2--; else break; |
|---|
| 280 | |
|---|
| 281 | qualkey[0]='\0'; qualcase=0; |
|---|
| 282 | if (n2 <= 2) { /* tem so' ID no mfn 7242 */ /* => /xx */ |
|---|
| 283 | if (!prefcase) |
|---|
| 284 | if (*meshp != '/') |
|---|
| 285 | if (n2 <= 1) { /* => ... */ |
|---|
| 286 | printf( "+++ %"_LD_" %s -> Bug1\n",count,keyinp); |
|---|
| 287 | fprintf(fplst,"+++ %"_LD_" %s -> Bug1\n",count,keyinp); |
|---|
| 288 | fatal(keyinp); |
|---|
| 289 | } |
|---|
| 290 | } |
|---|
| 291 | else |
|---|
| 292 | if (*p == '/') { /* => .../ */ |
|---|
| 293 | qualcase=1; memcpy(qualkey,p,n3=1); qualkey[n3]='\0'; |
|---|
| 294 | n2-=n3; |
|---|
| 295 | } |
|---|
| 296 | else if (n2 >= 5 && *(p-2) == '/') { /* => .../xx */ |
|---|
| 297 | qualcase=2; memcpy(qualkey,p-2,n3=3); qualkey[n3]='\0'; |
|---|
| 298 | n2-=n3; |
|---|
| 299 | } |
|---|
| 300 | |
|---|
| 301 | |
|---|
| 302 | memcpy(meshkey,meshp,n2); meshkey[n2]='\0'; |
|---|
| 303 | TERM(itrm,decs,meshkey); |
|---|
| 304 | |
|---|
| 305 | if ((++count % xtell) == 0) |
|---|
| 306 | printf("+++ %"_LD_" %s%s%s %d,%d,%d [%d,%d]\n", |
|---|
| 307 | count,prefkey,meshkey,qualkey,n1,n2,n3,prefcase,qualcase); |
|---|
| 308 | |
|---|
| 309 | if (TRMrc == RCNORMAL && TRMxytotp != 1) { |
|---|
| 310 | printf("+++ %"_LD_" %s -> %"_LD_" postings !!\n", |
|---|
| 311 | count,keyinp,TRMxytotp); |
|---|
| 312 | fprintf(fplst, |
|---|
| 313 | "+++ %"_LD_" %s -> %"_LD_" postings !!\n", |
|---|
| 314 | count,keyinp,TRMxytotp); |
|---|
| 315 | continue ; /* fatal("aborted"); */ |
|---|
| 316 | } |
|---|
| 317 | |
|---|
| 318 | if (TRMrc == RCNORMAL) |
|---|
| 319 | mfn=posting(itrm,1L); |
|---|
| 320 | else { |
|---|
| 321 | mfn=999999L; |
|---|
| 322 | printf( "+++ %"_LD_" %s -> Not found\n",count,keyinp); |
|---|
| 323 | fprintf(fplst,"+++ %"_LD_" %s -> Not found\n",count,keyinp); |
|---|
| 324 | continue; /*myb - 11.05.93 */ |
|---|
| 325 | } |
|---|
| 326 | |
|---|
| 327 | RECORD(irec,decs,mfn); |
|---|
| 328 | |
|---|
| 329 | if (RECrc != RCNORMAL) { |
|---|
| 330 | printf( "+++ %"_LD_" %s -> Not translated\n",count,keyinp); |
|---|
| 331 | fprintf(fplst,"+++ %"_LD_" %s -> Not translated\n",count,keyinp); |
|---|
| 332 | ecount++; |
|---|
| 333 | sprintf(buffup,"D*H%d %d %s",TAGTING,n2,meshkey); |
|---|
| 334 | if ((p=fldupdat(irec,buffup)) != NULL) { |
|---|
| 335 | printf("+++ %"_LD_" key=%s mfn=%"_LD_" \nfldupdat=%s \n", |
|---|
| 336 | count,keyinp,mfn,buffup); |
|---|
| 337 | fprintf(fplst, |
|---|
| 338 | "+++ %"_LD_" key=%s mfn=%"_LD_" \nfldupdat=%s \n", |
|---|
| 339 | count,keyinp,mfn,buffup); |
|---|
| 340 | fatal(p); |
|---|
| 341 | } |
|---|
| 342 | } |
|---|
| 343 | |
|---|
| 344 | if (*meshkey == '/') { /* duplicate /xx */ |
|---|
| 345 | qualx=0; |
|---|
| 346 | if (n2 != 3) qualx+=1; |
|---|
| 347 | else if ((xdir=fieldx(irec,TAGQUAL,1)) < 0) qualx+=2; |
|---|
| 348 | else if (DIRlen(xdir) != 2) qualx+=4; /* only xx */ |
|---|
| 349 | if (qualx) { |
|---|
| 350 | printf( "+++ %"_LD_" %s %d -> Bug2\n",count,keyinp,qualx); |
|---|
| 351 | fprintf(fplst,"+++ %"_LD_" %s %d -> Bug2\n",count,keyinp,qualx); |
|---|
| 352 | if (optbug2) continue; else fatal(keyinp); |
|---|
| 353 | } |
|---|
| 354 | sprintf(buffup,"H%d 3 %sH%d 3 %sH%d 3 %s", |
|---|
| 355 | TAGTING,meshkey,TAGTESP,meshkey,TAGTPOR,meshkey); /* do it */ |
|---|
| 356 | if ((p=fldupdat(irec,buffup)) != NULL) { |
|---|
| 357 | printf("+++ %"_LD_" key=%s mfn=%"_LD_" \nfldupdat=%s \n", |
|---|
| 358 | count,keyinp,mfn,buffup); |
|---|
| 359 | fprintf(fplst, |
|---|
| 360 | "+++ %"_LD_" key=%s mfn=%"_LD_" \nfldupdat=%s \n", |
|---|
| 361 | count,keyinp,mfn,buffup); |
|---|
| 362 | fatal(p); |
|---|
| 363 | } |
|---|
| 364 | } |
|---|
| 365 | |
|---|
| 366 | for (occ=1, xdir=0; xdir < MFRnvf; xdir++) { |
|---|
| 367 | tag=DIRtag(xdir); |
|---|
| 368 | if (tag == TAGTING || tag == TAGTESP || tag == TAGTPOR || |
|---|
| 369 | tag == TAGCATN || tag == TAGPROI) { |
|---|
| 370 | for (p=FIELDP(xdir), loop=DIRlen(xdir); loop--; ) |
|---|
| 371 | *p++ = isisuctab[*p]; |
|---|
| 372 | if (tag == TAGPROI) { |
|---|
| 373 | occ+=genlk1(occ,tag,recp,xdir,delim[0],0); |
|---|
| 374 | occ+=genlk1(occ,tag,recp,xdir,delim[1],1); |
|---|
| 375 | occ+=genlk1(occ,tag,recp,xdir,delim[2],2); |
|---|
| 376 | } |
|---|
| 377 | else { |
|---|
| 378 | occ+=genlk1(occ,tag,recp,xdir,'\0', wx(tag)); |
|---|
| 379 | |
|---|
| 380 | } |
|---|
| 381 | } |
|---|
| 382 | } |
|---|
| 383 | |
|---|
| 384 | } /* end for each term */ |
|---|
| 385 | |
|---|
| 386 | |
|---|
| 387 | printf( |
|---|
| 388 | "+++ terms=%"_LD_" err=%"_LD_" I=%"_LD_"+%"_LD_" E=%"_LD_"+%"_LD_" P=%"_LD_"+%"_LD_" C=%"_LD_"+%"_LD_"\n", |
|---|
| 389 | count,ecount, |
|---|
| 390 | vc[0][0],vc[0][1],vc[1][0],vc[1][1],vc[2][0],vc[2][1], |
|---|
| 391 | vc[3][0],vc[3][1]); |
|---|
| 392 | |
|---|
| 393 | fprintf(fplst, |
|---|
| 394 | "+++ terms=%"_LD_" err=%"_LD_" I=%"_LD_"+%"_LD_" E=%"_LD_"+%"_LD_" P=%"_LD_"+%"_LD_" C=%"_LD_"+%"_LD_"\n", |
|---|
| 395 | count,ecount, |
|---|
| 396 | vc[0][0],vc[0][1],vc[1][0],vc[1][1],vc[2][0],vc[2][1], |
|---|
| 397 | vc[3][0],vc[3][1]); |
|---|
| 398 | |
|---|
| 399 | exit(0); |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | |
|---|
| 403 | |
|---|
| 404 | #if ANSI |
|---|
| 405 | int outlink(LONGX mfn, int tag, int occ, int cnt, char *keyp, int keylen, |
|---|
| 406 | int sn) |
|---|
| 407 | #else |
|---|
| 408 | int outlink(mfn,tag,occ,cnt,keyp,keylen,sn) |
|---|
| 409 | LONGX mfn; |
|---|
| 410 | int tag; |
|---|
| 411 | int occ; |
|---|
| 412 | int cnt; |
|---|
| 413 | char *keyp; |
|---|
| 414 | int keylen; |
|---|
| 415 | int sn; |
|---|
| 416 | #endif |
|---|
| 417 | { |
|---|
| 418 | unsigned char *p,*q; |
|---|
| 419 | int loop,rc,lrecl; |
|---|
| 420 | |
|---|
| 421 | #if TRACE |
|---|
| 422 | printf("+++ outlink - %8"_LD_"/%5d/%4d/%4d/%d ",mfn,tag,occ,cnt,sn); |
|---|
| 423 | for (q=keyp, loop=keylen; loop--; q++) printf("%c",*q); |
|---|
| 424 | printf("\n"); |
|---|
| 425 | #endif |
|---|
| 426 | |
|---|
| 427 | /* setup link record */ |
|---|
| 428 | lrecl=0; |
|---|
| 429 | if (keylen > LE2) keylen=LE2; |
|---|
| 430 | rc = (keylen <= LE1) ? 0 : 1; |
|---|
| 431 | |
|---|
| 432 | #if UNIX |
|---|
| 433 | /* |
|---|
| 434 | 1234567890123456 1234567 12345 1234 1234 |
|---|
| 435 | IS 0262-0898 1 300 1 1 |
|---|
| 436 | JC DFC 1 300 1 3 |
|---|
| 437 | IS 0262-0898 2 300 1 1 |
|---|
| 438 | */ |
|---|
| 439 | for (p=&line[lrecl], q=keyp, loop=keylen; loop--; ) *p++ = *q++; |
|---|
| 440 | lrecl+=keylen; |
|---|
| 441 | loop=(rc)?LE2-keylen:LE1-keylen; |
|---|
| 442 | memset(p,' ',loop); p+=loop; lrecl+=loop; |
|---|
| 443 | sprintf(&line[lrecl]," %8"_LD_" %5d %4d %4d",mfn,tag,occ,cnt); |
|---|
| 444 | p+=25; lrecl+=25; |
|---|
| 445 | *p='\n'; |
|---|
| 446 | lrecl++; |
|---|
| 447 | #endif /* UNIX */ |
|---|
| 448 | |
|---|
| 449 | #if MPE || PC |
|---|
| 450 | #if MPE |
|---|
| 451 | line[lrecl++]='\0'; |
|---|
| 452 | sprintf(&line[lrecl],"%8"_LD_" %5d %4d %4d ",mfn,tag,occ,cnt); |
|---|
| 453 | lrecl+=25; |
|---|
| 454 | #endif |
|---|
| 455 | #if PC |
|---|
| 456 | sprintf(&line[lrecl],"%1"_LD_" %1d %1d %1d ",mfn,tag,occ,cnt); |
|---|
| 457 | lrecl+=strlen(&line[lrecl]); |
|---|
| 458 | #endif |
|---|
| 459 | for (p=&line[lrecl], q=keyp, loop=keylen; loop--; ) *p++ = *q++; |
|---|
| 460 | lrecl+=keylen; |
|---|
| 461 | #if MPE |
|---|
| 462 | for (loop=vlrecl[rc]-lrecl; loop--; ) { |
|---|
| 463 | *p++ = ' '; |
|---|
| 464 | lrecl++; |
|---|
| 465 | } |
|---|
| 466 | *p='\n'; |
|---|
| 467 | lrecl++; |
|---|
| 468 | #endif |
|---|
| 469 | #endif /* MPE || PC */ |
|---|
| 470 | |
|---|
| 471 | /* write it */ |
|---|
| 472 | if (CIWRITE(vfd[sn][rc],line,lrecl) != lrecl) { |
|---|
| 473 | printf("mfn/tag/occ/cnt: %"_LD_"/%d/%d/%d \n",mfn,tag,occ,cnt); |
|---|
| 474 | fatal("outlink/write"); |
|---|
| 475 | } |
|---|
| 476 | |
|---|
| 477 | vc[sn][rc]++; |
|---|
| 478 | |
|---|
| 479 | return(rc); |
|---|
| 480 | } |
|---|
| 481 | |
|---|
| 482 | |
|---|
| 483 | |
|---|
| 484 | |
|---|
| 485 | #if ANSI |
|---|
| 486 | int genlk1(int occ, int tag, RECSTRU *recp, int xdir, char dlm, int sn) |
|---|
| 487 | #else |
|---|
| 488 | int genlk1(occ,tag,recp,xdir,dlm,sn) |
|---|
| 489 | int occ; |
|---|
| 490 | int tag; |
|---|
| 491 | RECSTRU *recp; |
|---|
| 492 | int xdir; |
|---|
| 493 | char dlm; |
|---|
| 494 | int sn; |
|---|
| 495 | #endif |
|---|
| 496 | { |
|---|
| 497 | unsigned char *fldp; |
|---|
| 498 | FFI hn,qn; |
|---|
| 499 | int len,cnt,loop; |
|---|
| 500 | unsigned char *hp,*qp,c,*batchp; |
|---|
| 501 | LONGX totpostx; |
|---|
| 502 | |
|---|
| 503 | #if TRACE |
|---|
| 504 | int tracn; |
|---|
| 505 | unsigned char *tracp; |
|---|
| 506 | #endif |
|---|
| 507 | |
|---|
| 508 | hp=fldp=FIELDP(xdir); cnt=1; |
|---|
| 509 | hn=len=DIRlen(xdir); |
|---|
| 510 | |
|---|
| 511 | if (dlm) { |
|---|
| 512 | hp=subfldp(fldp,dlm,&hn); |
|---|
| 513 | if (hp == NULL) |
|---|
| 514 | return(0); |
|---|
| 515 | hn=(hp)?subfldn(hp,hn):0; |
|---|
| 516 | |
|---|
| 517 | /* eliminate homeo (^qp) and repidisca (^qr) */ |
|---|
| 518 | qp=fldp; qn=len; |
|---|
| 519 | qp=subfldp(fldp,'q',&qn); |
|---|
| 520 | if (qp != NULL) { |
|---|
| 521 | qn=(qp)?subfldn(qp,qn):0; |
|---|
| 522 | if (qn != 0 && qn != 1) { |
|---|
| 523 | printf("*** mfn/tag: %"_LD_"/%d\n",MFRmfn,tag); |
|---|
| 524 | fatal("^q invalid"); |
|---|
| 525 | } |
|---|
| 526 | if (qn) { |
|---|
| 527 | c=isisuctab[*qp]; |
|---|
| 528 | if (c != 'P' && c != 'R' && c != 'H' && c != 'V' && c != 'S') { |
|---|
| 529 | printf("*** mfn/tag: %"_LD_"/%d\n",MFRmfn,tag); |
|---|
| 530 | fatal("^q not P/R/H/V/S"); |
|---|
| 531 | } |
|---|
| 532 | if (c == 'P' || c == 'R') |
|---|
| 533 | return(0); /* eliminate */ |
|---|
| 534 | } |
|---|
| 535 | } |
|---|
| 536 | } |
|---|
| 537 | |
|---|
| 538 | if (*hp <= ' ') { |
|---|
| 539 | printf("+++ Adjusting key %"_LD_"/%d/%d/%d \n",MFRmfn,tag,occ,cnt); |
|---|
| 540 | #if TRACE |
|---|
| 541 | for (tracp=hp, tracn=hn; tracn--; tracp++) |
|---|
| 542 | printf("%c(%02x)",*tracp,*tracp); |
|---|
| 543 | getchar(); |
|---|
| 544 | #endif |
|---|
| 545 | while (*hp <= ' ') |
|---|
| 546 | if (hn > 1) { |
|---|
| 547 | hp++; hn--; |
|---|
| 548 | } |
|---|
| 549 | else { |
|---|
| 550 | printf("*** Rejected key - mfn/tag/occ/cnt: %"_LD_"/%d/%d/%d \n", |
|---|
| 551 | MFRmfn,tag,occ,cnt); |
|---|
| 552 | return(0); |
|---|
| 553 | } |
|---|
| 554 | } |
|---|
| 555 | |
|---|
| 556 | |
|---|
| 557 | if (prefcase) |
|---|
| 558 | memcpy(keynew,prefkey,n1); |
|---|
| 559 | |
|---|
| 560 | memcpy(keynew+n1,hp,hn); |
|---|
| 561 | |
|---|
| 562 | if (qualcase) |
|---|
| 563 | memcpy(keynew+n1+hn,qualkey,n3); |
|---|
| 564 | |
|---|
| 565 | outlink(MFRmfn,1,occ,cnt,keynew,n1+hn+n3,sn); |
|---|
| 566 | |
|---|
| 567 | /* keep info */ |
|---|
| 568 | batchp=buffup; |
|---|
| 569 | sprintf(batchp,"%06"_LD_"|",MFRmfn); batchp+=strlen(batchp); |
|---|
| 570 | |
|---|
| 571 | if (n2 >= LE2) { |
|---|
| 572 | memcpy(batchp,meshkey,LE2); batchp+=LE2; |
|---|
| 573 | } |
|---|
| 574 | else { |
|---|
| 575 | memcpy(batchp,meshkey,n2); batchp+=n2; |
|---|
| 576 | for (loop=LE2-n2; loop--; ) *batchp++ = ' '; |
|---|
| 577 | } |
|---|
| 578 | *batchp++ = '|'; |
|---|
| 579 | |
|---|
| 580 | if (dlm) { |
|---|
| 581 | sprintf(batchp,"%c|x|",isisuctab[dlm]); |
|---|
| 582 | totpostx=0; /* mfn count is ok */ |
|---|
| 583 | } |
|---|
| 584 | else { |
|---|
| 585 | sprintf(batchp,"%c|a|",isisuctab[wxchr[wx(tag)]]); |
|---|
| 586 | if (totpmfnok[wx(tag)]) |
|---|
| 587 | totpostx=0; |
|---|
| 588 | else { |
|---|
| 589 | totpostx=totpost; |
|---|
| 590 | totpmfnok[wx(tag)]=1; |
|---|
| 591 | } |
|---|
| 592 | } |
|---|
| 593 | batchp+=strlen(batchp); |
|---|
| 594 | |
|---|
| 595 | if (hn >= LE2) { |
|---|
| 596 | memcpy(batchp,hp,LE2); batchp+=LE2; |
|---|
| 597 | } |
|---|
| 598 | else { |
|---|
| 599 | memcpy(batchp,hp,hn); batchp+=hn; |
|---|
| 600 | for (loop=LE2-hn; loop--; ) *batchp++ = ' '; |
|---|
| 601 | } |
|---|
| 602 | *batchp++ = '|'; |
|---|
| 603 | |
|---|
| 604 | if (n1 >= 2) { |
|---|
| 605 | memcpy(batchp,prefkey,2); batchp+=2; |
|---|
| 606 | } |
|---|
| 607 | else { |
|---|
| 608 | memcpy(batchp,prefkey,n1); batchp+=n1; |
|---|
| 609 | for (loop=2-n1; loop--; ) *batchp++ = ' '; |
|---|
| 610 | } |
|---|
| 611 | *batchp++ = '|'; |
|---|
| 612 | |
|---|
| 613 | if (n3 >= 3) { |
|---|
| 614 | memcpy(batchp,qualkey,3); batchp+=3; |
|---|
| 615 | } |
|---|
| 616 | else { |
|---|
| 617 | memcpy(batchp,qualkey,n3); batchp+=n3; |
|---|
| 618 | for (loop=3-n3; loop--; ) *batchp++ = ' '; |
|---|
| 619 | } |
|---|
| 620 | *batchp++ = '|'; |
|---|
| 621 | |
|---|
| 622 | sprintf(batchp,"%2d|%2d|%d|%d|%9"_LD_"\n",n2,hn,n1,n3,totpostx); |
|---|
| 623 | #if TRACE |
|---|
| 624 | *batchp='\0'; |
|---|
| 625 | printf("sn=%d strlen=%d lreclx=%d\n%s.",sn,strlen(buffup),lreclx,buffup); |
|---|
| 626 | #endif |
|---|
| 627 | if (CIWRITE(fdout[sn],buffup,lreclx) != lreclx) |
|---|
| 628 | fatal("genlk1/write"); |
|---|
| 629 | |
|---|
| 630 | #if OUTONISIS |
|---|
| 631 | memcpy(key2,hp,hn); key2[hn]='\0'; |
|---|
| 632 | if (fldupdat(irecout,"D*") != NULL) fatal("fldupdat/init"); |
|---|
| 633 | VMFRmfn(irecout)=MFRmfn; etc; |
|---|
| 634 | #endif |
|---|
| 635 | |
|---|
| 636 | return(1); |
|---|
| 637 | } |
|---|