| 1 | /* ---------------------------------------------------------------------- |
|---|
| 2 | mdlmf.c - NLM Medlars II - Master file translation/reformatting |
|---|
| 3 | ----------------------------------------------------------------------- */ |
|---|
| 4 | |
|---|
| 5 | #include <stdio.h> |
|---|
| 6 | #include <ctype.h> |
|---|
| 7 | #include <string.h> |
|---|
| 8 | |
|---|
| 9 | #include "cisis.h" /* CISIS Interface */ |
|---|
| 10 | #include "cirun.h" /* runtime area and defines by AOT */ |
|---|
| 11 | |
|---|
| 12 | char *parmgizp = NULL; /* gizp */ |
|---|
| 13 | |
|---|
| 14 | int argnext = 1; |
|---|
| 15 | |
|---|
| 16 | int parmcontrol=0,parmleader=0,parmfields=0; |
|---|
| 17 | LONGX parmfrom=1,parmto=0,parmloop=1; |
|---|
| 18 | int parmwait=1; |
|---|
| 19 | int parmtrace=0; |
|---|
| 20 | LONGX parmcount=999999999L, parmtell=0; |
|---|
| 21 | |
|---|
| 22 | int parmzdecs=0; |
|---|
| 23 | int parmok=0; |
|---|
| 24 | char *zdbnp; |
|---|
| 25 | char *zdp; |
|---|
| 26 | unsigned char *z1p,*z2p,zkey[LE2+BUFSIZ+1]; |
|---|
| 27 | LONGX itrm=0L; |
|---|
| 28 | TRMSTRU *trmp; |
|---|
| 29 | LONGX zsave=0L; |
|---|
| 30 | int zx0,zx1; |
|---|
| 31 | LONGX zdlookup=0L,zdnotf=0L; |
|---|
| 32 | |
|---|
| 33 | int parmgizmo=0; |
|---|
| 34 | VGIZPSTRU *vgzrp=NULL; /* gizmo processing */ |
|---|
| 35 | LONGX grec; |
|---|
| 36 | UWORD gmfrl0; |
|---|
| 37 | LONGX gsave=0L; |
|---|
| 38 | |
|---|
| 39 | LONGX totmfrl=0L,totleader=0L,totdir=0L,totdata=0L; |
|---|
| 40 | LONGX tot0,tot1,totz=0L,totg=0L; |
|---|
| 41 | FILE *fplog=NULL; |
|---|
| 42 | FILE *filog=NULL; |
|---|
| 43 | |
|---|
| 44 | #define MINTAG 15 |
|---|
| 45 | #define MAXTAG 969 |
|---|
| 46 | |
|---|
| 47 | int nlmtag[MAXTAG+1]; |
|---|
| 48 | |
|---|
| 49 | #define NLMTAGAB 370 /* A830 */ |
|---|
| 50 | #define NLMTAGAA 371 /* ---- [370: (Au)] */ |
|---|
| 51 | #define NLMTAGAD 378 /* B100 */ |
|---|
| 52 | #define NLMTAGAU 372 /* A100 */ |
|---|
| 53 | #define NLMTAGRN 261 /* ---- */ |
|---|
| 54 | #define NLMTAGCY 307 /* ---- */ |
|---|
| 55 | #define NLMTAGDA 100 /* A910 */ |
|---|
| 56 | #define NLMTAGDP 354 /* A640 [aaaammdd: A650=650] */ |
|---|
| 57 | #define NLMTAGEA 382 /* A410 [En] */ |
|---|
| 58 | #define NLMTAGEM 383 /* E900 */ |
|---|
| 59 | #define NLMTAGID 640 /* ---- */ |
|---|
| 60 | #define NLMTAGPY 323 /* ---- */ |
|---|
| 61 | #define NLMTAGIS 301 /* A350 */ |
|---|
| 62 | #define NLMTAGIP 373 /* A320 */ |
|---|
| 63 | #define NLMTAGSB 324 /* ---- */ |
|---|
| 64 | #define NLMTAGJC 320 /* B300 */ |
|---|
| 65 | #define NLMTAGLA 306 /* A400 [ISO] */ |
|---|
| 66 | #define NLMTAGMR 368 /* ---- */ |
|---|
| 67 | #define NLMTAGMH 351 /* A770 [if: A870/A880] */ |
|---|
| 68 | #define NLMTAGZN 308 /* ---- */ |
|---|
| 69 | #define NLMTAGNI 376 /* ---- */ |
|---|
| 70 | #define NLMTAGNP 369 /* ---- */ |
|---|
| 71 | #define NLMTAGRF 377 /* A720 */ |
|---|
| 72 | #define NLMTAGPG 353 /* A140 */ |
|---|
| 73 | #define NLMTAGPS 379 /* A780 */ |
|---|
| 74 | #define NLMTAGRO 101 /* ---- */ |
|---|
| 75 | #define NLMTAGSI 606 /* ---- */ |
|---|
| 76 | #define NLMTAGLI 329 /* ---- */ |
|---|
| 77 | #define NLMTAGTI 352 /* A120 [380pres: A130=130] */ |
|---|
| 78 | #define NLMTAGTA 305 /* A300 */ |
|---|
| 79 | #define NLMTAGTT 380 /* A120 */ |
|---|
| 80 | #define NLMTAGUI 350 /* A020 */ |
|---|
| 81 | #define NLMTAGVI 381 /* S310 */ |
|---|
| 82 | #define NLMTAGCU 103 /* A900 */ |
|---|
| 83 | #define NLMTAGLR 102 /* M900 */ |
|---|
| 84 | #define NLMTAGCO 440 /* A440 */ |
|---|
| 85 | #define NLMTAGPT 360 /* Publication Type -1991 */ |
|---|
| 86 | |
|---|
| 87 | #define NEWTAGTI_130 130 /* when TT present */ |
|---|
| 88 | |
|---|
| 89 | #define ENAB650 0 |
|---|
| 90 | |
|---|
| 91 | #if ENAB650 |
|---|
| 92 | #define NEWTAGDP_650 650 /* standardized date */ |
|---|
| 93 | #endif |
|---|
| 94 | |
|---|
| 95 | /* TOXLINE - AOT/MB/FJL 14/06/2000 */ |
|---|
| 96 | /* Novos campos para display */ |
|---|
| 97 | #define NLMTAGCN 529 /* */ |
|---|
| 98 | #define NLMTAGSO 602 /* */ |
|---|
| 99 | #define NLMTAGGS 328 /* */ |
|---|
| 100 | #define NLMTAGOD 611 /* */ |
|---|
| 101 | #define NLMTAGPR 547 /* */ |
|---|
| 102 | #define NLMTAGKW 634 /* */ |
|---|
| 103 | /* Campos em outros tags */ |
|---|
| 104 | #define TOXTAGAD 410 /* x 378 - */ |
|---|
| 105 | #define TOXTAGCY 642 /* x 307 - */ |
|---|
| 106 | #define TOXTAGEM 100 /* x 383 - agora com 6 digitos */ |
|---|
| 107 | /* Campos que nao podem existir */ |
|---|
| 108 | #define TOXTAGN1 378 |
|---|
| 109 | #define TOXTAGN2 307 |
|---|
| 110 | #define TOXTAGN3 383 |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | unsigned char ebc2asc[256]; |
|---|
| 115 | |
|---|
| 116 | #define EBCBLANK 0x40 |
|---|
| 117 | #define EBCPERIOD 0x4b |
|---|
| 118 | #define EBCOSQBR 0xad |
|---|
| 119 | #define EBCCSQBR 0xbd |
|---|
| 120 | #define EBCOPARE 0x4d |
|---|
| 121 | #define EBCCPARE 0x5d |
|---|
| 122 | |
|---|
| 123 | #define SVCHR 0x51 |
|---|
| 124 | #define EVCHR 0x52 |
|---|
| 125 | #define SSCHR 0x53 |
|---|
| 126 | |
|---|
| 127 | #define FLDUPDLM 0x01 |
|---|
| 128 | |
|---|
| 129 | #define INVALID 0x02 |
|---|
| 130 | |
|---|
| 131 | #define CEDILLA 0x03 /* cedilla */ |
|---|
| 132 | #define OPNQUOTE 0x04 /* '�' */ |
|---|
| 133 | #define DOTLESSI 0x05 /* dotless i */ |
|---|
| 134 | #define LPOLISHL 0x06 /* lower polish l */ |
|---|
| 135 | #define CLSQUOTE 0x07 /* '�' */ |
|---|
| 136 | #define CIRCUMFLEX 0x08 /* circumflex */ |
|---|
| 137 | #define TRADEMARK 0x09 /* trademark symbol */ |
|---|
| 138 | #define ANGSTROM 0x0a /* angstrom */ |
|---|
| 139 | #define UMLAUT 0x0b /* um laut */ |
|---|
| 140 | #define TILDE 0x0c /* tilde */ |
|---|
| 141 | #define GRAVE 0x0d /* grave */ |
|---|
| 142 | #define LPOLISHO 0x0e /* lower polish o */ |
|---|
| 143 | #define BREVE 0x0f /* breve */ |
|---|
| 144 | #define ACUTE 0x10 /* acute */ |
|---|
| 145 | #define MACRON 0x11 /* macron */ |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | int MHnocc; |
|---|
| 149 | |
|---|
| 150 | #define LATABSIZ 6 |
|---|
| 151 | #define LANLMSIZ 3 |
|---|
| 152 | #define LAISOSIZ 2 |
|---|
| 153 | unsigned char LAin[128]; |
|---|
| 154 | unsigned char LAtab[][LATABSIZ+1] = { "AFR Af", "ENG En", "" }; |
|---|
| 155 | |
|---|
| 156 | #if ANSI |
|---|
| 157 | unsigned char *DPconvert(unsigned char *errp, int n); |
|---|
| 158 | void mxexit(int rc); |
|---|
| 159 | #else |
|---|
| 160 | unsigned char *DPconvert(); |
|---|
| 161 | void mxexit(); |
|---|
| 162 | #endif |
|---|
| 163 | |
|---|
| 164 | #if ENAB650 |
|---|
| 165 | unsigned char DPin[128]; |
|---|
| 166 | unsigned char DPok[128]; |
|---|
| 167 | unsigned char *DPerrp; |
|---|
| 168 | #endif |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | int parmcopy = 1; |
|---|
| 172 | |
|---|
| 173 | #if BEFORE20000320 |
|---|
| 174 | int parmDP = 0; |
|---|
| 175 | #else |
|---|
| 176 | int parmDP = -1; |
|---|
| 177 | #endif |
|---|
| 178 | unsigned short int DP1,DP2; |
|---|
| 179 | int parmappd = 0; |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | RECSTRU *recp; /* mandatory for defines REC RDB MF0 MFR DIR, FIELDP */ |
|---|
| 183 | |
|---|
| 184 | unsigned char dbname[CIMPL+1],dbnout[CIMPL+1],buffup[MAXMFRL+MAXMFRL]; |
|---|
| 185 | |
|---|
| 186 | unsigned char *dbnamep,*dbnoutp,*batchp; |
|---|
| 187 | |
|---|
| 188 | LONGX irec,upcrec,upirec,mfn; |
|---|
| 189 | |
|---|
| 190 | int parmTAn = 0; |
|---|
| 191 | int parmTAy = 0; |
|---|
| 192 | |
|---|
| 193 | int parmTOX = 0; |
|---|
| 194 | |
|---|
| 195 | LONGX count = 0; |
|---|
| 196 | |
|---|
| 197 | #define PROC 1 |
|---|
| 198 | /* ========================== mp_scan/mp_edit ============================= */ |
|---|
| 199 | #if PROC |
|---|
| 200 | #define MAXNPPP 1 |
|---|
| 201 | FMT_CODE *mp_pgmp[MAXNPPP]; |
|---|
| 202 | int mp_n = 0; |
|---|
| 203 | char *mp_areap=NULL; |
|---|
| 204 | LONGX fmtasize=MAXMFRL+MAXMFRL; |
|---|
| 205 | #if ANSI |
|---|
| 206 | void mp_scan(char *gidbnp, char *specp); |
|---|
| 207 | void mp_edit(LONGX ridx, int i1, int i2); |
|---|
| 208 | #else |
|---|
| 209 | void mp_scan(); |
|---|
| 210 | void mp_edit(); |
|---|
| 211 | #endif |
|---|
| 212 | #endif /* PROC */ |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | void main(argc,argv) |
|---|
| 216 | int argc; |
|---|
| 217 | char *argv[]; |
|---|
| 218 | |
|---|
| 219 | { |
|---|
| 220 | int rc; |
|---|
| 221 | int minus1,plus1; |
|---|
| 222 | unsigned char *p,*q; |
|---|
| 223 | int i/*,j*/,xdir,loop1,loop2,tag,iocc; |
|---|
| 224 | VGIZPSTRU *gizmap; |
|---|
| 225 | |
|---|
| 226 | for (i=0; i<MAXTAG; ) |
|---|
| 227 | nlmtag[i++]=2; /* health */ |
|---|
| 228 | /* health */ |
|---|
| 229 | nlmtag[NLMTAGAA]=0; |
|---|
| 230 | nlmtag[NLMTAGRN]=1; /* cdrom */ |
|---|
| 231 | nlmtag[NLMTAGCY]=0; |
|---|
| 232 | nlmtag[NLMTAGID]=0; |
|---|
| 233 | nlmtag[NLMTAGPY]=0; |
|---|
| 234 | nlmtag[NLMTAGSB]=1; /* cdrom */ |
|---|
| 235 | nlmtag[NLMTAGMR]=0; |
|---|
| 236 | nlmtag[NLMTAGZN]=0; |
|---|
| 237 | nlmtag[NLMTAGNI]=0; |
|---|
| 238 | nlmtag[NLMTAGNP]=0; |
|---|
| 239 | nlmtag[NLMTAGRO]=0; |
|---|
| 240 | nlmtag[NLMTAGSI]=0; |
|---|
| 241 | nlmtag[NLMTAGLI]=1; /* cdrom */ |
|---|
| 242 | |
|---|
| 243 | /* health */ |
|---|
| 244 | |
|---|
| 245 | nlmtag[NLMTAGAB]=1; |
|---|
| 246 | nlmtag[NLMTAGAD]=1; |
|---|
| 247 | nlmtag[NLMTAGAU]=1; |
|---|
| 248 | nlmtag[NLMTAGDA]=1; |
|---|
| 249 | nlmtag[NLMTAGDP]=1; |
|---|
| 250 | nlmtag[NLMTAGEA]=1; |
|---|
| 251 | nlmtag[NLMTAGEM]=1; |
|---|
| 252 | nlmtag[NLMTAGIS]=0; |
|---|
| 253 | nlmtag[NLMTAGIP]=1; |
|---|
| 254 | nlmtag[NLMTAGJC]=1; |
|---|
| 255 | nlmtag[NLMTAGLA]=1; |
|---|
| 256 | nlmtag[NLMTAGMH]=1; |
|---|
| 257 | nlmtag[NLMTAGRF]=1; |
|---|
| 258 | nlmtag[NLMTAGPG]=1; |
|---|
| 259 | nlmtag[NLMTAGPS]=1; |
|---|
| 260 | nlmtag[NLMTAGTI]=1; |
|---|
| 261 | nlmtag[NLMTAGTA]=0; |
|---|
| 262 | nlmtag[NLMTAGTT]=1; |
|---|
| 263 | nlmtag[NLMTAGUI]=1; |
|---|
| 264 | nlmtag[NLMTAGVI]=1; |
|---|
| 265 | nlmtag[NLMTAGCU]=1; |
|---|
| 266 | nlmtag[NLMTAGLR]=1; |
|---|
| 267 | nlmtag[NLMTAGCO]=1; |
|---|
| 268 | nlmtag[NLMTAGPT]=1; |
|---|
| 269 | |
|---|
| 270 | |
|---|
| 271 | for (i=0; i<256; ) |
|---|
| 272 | ebc2asc[i++]=INVALID; |
|---|
| 273 | |
|---|
| 274 | |
|---|
| 275 | ebc2asc[0x40]=' '; |
|---|
| 276 | ebc2asc[0x4a]=CEDILLA; /* cedilla */ |
|---|
| 277 | ebc2asc[0x4b]='.'; |
|---|
| 278 | ebc2asc[0x4c]='<'; |
|---|
| 279 | ebc2asc[0x4d]='('; |
|---|
| 280 | ebc2asc[0x4f]='|'; |
|---|
| 281 | ebc2asc[0x4e]='+'; |
|---|
| 282 | ebc2asc[0x50]='&'; |
|---|
| 283 | ebc2asc[0x51]=INVALID; /* SVCHR */ |
|---|
| 284 | ebc2asc[0x52]=INVALID; /* EVCHR */ |
|---|
| 285 | ebc2asc[0x53]=INVALID; /* SSCHR */ |
|---|
| 286 | ebc2asc[0x5a]='!'; |
|---|
| 287 | ebc2asc[0x5b]='$'; |
|---|
| 288 | ebc2asc[0x5c]='*'; |
|---|
| 289 | ebc2asc[0x5d]=')'; |
|---|
| 290 | ebc2asc[0x5e]=';'; |
|---|
| 291 | ebc2asc[0x5f]=INVALID; /* not sign */ |
|---|
| 292 | ebc2asc[0x60]='-'; |
|---|
| 293 | ebc2asc[0x61]='/'; |
|---|
| 294 | ebc2asc[0x69]='|'; |
|---|
| 295 | ebc2asc[0x6a]='|'; |
|---|
| 296 | ebc2asc[0x6b]=','; |
|---|
| 297 | ebc2asc[0x6c]='%'; |
|---|
| 298 | ebc2asc[0x6d]='_'; |
|---|
| 299 | ebc2asc[0x6e]='>'; |
|---|
| 300 | ebc2asc[0x6f]='?'; |
|---|
| 301 | ebc2asc[0x7a]=':'; |
|---|
| 302 | ebc2asc[0x7b]='#'; |
|---|
| 303 | ebc2asc[0x7c]='@'; |
|---|
| 304 | ebc2asc[0x7d]='\''; |
|---|
| 305 | ebc2asc[0x7e]='='; |
|---|
| 306 | ebc2asc[0x7f]=OPNQUOTE; /* '�' */ |
|---|
| 307 | ebc2asc[0x80]=INVALID; /* afs delimiter */ |
|---|
| 308 | ebc2asc[0x81]='a'; |
|---|
| 309 | ebc2asc[0x82]='b'; |
|---|
| 310 | ebc2asc[0x83]='c'; |
|---|
| 311 | ebc2asc[0x84]='d'; |
|---|
| 312 | ebc2asc[0x85]='e'; |
|---|
| 313 | ebc2asc[0x86]='f'; |
|---|
| 314 | ebc2asc[0x87]='g'; |
|---|
| 315 | ebc2asc[0x88]='h'; |
|---|
| 316 | ebc2asc[0x89]='i'; |
|---|
| 317 | ebc2asc[0x8a]=DOTLESSI; /* dotless i */ |
|---|
| 318 | ebc2asc[0x8e]=LPOLISHL; /* lower polish l */ |
|---|
| 319 | ebc2asc[0x91]='j'; |
|---|
| 320 | ebc2asc[0x92]='k'; |
|---|
| 321 | ebc2asc[0x93]='l'; |
|---|
| 322 | ebc2asc[0x94]='m'; |
|---|
| 323 | ebc2asc[0x95]='n'; |
|---|
| 324 | ebc2asc[0x96]='o'; |
|---|
| 325 | ebc2asc[0x97]='p'; |
|---|
| 326 | ebc2asc[0x98]='q'; |
|---|
| 327 | ebc2asc[0x99]='r'; |
|---|
| 328 | ebc2asc[0x9d]=CLSQUOTE; /* '�' */ |
|---|
| 329 | ebc2asc[0x9f]=CIRCUMFLEX; /* circumflex */ |
|---|
| 330 | ebc2asc[0xa0]=TRADEMARK; /* trademark symbol */ |
|---|
| 331 | ebc2asc[0xa1]=ANGSTROM; /* angstrom */ |
|---|
| 332 | ebc2asc[0xa2]='s'; |
|---|
| 333 | ebc2asc[0xa3]='t'; |
|---|
| 334 | ebc2asc[0xa4]='u'; |
|---|
| 335 | ebc2asc[0xa5]='v'; |
|---|
| 336 | ebc2asc[0xa6]='w'; |
|---|
| 337 | ebc2asc[0xa7]='x'; |
|---|
| 338 | ebc2asc[0xa8]='y'; |
|---|
| 339 | ebc2asc[0xa9]='z'; |
|---|
| 340 | ebc2asc[0xab]=UMLAUT; /* um laut */ |
|---|
| 341 | ebc2asc[0xac]=TILDE; /* tilde */ |
|---|
| 342 | ebc2asc[0xad]='['; |
|---|
| 343 | ebc2asc[0xaf]=GRAVE; /* grave */ |
|---|
| 344 | ebc2asc[0xb9]=LPOLISHO; /* lower polish o */ |
|---|
| 345 | ebc2asc[0xbb]=BREVE; /* breve */ |
|---|
| 346 | ebc2asc[0xbc]=ACUTE; /* acute */ |
|---|
| 347 | ebc2asc[0xbd]=']'; |
|---|
| 348 | ebc2asc[0xbf]=MACRON; /* macron */ |
|---|
| 349 | ebc2asc[0xc0]='{'; |
|---|
| 350 | ebc2asc[0xc1]='A'; |
|---|
| 351 | ebc2asc[0xc2]='B'; |
|---|
| 352 | ebc2asc[0xc3]='C'; |
|---|
| 353 | ebc2asc[0xc4]='D'; |
|---|
| 354 | ebc2asc[0xc5]='E'; |
|---|
| 355 | ebc2asc[0xc6]='F'; |
|---|
| 356 | ebc2asc[0xc7]='G'; |
|---|
| 357 | ebc2asc[0xc8]='H'; |
|---|
| 358 | ebc2asc[0xc9]='I'; |
|---|
| 359 | ebc2asc[0xd0]='}'; |
|---|
| 360 | ebc2asc[0xd1]='J'; |
|---|
| 361 | ebc2asc[0xd2]='K'; |
|---|
| 362 | ebc2asc[0xd3]='L'; |
|---|
| 363 | ebc2asc[0xd4]='M'; |
|---|
| 364 | ebc2asc[0xd5]='N'; |
|---|
| 365 | ebc2asc[0xd6]='O'; |
|---|
| 366 | ebc2asc[0xd7]='P'; |
|---|
| 367 | ebc2asc[0xd8]='Q'; |
|---|
| 368 | ebc2asc[0xd9]='R'; |
|---|
| 369 | ebc2asc[0xe0]='\\'; |
|---|
| 370 | ebc2asc[0xe2]='S'; |
|---|
| 371 | ebc2asc[0xe3]='T'; |
|---|
| 372 | ebc2asc[0xe4]='U'; |
|---|
| 373 | ebc2asc[0xe5]='V'; |
|---|
| 374 | ebc2asc[0xe6]='W'; |
|---|
| 375 | ebc2asc[0xe7]='X'; |
|---|
| 376 | ebc2asc[0xe8]='Y'; |
|---|
| 377 | ebc2asc[0xe9]='Z'; |
|---|
| 378 | ebc2asc[0xf0]='0'; |
|---|
| 379 | ebc2asc[0xf1]='1'; |
|---|
| 380 | ebc2asc[0xf2]='2'; |
|---|
| 381 | ebc2asc[0xf3]='3'; |
|---|
| 382 | ebc2asc[0xf4]='4'; |
|---|
| 383 | ebc2asc[0xf5]='5'; |
|---|
| 384 | ebc2asc[0xf6]='6'; |
|---|
| 385 | ebc2asc[0xf7]='7'; |
|---|
| 386 | ebc2asc[0xf8]='8'; |
|---|
| 387 | ebc2asc[0xf9]='9'; |
|---|
| 388 | |
|---|
| 389 | |
|---|
| 390 | argnext=1; |
|---|
| 391 | if (argc < 3) { |
|---|
| 392 | if (argc == 2 && strcmp(argv[1],"what") == 0) { |
|---|
| 393 | printf("%s",cicopyr("?Utility MDL/MDLMF")); |
|---|
| 394 | printf("\n"); |
|---|
| 395 | exit(1); |
|---|
| 396 | } |
|---|
| 397 | printf("%s",cicopyr("Utility MDL/MDLMF")); |
|---|
| 398 | printf("\n"); |
|---|
| 399 | printf("mdlmf <dbname> [create=]<dbnout> [<option> [...]] \n"); |
|---|
| 400 | printf("\n"); |
|---|
| 401 | printf("options: {+/-}{control/leader/fields} \n"); |
|---|
| 402 | printf(" {from/to/loop/count/tell}=<n> \n"); |
|---|
| 403 | printf(" DP=<aa> \n"); |
|---|
| 404 | printf(" TA=NO \n"); |
|---|
| 405 | /*printf(" TA={YES|NO} \n");*/ |
|---|
| 406 | printf(" TOXLINE \n"); |
|---|
| 407 | printf(" APPEND \n"); |
|---|
| 408 | printf(" zdecs=<zdecs> [ok]\n"); |
|---|
| 409 | #if PROC |
|---|
| 410 | printf(" proc={<fldupdat_fmt_spec>|@<file>} \n"); |
|---|
| 411 | #endif |
|---|
| 412 | printf(" gizmo=<gizmo_dbn>[,<taglist>] [gizp=<dbnx>] \n"); |
|---|
| 413 | printf(" now[ait] \n"); |
|---|
| 414 | printf("\n"); |
|---|
| 415 | printf("(version 14/06/2000)\n"); |
|---|
| 416 | printf("\n"); |
|---|
| 417 | exit(1); |
|---|
| 418 | } |
|---|
| 419 | printf("===> ISO Languages\n"); |
|---|
| 420 | |
|---|
| 421 | dbnamep=argv[argnext++]; |
|---|
| 422 | dbnoutp=argv[argnext++]; |
|---|
| 423 | |
|---|
| 424 | if ((fplog=fopen("mdlmf.log","w")) == NULL) fatal("mdlmf.log"); |
|---|
| 425 | if ((filog=fopen("mdlmf.chr","w")) == NULL) fatal("mdlmf.chr"); |
|---|
| 426 | |
|---|
| 427 | printf("+++ input data base: %s\n",dbnamep); |
|---|
| 428 | |
|---|
| 429 | |
|---|
| 430 | minus1=plus1=0; |
|---|
| 431 | |
|---|
| 432 | for (i=argnext; i<argc; i++) { |
|---|
| 433 | p=argv[i]; |
|---|
| 434 | |
|---|
| 435 | if (*p == '-') { |
|---|
| 436 | minus1++; |
|---|
| 437 | if (minus1 == 1) |
|---|
| 438 | parmcontrol=parmleader=parmfields=1; |
|---|
| 439 | } |
|---|
| 440 | |
|---|
| 441 | if (strcmp(p,"-control") == 0) { |
|---|
| 442 | parmcontrol=0; |
|---|
| 443 | continue; |
|---|
| 444 | } |
|---|
| 445 | if (strcmp(p,"-leader") == 0) { |
|---|
| 446 | parmleader=0; |
|---|
| 447 | continue; |
|---|
| 448 | } |
|---|
| 449 | if (strcmp(p,"-fields") == 0) { |
|---|
| 450 | parmfields=0; |
|---|
| 451 | continue; |
|---|
| 452 | } |
|---|
| 453 | |
|---|
| 454 | if (*p == '+') { |
|---|
| 455 | plus1++; |
|---|
| 456 | if (plus1 == 1) { |
|---|
| 457 | parmcontrol=parmleader=parmfields=0; |
|---|
| 458 | } |
|---|
| 459 | } |
|---|
| 460 | |
|---|
| 461 | if (strcmp(p,"+control") == 0) { |
|---|
| 462 | parmcontrol=1; |
|---|
| 463 | continue; |
|---|
| 464 | } |
|---|
| 465 | if (strcmp(p,"+leader") == 0) { |
|---|
| 466 | parmleader=1; |
|---|
| 467 | continue; |
|---|
| 468 | } |
|---|
| 469 | if (strcmp(p,"+fields") == 0) { |
|---|
| 470 | parmfields=1; |
|---|
| 471 | continue; |
|---|
| 472 | } |
|---|
| 473 | |
|---|
| 474 | if (strncmp(p,"from=",5) == 0) { |
|---|
| 475 | if (sscanf(p+5,"%"_LD_,&parmfrom) != 1) |
|---|
| 476 | fatal(p); |
|---|
| 477 | continue; |
|---|
| 478 | } |
|---|
| 479 | if (strncmp(p,"to=",3) == 0) { |
|---|
| 480 | if (sscanf(p+3,"%"_LD_,&parmto) != 1) |
|---|
| 481 | fatal(p); |
|---|
| 482 | continue; |
|---|
| 483 | } |
|---|
| 484 | if (strncmp(p,"loop=",5) == 0) { |
|---|
| 485 | if (sscanf(p+5,"%"_LD_,&parmloop) != 1) |
|---|
| 486 | fatal(p); |
|---|
| 487 | continue; |
|---|
| 488 | } |
|---|
| 489 | |
|---|
| 490 | if (strcmp(p,"nowait") == 0 || strcmp(p,"now") == 0) { |
|---|
| 491 | parmwait=0; |
|---|
| 492 | continue; |
|---|
| 493 | } |
|---|
| 494 | |
|---|
| 495 | if (strcmp(p,"trace") == 0) { |
|---|
| 496 | parmtrace=1; |
|---|
| 497 | continue; |
|---|
| 498 | } |
|---|
| 499 | |
|---|
| 500 | if (strncmp(p,"zdecs=",6) == 0) { |
|---|
| 501 | parmzdecs=1; zdbnp=p+6; |
|---|
| 502 | continue; |
|---|
| 503 | } |
|---|
| 504 | if (strcmp(p,"ok") == 0) { |
|---|
| 505 | parmok=1; |
|---|
| 506 | continue; |
|---|
| 507 | } |
|---|
| 508 | |
|---|
| 509 | if (strncmp(p,"proc?",5) == 0 || strncmp(p,"proc=",5) == 0) { |
|---|
| 510 | q=p+5; |
|---|
| 511 | if (!*q) fatal(p); |
|---|
| 512 | mp_scan(NULL,q); |
|---|
| 513 | continue; |
|---|
| 514 | } |
|---|
| 515 | |
|---|
| 516 | if (strncmp(p,"gizp?",5) == 0 || strncmp(p,"gizp=",5) == 0) { |
|---|
| 517 | parmgizp=p+5; |
|---|
| 518 | continue; |
|---|
| 519 | } |
|---|
| 520 | |
|---|
| 521 | if (strncmp(p,"gizmo?",6) == 0 || strncmp(p,"gizmo=",6) == 0) { |
|---|
| 522 | q=p+6; if (!*q) fatal(p); |
|---|
| 523 | if (vgzrp) { /* gizmo already defined */ |
|---|
| 524 | for (gizmap=vgzrp; gizmap->nextp; ) |
|---|
| 525 | gizmap=gizmap->nextp; |
|---|
| 526 | gizmread(q,&gizmap->nextp,(grec)?grec:(grec=nrecs)); |
|---|
| 527 | gizmap=gizmap->nextp; |
|---|
| 528 | } |
|---|
| 529 | else { /* first gizmo definition */ |
|---|
| 530 | gizmread(q,&vgzrp,(grec)?grec:(grec=nrecs)); |
|---|
| 531 | } |
|---|
| 532 | if (parmtrace) { |
|---|
| 533 | for (gizmap=vgzrp; gizmap; gizmap=gizmap->nextp) |
|---|
| 534 | printf("+++ gizmo=%s \n",gizmap->gdbnp); |
|---|
| 535 | } |
|---|
| 536 | parmgizmo=1; |
|---|
| 537 | continue; |
|---|
| 538 | } |
|---|
| 539 | |
|---|
| 540 | if (!strncmp(p,"count=",6)) { |
|---|
| 541 | p=p+6; |
|---|
| 542 | if ((sscanf(p,"%"_LD_,&parmcount)) != 1) |
|---|
| 543 | fatal(p); |
|---|
| 544 | continue; |
|---|
| 545 | } |
|---|
| 546 | if (!strncmp(p,"tell=",5)) { |
|---|
| 547 | p=p+5; |
|---|
| 548 | if ((sscanf(p,"%"_LD_,&parmtell)) != 1) |
|---|
| 549 | fatal(p); |
|---|
| 550 | continue; |
|---|
| 551 | } |
|---|
| 552 | |
|---|
| 553 | if (!strncmp(p,"DP=",3)) { |
|---|
| 554 | p=p+3; |
|---|
| 555 | if ((sscanf(p,"%d",&parmDP)) != 1) |
|---|
| 556 | fatal(p); |
|---|
| 557 | #if BEFORE20000310 |
|---|
| 558 | if (parmDP < 48 || parmDP > 99) |
|---|
| 559 | fatal("parmDP 48..99"); |
|---|
| 560 | #endif |
|---|
| 561 | DP1=parmDP/10; DP2=parmDP-DP1*10; |
|---|
| 562 | printf("+++ parmDP=%d%d",DP1,DP2); |
|---|
| 563 | DP1|=0xF0; /* EBCDIC '0' */ |
|---|
| 564 | DP2|=0xF0; /* */ |
|---|
| 565 | printf("=%02x%02x \n",DP1,DP2); |
|---|
| 566 | continue; |
|---|
| 567 | } |
|---|
| 568 | |
|---|
| 569 | if (!strncmp(argv[i],"APPEND",6)) { |
|---|
| 570 | parmappd=1; |
|---|
| 571 | printf("+++ APPEND \n"); |
|---|
| 572 | continue; |
|---|
| 573 | } |
|---|
| 574 | |
|---|
| 575 | if (!strncmp(argv[i],"TA=NO",5)) { |
|---|
| 576 | parmTAn=1; |
|---|
| 577 | nlmtag[NLMTAGTA] = 0; |
|---|
| 578 | nlmtag[NLMTAGIS] = 0; |
|---|
| 579 | nlmtag[NLMTAGCY] = 0; |
|---|
| 580 | printf("+++ parmTAn=%d parmTAy=%d \n",parmTAn,parmTAy); |
|---|
| 581 | continue; |
|---|
| 582 | } |
|---|
| 583 | |
|---|
| 584 | /*if (!strncmp(argv[i],"TA=YES",6)) { |
|---|
| 585 | parmTAy=1; |
|---|
| 586 | for (j=0; j<MAXTAG; ) nlmtag[j++]=0; |
|---|
| 587 | nlmtag[NLMTAGJC] = 1; |
|---|
| 588 | nlmtag[NLMTAGTA] = 1; |
|---|
| 589 | nlmtag[NLMTAGIS] = 1; |
|---|
| 590 | nlmtag[NLMTAGCY] = 1; |
|---|
| 591 | printf("+++ parmTAn=%d parmTAy=%d \n",parmTAn,parmTAy); |
|---|
| 592 | continue; |
|---|
| 593 | } |
|---|
| 594 | */ |
|---|
| 595 | |
|---|
| 596 | /* TOXLINE - AOT/MB/FJL 14/06/2000 */ |
|---|
| 597 | if (!strcmp(argv[i],"TOXLINE")) { |
|---|
| 598 | parmTOX=1; |
|---|
| 599 | nlmtag[NLMTAGCN] = 1; |
|---|
| 600 | nlmtag[NLMTAGSO] = 1; |
|---|
| 601 | nlmtag[NLMTAGGS] = 1; |
|---|
| 602 | nlmtag[NLMTAGOD] = 1; |
|---|
| 603 | nlmtag[NLMTAGPR] = 1; |
|---|
| 604 | nlmtag[NLMTAGKW] = 1; |
|---|
| 605 | nlmtag[TOXTAGAD] = 1; |
|---|
| 606 | nlmtag[TOXTAGCY] = 1; |
|---|
| 607 | nlmtag[TOXTAGEM] = 1; |
|---|
| 608 | printf("+++ TOXLINE \n"); |
|---|
| 609 | continue; |
|---|
| 610 | } |
|---|
| 611 | |
|---|
| 612 | fatal(p); |
|---|
| 613 | } |
|---|
| 614 | |
|---|
| 615 | |
|---|
| 616 | printf("+++ output data base: %s\n",dbnoutp); |
|---|
| 617 | |
|---|
| 618 | |
|---|
| 619 | /* |
|---|
| 620 | inicializa bases de dados |
|---|
| 621 | */ |
|---|
| 622 | if (strncmp(dbnoutp,"create=",7) == 0) { |
|---|
| 623 | rc=recisis0((dbnoutp+=7)); |
|---|
| 624 | /* printf("+++ recisis0=%d\n",rc); */ |
|---|
| 625 | } |
|---|
| 626 | |
|---|
| 627 | /* |
|---|
| 628 | ve entrada |
|---|
| 629 | */ |
|---|
| 630 | RECORD((irec=nrecs),dbnamep,0L); |
|---|
| 631 | if (!parmto) parmto=MF0nxtmfn-1; |
|---|
| 632 | if (parmcontrol) prtcontrol(recp,dbnamep); |
|---|
| 633 | |
|---|
| 634 | /* |
|---|
| 635 | ve saida |
|---|
| 636 | */ |
|---|
| 637 | RECORD((upcrec=nrecs),dbnoutp,0L); |
|---|
| 638 | if (parmcontrol) prtcontrol(recp,dbnoutp); |
|---|
| 639 | |
|---|
| 640 | /* |
|---|
| 641 | loop principal |
|---|
| 642 | */ |
|---|
| 643 | for (upirec=nrecs, mfn=parmfrom; mfn<=parmto; mfn+=parmloop) { |
|---|
| 644 | |
|---|
| 645 | RECORD(irec,dbnamep,mfn); |
|---|
| 646 | |
|---|
| 647 | if (RECrc != RCNORMAL) |
|---|
| 648 | continue; |
|---|
| 649 | |
|---|
| 650 | /* printf("*** mfn=%"_LD_" \n",MFRmfn); */ |
|---|
| 651 | |
|---|
| 652 | #if BEFORE20000320 |
|---|
| 653 | if (parmDP) { |
|---|
| 654 | #else |
|---|
| 655 | if (parmDP >= 0) { |
|---|
| 656 | #endif |
|---|
| 657 | xdir=fieldx(irec,NLMTAGDP,1); |
|---|
| 658 | if (xdir >= 0) { |
|---|
| 659 | if (DIRlen(xdir) >= 4) { |
|---|
| 660 | p=FIELDP(xdir); |
|---|
| 661 | if (*(p+2) != DP1) continue; |
|---|
| 662 | if (*(p+3) != DP2) continue; |
|---|
| 663 | } |
|---|
| 664 | } |
|---|
| 665 | else { |
|---|
| 666 | if (!parmappd) continue; |
|---|
| 667 | } |
|---|
| 668 | } |
|---|
| 669 | |
|---|
| 670 | if (parmleader) prtleader(recp,0L); |
|---|
| 671 | |
|---|
| 672 | for (xdir=0, loop1=MFRnvf; loop1--; xdir++) |
|---|
| 673 | for (p=FIELDP(xdir), loop2=DIRlen(xdir); loop2--; p++) { |
|---|
| 674 | if (*p < EBCBLANK) { |
|---|
| 675 | printf("*** mfn=%"_LD_" tag=%d left=%d ebcdic_chr=%02x\n", |
|---|
| 676 | MFRmfn,DIRtag(xdir),loop2,*p); |
|---|
| 677 | *p = EBCBLANK; |
|---|
| 678 | continue; |
|---|
| 679 | } |
|---|
| 680 | if (ebc2asc[*p] == INVALID) { |
|---|
| 681 | if (*p == SVCHR) |
|---|
| 682 | continue; |
|---|
| 683 | if (*p == EVCHR) |
|---|
| 684 | continue; |
|---|
| 685 | if (*p == SSCHR) |
|---|
| 686 | continue; |
|---|
| 687 | printf("*** mfn=%"_LD_" tag=%d left=%d ebcdic_chr=%02x\n", |
|---|
| 688 | MFRmfn,DIRtag(xdir),loop2,*p); |
|---|
| 689 | *p = EBCBLANK; |
|---|
| 690 | } |
|---|
| 691 | } |
|---|
| 692 | |
|---|
| 693 | MHnocc=nocc(irec,NLMTAGMH); |
|---|
| 694 | |
|---|
| 695 | batchp=buffup; *batchp=NULL; |
|---|
| 696 | |
|---|
| 697 | for (xdir=tag=0, loop1=MFRnvf; loop1--; xdir++) { |
|---|
| 698 | |
|---|
| 699 | if (DIRtag(xdir) < MINTAG || DIRtag(xdir) > MAXTAG) { |
|---|
| 700 | printf("*** mfn=%"_LD_" tag=%d \n", |
|---|
| 701 | MFRmfn,DIRtag(xdir)); |
|---|
| 702 | fatal("mdlmf/tag"); |
|---|
| 703 | } |
|---|
| 704 | |
|---|
| 705 | if (nlmtag[DIRtag(xdir)] == 0) |
|---|
| 706 | continue; |
|---|
| 707 | |
|---|
| 708 | if (DIRtag(xdir) != tag) { |
|---|
| 709 | tag=DIRtag(xdir); |
|---|
| 710 | iocc=1; |
|---|
| 711 | } |
|---|
| 712 | else |
|---|
| 713 | iocc++; |
|---|
| 714 | |
|---|
| 715 | if (DIRlen(xdir) < 1) { |
|---|
| 716 | printf("*** mfn=%"_LD_" tag=%d occ=%d len=%d \n", |
|---|
| 717 | MFRmfn,DIRtag(xdir),iocc,DIRlen(xdir)); |
|---|
| 718 | if (DIRlen(xdir) == 0) |
|---|
| 719 | continue; |
|---|
| 720 | fatal("mdlmf/length"); |
|---|
| 721 | } |
|---|
| 722 | |
|---|
| 723 | |
|---|
| 724 | if (tag != NLMTAGMH) { |
|---|
| 725 | |
|---|
| 726 | switch (tag) { |
|---|
| 727 | |
|---|
| 728 | case NLMTAGAB: |
|---|
| 729 | sprintf(batchp,"A%3d%c",DIRtag(xdir),FLDUPDLM); batchp+=5; |
|---|
| 730 | p=FIELDP(xdir); loop2=DIRlen(xdir); |
|---|
| 731 | if (*(p+loop2-1) == EBCPERIOD) |
|---|
| 732 | loop2--; |
|---|
| 733 | for (; loop2--; ) { |
|---|
| 734 | if ( ebc2asc[*p] != INVALID) |
|---|
| 735 | *batchp++ = ebc2asc[*p++]; |
|---|
| 736 | else { |
|---|
| 737 | fprintf(filog,"+++ input data base: %s *** mfn=%"_LD_" tag=%d left=%d ebcdic_chr=%02x\n", dbnamep,MFRmfn,DIRtag(xdir),loop2,*p); |
|---|
| 738 | *p++; } |
|---|
| 739 | } |
|---|
| 740 | |
|---|
| 741 | if (fieldn(irec,NLMTAGAA,1)) { |
|---|
| 742 | sprintf(batchp," (Au)"); batchp+=5; |
|---|
| 743 | } |
|---|
| 744 | *batchp++ = FLDUPDLM; |
|---|
| 745 | break; |
|---|
| 746 | |
|---|
| 747 | |
|---|
| 748 | case NLMTAGTI: |
|---|
| 749 | if (fieldn(irec,NLMTAGTT,1)) |
|---|
| 750 | sprintf(batchp,"A%3d%c",NEWTAGTI_130,FLDUPDLM); |
|---|
| 751 | else |
|---|
| 752 | sprintf(batchp,"A%3d%c",DIRtag(xdir),FLDUPDLM); |
|---|
| 753 | batchp+=5; |
|---|
| 754 | p=FIELDP(xdir); loop2=DIRlen(xdir); |
|---|
| 755 | if (*(p+loop2-1) == EBCPERIOD) |
|---|
| 756 | loop2--; |
|---|
| 757 | if (*p == EBCOSQBR) |
|---|
| 758 | if (*(p+loop2-1) == EBCCSQBR) { |
|---|
| 759 | p++; loop2--; |
|---|
| 760 | loop2--; |
|---|
| 761 | } |
|---|
| 762 | |
|---|
| 763 | for (; loop2--; ) { |
|---|
| 764 | if ( ebc2asc[*p] != INVALID) |
|---|
| 765 | *batchp++ = ebc2asc[*p++]; |
|---|
| 766 | else { |
|---|
| 767 | fprintf(filog, "+++ input data base: %s *** mfn=%"_LD_" tag=%d left=%d ebcdic_chr=%02x\n", dbnamep,MFRmfn,DIRtag(xdir),loop2,*p); |
|---|
| 768 | *p++; } |
|---|
| 769 | } |
|---|
| 770 | |
|---|
| 771 | *batchp++ = FLDUPDLM; |
|---|
| 772 | break; |
|---|
| 773 | |
|---|
| 774 | case NLMTAGRN: |
|---|
| 775 | sprintf(batchp,"A%3d%c",DIRtag(xdir),FLDUPDLM); |
|---|
| 776 | batchp+=5; |
|---|
| 777 | *batchp++ = '^'; *batchp++ = 'a'; |
|---|
| 778 | p=FIELDP(xdir); loop2=DIRlen(xdir); |
|---|
| 779 | if (*(p+loop2-1) == EBCCPARE) |
|---|
| 780 | loop2--; |
|---|
| 781 | for (; loop2; ) { |
|---|
| 782 | if (*p == EBCOPARE) |
|---|
| 783 | break; |
|---|
| 784 | loop2--; |
|---|
| 785 | *batchp++ = ebc2asc[*p++]; |
|---|
| 786 | } |
|---|
| 787 | if (*(batchp-1) == ' ') { batchp--; } |
|---|
| 788 | if (*p == EBCOPARE) { loop2--; p++; } |
|---|
| 789 | *batchp++ = '^'; *batchp++ = 'b'; |
|---|
| 790 | for (; loop2--; ) |
|---|
| 791 | *batchp++ = ebc2asc[*p++]; |
|---|
| 792 | *batchp++ = FLDUPDLM; |
|---|
| 793 | break; |
|---|
| 794 | |
|---|
| 795 | case NLMTAGTT: |
|---|
| 796 | sprintf(batchp,"A%3d%c",DIRtag(xdir),FLDUPDLM); batchp+=5; |
|---|
| 797 | p=FIELDP(xdir); loop2=DIRlen(xdir); |
|---|
| 798 | if (*(p+loop2-1) == EBCPERIOD) |
|---|
| 799 | loop2--; |
|---|
| 800 | for (; loop2--; ) { |
|---|
| 801 | if ( ebc2asc[*p] != INVALID) |
|---|
| 802 | *batchp++ = ebc2asc[*p++]; |
|---|
| 803 | else { |
|---|
| 804 | fprintf(filog,"+++ input data base: %s *** mfn=%"_LD_" tag=%d left=%d ebcdic_chr=%02x\n", dbnamep,MFRmfn,DIRtag(xdir),loop2,*p); |
|---|
| 805 | *p++; } |
|---|
| 806 | } |
|---|
| 807 | *batchp++ = FLDUPDLM; |
|---|
| 808 | break; |
|---|
| 809 | |
|---|
| 810 | case NLMTAGAD: |
|---|
| 811 | sprintf(batchp,"A%3d%c",DIRtag(xdir),FLDUPDLM); batchp+=5; |
|---|
| 812 | p=FIELDP(xdir); loop2=DIRlen(xdir); |
|---|
| 813 | if (*(p+loop2-1) == EBCPERIOD) |
|---|
| 814 | loop2--; |
|---|
| 815 | for (; loop2--; ) { |
|---|
| 816 | if ( ebc2asc[*p] != INVALID) |
|---|
| 817 | *batchp++ = ebc2asc[*p++]; |
|---|
| 818 | else { |
|---|
| 819 | fprintf(filog,"+++ input data base: %s *** mfn=%"_LD_" tag=%d left=%d ebcdic_chr=%02x\n", dbnamep,MFRmfn,DIRtag(xdir),loop2,*p); |
|---|
| 820 | *p++; } |
|---|
| 821 | } |
|---|
| 822 | *batchp++ = FLDUPDLM; |
|---|
| 823 | break; |
|---|
| 824 | |
|---|
| 825 | case NLMTAGCY: |
|---|
| 826 | case NLMTAGAU: |
|---|
| 827 | case NLMTAGPS: |
|---|
| 828 | case NLMTAGPT: |
|---|
| 829 | case NLMTAGCO: |
|---|
| 830 | sprintf(batchp,"A%3d%c",DIRtag(xdir),FLDUPDLM); batchp+=5; |
|---|
| 831 | for (p=FIELDP(xdir), loop2=DIRlen(xdir); loop2--; ) { |
|---|
| 832 | if (*p == SVCHR) |
|---|
| 833 | break; |
|---|
| 834 | if (*p == SSCHR) { |
|---|
| 835 | *batchp++ = '/'; p++; |
|---|
| 836 | } |
|---|
| 837 | else |
|---|
| 838 | *batchp++ = ebc2asc[*p++]; |
|---|
| 839 | } |
|---|
| 840 | *batchp++ = FLDUPDLM; |
|---|
| 841 | break; |
|---|
| 842 | |
|---|
| 843 | case NLMTAGEA: |
|---|
| 844 | sprintf(batchp,"A%3d%c",DIRtag(xdir),FLDUPDLM); batchp+=5; |
|---|
| 845 | sprintf(batchp,"En"); batchp+=2; |
|---|
| 846 | *batchp++ = FLDUPDLM; |
|---|
| 847 | break; |
|---|
| 848 | |
|---|
| 849 | case NLMTAGDP: |
|---|
| 850 | sprintf(batchp,"A%3d%c",DIRtag(xdir),FLDUPDLM); batchp+=5; |
|---|
| 851 | for (p=FIELDP(xdir), loop2=DIRlen(xdir); loop2--; ) |
|---|
| 852 | *batchp++ = ebc2asc[*p++]; |
|---|
| 853 | *batchp++ = FLDUPDLM; |
|---|
| 854 | #if ENAB650 |
|---|
| 855 | q=DPin; |
|---|
| 856 | for (p=FIELDP(xdir), loop2=DIRlen(xdir); loop2--; ) { |
|---|
| 857 | *q++ = toupper(ebc2asc[*p++]); |
|---|
| 858 | } |
|---|
| 859 | *q = '\0'; |
|---|
| 860 | if (DPconvert(DPin,DIRlen(xdir))) { |
|---|
| 861 | sprintf(batchp,"A%3d%c",NEWTAGDP_650,FLDUPDLM); |
|---|
| 862 | batchp+=5; |
|---|
| 863 | strcpy(batchp,DPok); batchp+=strlen(batchp); |
|---|
| 864 | *batchp++ = FLDUPDLM; |
|---|
| 865 | } |
|---|
| 866 | if (*DPerrp != '\0') { |
|---|
| 867 | printf("*** mfn=%"_LD_" tag=%d DP = '", |
|---|
| 868 | MFRmfn,DIRtag(xdir)); |
|---|
| 869 | for (p=FIELDP(xdir), loop2=DIRlen(xdir); loop2--; p++) |
|---|
| 870 | printf("%c",ebc2asc[*p]); |
|---|
| 871 | printf("' [%s]\n",DPerrp); |
|---|
| 872 | } |
|---|
| 873 | #endif |
|---|
| 874 | break; |
|---|
| 875 | |
|---|
| 876 | #define ENABLA1 1 |
|---|
| 877 | #define ENABLA2 0 |
|---|
| 878 | #if ENABLA1 |
|---|
| 879 | case NLMTAGLA: |
|---|
| 880 | sprintf(batchp,"A%3d%c",DIRtag(xdir),FLDUPDLM); batchp+=5; |
|---|
| 881 | #if ENABLA2 |
|---|
| 882 | q=LAin; |
|---|
| 883 | for (p=FIELDP(xdir), loop2=DIRlen(xdir); loop2--; ) |
|---|
| 884 | *q++ = toupper(ebc2asc[*p++]); |
|---|
| 885 | for (p=LAtab[0]; *p; p+=(LATABSIZ+1)) { |
|---|
| 886 | if ((i=strncmp(LAin,p,LANLMSIZ)) == 0) { |
|---|
| 887 | for (p+=(LANLMSIZ+1), loop2=LAISOSIZ; loop2--; ) |
|---|
| 888 | *batchp++ = *p++; |
|---|
| 889 | break; |
|---|
| 890 | } |
|---|
| 891 | if (i < 0) /* gt */ |
|---|
| 892 | break; |
|---|
| 893 | } |
|---|
| 894 | if (*(batchp-1) == FLDUPDLM) { |
|---|
| 895 | printf("*** mfn=%"_LD_" tag=%d LA = '", |
|---|
| 896 | MFRmfn,DIRtag(xdir)); |
|---|
| 897 | for (p=FIELDP(xdir), loop2=DIRlen(xdir); loop2--; ) { |
|---|
| 898 | printf("%c",ebc2asc[*p]); |
|---|
| 899 | *batchp++ = ebc2asc[*p++]; |
|---|
| 900 | } |
|---|
| 901 | printf("'\n"); |
|---|
| 902 | } |
|---|
| 903 | #else |
|---|
| 904 | for (p=FIELDP(xdir), loop2=DIRlen(xdir); loop2--; ) |
|---|
| 905 | *batchp++ = ebc2asc[*p++]; |
|---|
| 906 | #endif |
|---|
| 907 | *batchp++ = FLDUPDLM; |
|---|
| 908 | break; |
|---|
| 909 | #endif |
|---|
| 910 | |
|---|
| 911 | default: |
|---|
| 912 | if (nlmtag[tag] != 1 && nlmtag[tag] != 2) { |
|---|
| 913 | printf("*** mfn=%"_LD_" tag=%d \n", |
|---|
| 914 | MFRmfn,DIRtag(xdir)); |
|---|
| 915 | printf(" '"); /* health */ |
|---|
| 916 | for (p=FIELDP(xdir), loop2=DIRlen(xdir); loop2--; ) |
|---|
| 917 | printf("%c",ebc2asc[*p++]); |
|---|
| 918 | printf("' \n"); /* health */ |
|---|
| 919 | fatal("mdlmf/switch"); |
|---|
| 920 | } |
|---|
| 921 | sprintf(batchp,"A%3d%c",DIRtag(xdir),FLDUPDLM); batchp+=5; |
|---|
| 922 | p=FIELDP(xdir); loop2=DIRlen(xdir); /* health */ |
|---|
| 923 | if (*(p+loop2-1) == EBCPERIOD) |
|---|
| 924 | loop2--; /* health */ |
|---|
| 925 | for (; loop2--; ) |
|---|
| 926 | *batchp++ = ebc2asc[*p++]; |
|---|
| 927 | *batchp++ = FLDUPDLM; |
|---|
| 928 | |
|---|
| 929 | } /* end of switch */ |
|---|
| 930 | |
|---|
| 931 | tag=0; /* ????? */ |
|---|
| 932 | continue; /* next dir entry */ |
|---|
| 933 | } |
|---|
| 934 | |
|---|
| 935 | |
|---|
| 936 | #if TRACE |
|---|
| 937 | printf("iocc=%d/%d '",iocc,MHnocc); |
|---|
| 938 | for (p=FIELDP(xdir), i=DIRlen(xdir); i--; p++) |
|---|
| 939 | putchar(ebc2asc[*p]); |
|---|
| 940 | printf("'\n"); |
|---|
| 941 | #endif |
|---|
| 942 | |
|---|
| 943 | if (iocc == 1) { |
|---|
| 944 | sprintf(batchp,"A%3d%c",DIRtag(xdir),FLDUPDLM); batchp+=5; |
|---|
| 945 | } |
|---|
| 946 | else { |
|---|
| 947 | if (!parmzdecs) { |
|---|
| 948 | sprintf(batchp,"; "); batchp+=2; |
|---|
| 949 | } |
|---|
| 950 | else { |
|---|
| 951 | sprintf(batchp,";"); batchp+=1; |
|---|
| 952 | zsave+=1; |
|---|
| 953 | } |
|---|
| 954 | } |
|---|
| 955 | |
|---|
| 956 | if (parmzdecs) zdp=batchp; |
|---|
| 957 | |
|---|
| 958 | for (zx0=0, p=FIELDP(xdir), loop2=DIRlen(xdir); loop2; ) { |
|---|
| 959 | if (*p == SSCHR) |
|---|
| 960 | break; |
|---|
| 961 | *batchp++ = ebc2asc[*p++]; |
|---|
| 962 | loop2--; zx0++; |
|---|
| 963 | } |
|---|
| 964 | totz+=zx0; |
|---|
| 965 | |
|---|
| 966 | if (parmzdecs) { |
|---|
| 967 | *batchp='\0'; zdlookup++; |
|---|
| 968 | if (parmtrace) printf("+++ %d: %s\n",DIRtag(xdir),zdp); |
|---|
| 969 | for (z1p=zdp, z2p=zkey; *z1p; ) *z2p++ = isisuctab[*z1p++]; |
|---|
| 970 | *z2p='\0'; |
|---|
| 971 | TERM(itrm,zdbnp,zkey); |
|---|
| 972 | if (TRMrc == RCNORMAL) { |
|---|
| 973 | if (posting(itrm,0L) > 1) { |
|---|
| 974 | fprintf(stderr,"*** key=%s\n",TRMkey); |
|---|
| 975 | fatal("mdlmf/zdecs/more than 1 posting"); |
|---|
| 976 | } |
|---|
| 977 | batchp=zdp; |
|---|
| 978 | sprintf(batchp,"%"_LD_,posting(itrm,1L)); |
|---|
| 979 | batchp+=(zx1=strlen(batchp)); |
|---|
| 980 | if (parmtrace) { |
|---|
| 981 | printf("+++ %d: %s -> %"_LD_"\n",DIRtag(xdir),zkey,TRMpmfn); |
|---|
| 982 | } |
|---|
| 983 | zsave+=(zx0-zx1); |
|---|
| 984 | } |
|---|
| 985 | else { |
|---|
| 986 | if (!parmok) { |
|---|
| 987 | printf("*** mfn=%"_LD_" tag=%d key=%s -> NOT FOUND \n", |
|---|
| 988 | MFRmfn,DIRtag(xdir),zkey); |
|---|
| 989 | fprintf(fplog,"*** mfn=%"_LD_" tag=%d key=%s -> NOT FOUND \n", |
|---|
| 990 | MFRmfn,DIRtag(xdir),zkey); |
|---|
| 991 | } |
|---|
| 992 | zdnotf++; |
|---|
| 993 | } |
|---|
| 994 | } |
|---|
| 995 | |
|---|
| 996 | |
|---|
| 997 | if (*p != SSCHR) { |
|---|
| 998 | /* fatal("1\\SS\\2"); */ |
|---|
| 999 | printf("1\\SS\\2 - mfn=%"_LD_" tag=%d occ=%d\n", |
|---|
| 1000 | MFRmfn,DIRtag(xdir),iocc); |
|---|
| 1001 | if (iocc == MHnocc) *batchp++ = FLDUPDLM; |
|---|
| 1002 | continue; |
|---|
| 1003 | } |
|---|
| 1004 | p++; loop2--; |
|---|
| 1005 | p++; loop2--; |
|---|
| 1006 | |
|---|
| 1007 | |
|---|
| 1008 | if (*p != SSCHR) { |
|---|
| 1009 | /* fatal("2\\SS\\3"); */ |
|---|
| 1010 | printf("2\\SS\\3 - mfn=%"_LD_" tag=%d occ=%d\n", |
|---|
| 1011 | MFRmfn,DIRtag(xdir),iocc); |
|---|
| 1012 | if (iocc == MHnocc) *batchp++ = FLDUPDLM; |
|---|
| 1013 | continue; |
|---|
| 1014 | } |
|---|
| 1015 | p++; loop2--; |
|---|
| 1016 | p++; loop2--; |
|---|
| 1017 | |
|---|
| 1018 | |
|---|
| 1019 | if (loop2 < 0) { |
|---|
| 1020 | printf("loop2<0 - mfn=%"_LD_" tag=%d occ=%d loop2=%d \n", |
|---|
| 1021 | MFRmfn,DIRtag(xdir),iocc,loop2); |
|---|
| 1022 | if (iocc == MHnocc) *batchp++ = FLDUPDLM; |
|---|
| 1023 | continue; |
|---|
| 1024 | } |
|---|
| 1025 | |
|---|
| 1026 | |
|---|
| 1027 | if (*p == SSCHR) { |
|---|
| 1028 | p++; loop2--; |
|---|
| 1029 | *batchp++ = '/'; |
|---|
| 1030 | while (loop2--) { |
|---|
| 1031 | if (*p == SVCHR) |
|---|
| 1032 | break; |
|---|
| 1033 | if (*p == EVCHR) |
|---|
| 1034 | break; |
|---|
| 1035 | *batchp++ = ebc2asc[*p++]; |
|---|
| 1036 | } |
|---|
| 1037 | } |
|---|
| 1038 | |
|---|
| 1039 | if (iocc == MHnocc) *batchp++ = FLDUPDLM; |
|---|
| 1040 | |
|---|
| 1041 | } /* next dir entry */ |
|---|
| 1042 | |
|---|
| 1043 | |
|---|
| 1044 | *batchp='\0'; |
|---|
| 1045 | |
|---|
| 1046 | #if TRACE |
|---|
| 1047 | printf("buffup='%s'\n",buffup); |
|---|
| 1048 | #endif |
|---|
| 1049 | |
|---|
| 1050 | RECORD(upirec,dbnoutp,VMF0nxtmfn(upcrec)); /* get null PDEL record */ |
|---|
| 1051 | MFRstatus=ACTIVE; |
|---|
| 1052 | |
|---|
| 1053 | p=fldupdat(upirec,buffup); |
|---|
| 1054 | if (p) { |
|---|
| 1055 | printf("*** mfn=%"_LD_" fldupdat='%s'\n",mfn,p); |
|---|
| 1056 | fatal("mdlmf/fldupdat"); |
|---|
| 1057 | } |
|---|
| 1058 | |
|---|
| 1059 | #if PROC |
|---|
| 1060 | if (mp_n) mp_edit(upirec,0,mp_n-1); |
|---|
| 1061 | #endif /* PROC */ |
|---|
| 1062 | |
|---|
| 1063 | gmfrl0=VMFRmfrl(upirec); |
|---|
| 1064 | totg+=VMFRmfrl(upirec)-VMFRbase(upirec); |
|---|
| 1065 | if (parmgizmo) |
|---|
| 1066 | for (gizmap=vgzrp; gizmap; gizmap=gizmap->nextp) |
|---|
| 1067 | recgizmo(upirec,gizmap); |
|---|
| 1068 | gsave+=gmfrl0-VMFRmfrl(upirec); |
|---|
| 1069 | |
|---|
| 1070 | |
|---|
| 1071 | if (parmfields) { |
|---|
| 1072 | tag=NULL; iocc=1; |
|---|
| 1073 | for (xdir=0, loop1=MFRnvf; loop1--; xdir++) { |
|---|
| 1074 | if (DIRtag(xdir) == tag) { |
|---|
| 1075 | iocc++; |
|---|
| 1076 | } |
|---|
| 1077 | else { |
|---|
| 1078 | tag=DIRtag(xdir); |
|---|
| 1079 | iocc=1; |
|---|
| 1080 | } |
|---|
| 1081 | printf("%6"_LD_"|%3d|%3d|",MFRmfn,DIRtag(xdir),iocc); |
|---|
| 1082 | for (p=FIELDP(xdir), loop2=DIRlen(xdir); loop2--; p++) |
|---|
| 1083 | #if SHOWHEX |
|---|
| 1084 | if (*p < ' ' || *p > '}') printf("|x%02x|",*p); else |
|---|
| 1085 | #endif |
|---|
| 1086 | printf("%c",*p); |
|---|
| 1087 | printf("|\n"); |
|---|
| 1088 | } |
|---|
| 1089 | } |
|---|
| 1090 | |
|---|
| 1091 | |
|---|
| 1092 | for (xdir=0, loop1=MFRnvf; loop1--; xdir++) |
|---|
| 1093 | for (p=FIELDP(xdir), loop2=DIRlen(xdir); loop2--; p++) |
|---|
| 1094 | if (*p == INVALID) { |
|---|
| 1095 | printf("*** mfn=%"_LD_" tag=%d left=%d chr=%02x", |
|---|
| 1096 | MFRmfn,DIRtag(xdir),loop2,*p); |
|---|
| 1097 | printf(" '"); /* health */ |
|---|
| 1098 | for (p=FIELDP(xdir), loop2=DIRlen(xdir); loop2--; p++) |
|---|
| 1099 | printf("%c",(*p == INVALID) ? '?' : *p); |
|---|
| 1100 | printf("' \n"); /* health */ |
|---|
| 1101 | fatal("mdlmf/invalid"); |
|---|
| 1102 | } |
|---|
| 1103 | |
|---|
| 1104 | /* TOXLINE - AOT/MB/FJL 14/06/2000 */ |
|---|
| 1105 | if (parmTOX) |
|---|
| 1106 | for (xdir=0, loop1=MFRnvf; loop1--; xdir++) { |
|---|
| 1107 | tag=DIRtag(xdir); |
|---|
| 1108 | if (tag == TOXTAGN1) fatal("mdlmf/TOXLINE/TOXTAGN1"); |
|---|
| 1109 | if (tag == TOXTAGN2) fatal("mdlmf/TOXLINE/TOXTAGN2"); |
|---|
| 1110 | if (tag == TOXTAGN3) fatal("mdlmf/TOXLINE/TOXTAGN3"); |
|---|
| 1111 | } |
|---|
| 1112 | |
|---|
| 1113 | if (parmcopy) { |
|---|
| 1114 | rc=recupdat(upcrec,upirec); |
|---|
| 1115 | if (rc) { |
|---|
| 1116 | printf("*** recupdat=%d\n",rc); |
|---|
| 1117 | fatal("mdlmf/recupdat"); |
|---|
| 1118 | } |
|---|
| 1119 | } |
|---|
| 1120 | |
|---|
| 1121 | count++; |
|---|
| 1122 | totmfrl+=VMFRmfrl(upirec); |
|---|
| 1123 | totleader+=LEADER; |
|---|
| 1124 | totdir+=VMFRbase(upirec)-LEADER; |
|---|
| 1125 | totdata+=VMFRmfrl(upirec)-VMFRbase(upirec); |
|---|
| 1126 | |
|---|
| 1127 | if (parmtell) |
|---|
| 1128 | if (!(count % parmtell)) { |
|---|
| 1129 | tot0=totmfrl; |
|---|
| 1130 | tot1=zsave+gsave; |
|---|
| 1131 | fprintf(stderr, |
|---|
| 1132 | /* |
|---|
| 1133 | "+++ %"_LD_" mfn=%"_LD_" mfrl=%d=%d+%d(%d)+%d ", |
|---|
| 1134 | count,MFRmfn,MFRmfrl, |
|---|
| 1135 | LEADER,MFRbase-LEADER,MFRnvf,MFRmfrl-MFRbase); |
|---|
| 1136 | */ |
|---|
| 1137 | "+++ %"_LD_" w=%"_LD_" ", |
|---|
| 1138 | count,totmfrl); |
|---|
| 1139 | if (parmzdecs) { |
|---|
| 1140 | fprintf(stderr," z=%"_LD_"=%d%% ", |
|---|
| 1141 | zsave,(int)(10*(zsave*100/totz)+5)/10); |
|---|
| 1142 | if (zdnotf) fprintf(stderr,"%"_LD_"! ",zdnotf); |
|---|
| 1143 | } |
|---|
| 1144 | if (parmgizmo) fprintf(stderr," g=%"_LD_"=%d%% ", |
|---|
| 1145 | gsave,(int)(10*(gsave*100/totg)+5)/10); |
|---|
| 1146 | fprintf(stderr," s=%"_LD_"=%d%% ", |
|---|
| 1147 | tot1,(int)(10*(tot1*100/tot0)+5)/10); |
|---|
| 1148 | fprintf(stderr,"\n"); |
|---|
| 1149 | fprintf(fplog, |
|---|
| 1150 | "+++ %"_LD_" w=%"_LD_" [%"_LD_"+%"_LD_"+%"_LD_"] ", |
|---|
| 1151 | count,totmfrl, |
|---|
| 1152 | totleader,totdir,totdata); |
|---|
| 1153 | if (parmzdecs) fprintf(fplog," z=%"_LD_"=%d%% [%"_LD_"-%"_LD_"] ", |
|---|
| 1154 | zsave,(int)(10*(zsave*100/totz)+5)/10, |
|---|
| 1155 | zdlookup,zdnotf); |
|---|
| 1156 | if (parmgizmo) fprintf(fplog," g=%"_LD_"=%d%% ", |
|---|
| 1157 | gsave,(int)(10*(gsave*100/totg)+5)/10); |
|---|
| 1158 | fprintf(fplog," s=%"_LD_"=%d%% ", |
|---|
| 1159 | tot1,(int)(10*(tot1*100/tot0)+5)/10); |
|---|
| 1160 | fprintf(fplog,"\n"); |
|---|
| 1161 | } |
|---|
| 1162 | |
|---|
| 1163 | if (parmwait) { |
|---|
| 1164 | printf(".."); |
|---|
| 1165 | if (getchar() != '\n') |
|---|
| 1166 | break; |
|---|
| 1167 | } |
|---|
| 1168 | |
|---|
| 1169 | if (count >= parmcount) |
|---|
| 1170 | break; |
|---|
| 1171 | } |
|---|
| 1172 | |
|---|
| 1173 | if (parmgizp) dbxstorp(tmpnam(NULL))->dbxvgzrp=vgzrp; |
|---|
| 1174 | |
|---|
| 1175 | mxexit(0); |
|---|
| 1176 | } |
|---|
| 1177 | |
|---|
| 1178 | |
|---|
| 1179 | #if ENAB650 |
|---|
| 1180 | unsigned char *DPconvert(errp,n) |
|---|
| 1181 | unsigned char *errp; |
|---|
| 1182 | int n; |
|---|
| 1183 | { |
|---|
| 1184 | int loop,month; |
|---|
| 1185 | unsigned char *p,*q,*mop,edit[3]; |
|---|
| 1186 | |
|---|
| 1187 | static unsigned char motab[] = |
|---|
| 1188 | { "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC" }; |
|---|
| 1189 | |
|---|
| 1190 | sprintf(DPok,"00000000"); |
|---|
| 1191 | DPerrp=errp; |
|---|
| 1192 | |
|---|
| 1193 | if (n < 4) |
|---|
| 1194 | return(NULL); |
|---|
| 1195 | |
|---|
| 1196 | for (p=DPin, q=DPok, loop=4; loop--; ) |
|---|
| 1197 | if (isdigit(*p)) |
|---|
| 1198 | *q++ = *p++; |
|---|
| 1199 | else |
|---|
| 1200 | return(NULL); |
|---|
| 1201 | n-=4; /* space/month/space/day */ |
|---|
| 1202 | DPerrp+=4; |
|---|
| 1203 | |
|---|
| 1204 | if (n >= 3) |
|---|
| 1205 | if (*p == '-') |
|---|
| 1206 | if (isdigit(*(p+1))) |
|---|
| 1207 | if (isdigit(*(p+2))) { |
|---|
| 1208 | *(q-2) = *(p+1); |
|---|
| 1209 | *(q-1) = *(p+2); |
|---|
| 1210 | p+=3; |
|---|
| 1211 | n-=3; /* space/month/space/day */ |
|---|
| 1212 | DPerrp+=3; |
|---|
| 1213 | } |
|---|
| 1214 | |
|---|
| 1215 | if (n == 0) |
|---|
| 1216 | return(DPok); |
|---|
| 1217 | |
|---|
| 1218 | if (*p != ' ') |
|---|
| 1219 | return(NULL); |
|---|
| 1220 | |
|---|
| 1221 | p++; n--; /* month/space/day */ |
|---|
| 1222 | DPerrp++; |
|---|
| 1223 | |
|---|
| 1224 | if (n < 3) |
|---|
| 1225 | return(DPok); |
|---|
| 1226 | |
|---|
| 1227 | for (mop=motab, month=1; *mop; month++, mop+=3) |
|---|
| 1228 | if (*mop == *p) |
|---|
| 1229 | if (*(mop+1) == *(p+1)) |
|---|
| 1230 | if (*(mop+2) == *(p+2)) { |
|---|
| 1231 | sprintf(edit,"%02d",month); |
|---|
| 1232 | *q++ = edit[0]; |
|---|
| 1233 | *q++ = edit[1]; |
|---|
| 1234 | p+=3; |
|---|
| 1235 | n-=3; /* space/day */ |
|---|
| 1236 | DPerrp+=3; |
|---|
| 1237 | break; |
|---|
| 1238 | } |
|---|
| 1239 | |
|---|
| 1240 | if (!*mop) |
|---|
| 1241 | return(DPok); |
|---|
| 1242 | |
|---|
| 1243 | if (*p == '-') { |
|---|
| 1244 | p++; |
|---|
| 1245 | n--; |
|---|
| 1246 | DPerrp++; |
|---|
| 1247 | for (mop=motab, month=1; *mop; month++, mop+=3) |
|---|
| 1248 | if (*mop == *p) |
|---|
| 1249 | if (*(mop+1) == *(p+1)) |
|---|
| 1250 | if (*(mop+2) == *(p+2)) { |
|---|
| 1251 | sprintf(edit,"%02d",month); |
|---|
| 1252 | *(q-2) = edit[0]; |
|---|
| 1253 | *(q-1) = edit[1]; |
|---|
| 1254 | p+=3; |
|---|
| 1255 | n-=3; /* space/day */ |
|---|
| 1256 | DPerrp+=3; |
|---|
| 1257 | break; |
|---|
| 1258 | } |
|---|
| 1259 | if (!*mop) |
|---|
| 1260 | return(NULL); |
|---|
| 1261 | } |
|---|
| 1262 | |
|---|
| 1263 | if (n == 0) |
|---|
| 1264 | return(DPok); |
|---|
| 1265 | |
|---|
| 1266 | if (*p != ' ') |
|---|
| 1267 | return(NULL); |
|---|
| 1268 | |
|---|
| 1269 | p++; n--; /* day */ |
|---|
| 1270 | DPerrp++; |
|---|
| 1271 | |
|---|
| 1272 | if (!isdigit(*p)) |
|---|
| 1273 | return(DPok); |
|---|
| 1274 | |
|---|
| 1275 | if (*(p+1) == '-') { |
|---|
| 1276 | p+=2; n-=2; |
|---|
| 1277 | DPerrp+=2; |
|---|
| 1278 | } |
|---|
| 1279 | else |
|---|
| 1280 | if (isdigit(*(p+1))) |
|---|
| 1281 | if (*(p+2) == '-') { |
|---|
| 1282 | p+=3; n-=3; |
|---|
| 1283 | DPerrp+=3; |
|---|
| 1284 | } |
|---|
| 1285 | |
|---|
| 1286 | if (!isdigit(*p)) |
|---|
| 1287 | return(DPok); |
|---|
| 1288 | |
|---|
| 1289 | if (isdigit(*(p+1))) { |
|---|
| 1290 | *q++ = *p++; |
|---|
| 1291 | *q++ = *p++; |
|---|
| 1292 | *q = '\0'; |
|---|
| 1293 | n-=2; |
|---|
| 1294 | DPerrp+=2; |
|---|
| 1295 | } |
|---|
| 1296 | else { |
|---|
| 1297 | *q++ = '0'; |
|---|
| 1298 | *q++ = *p++; |
|---|
| 1299 | *q = '\0'; |
|---|
| 1300 | n--; |
|---|
| 1301 | DPerrp++; |
|---|
| 1302 | } |
|---|
| 1303 | |
|---|
| 1304 | return(DPok); |
|---|
| 1305 | } |
|---|
| 1306 | #endif |
|---|
| 1307 | |
|---|
| 1308 | |
|---|
| 1309 | |
|---|
| 1310 | /* ============================== mxexit ================================== */ |
|---|
| 1311 | |
|---|
| 1312 | void mxexit(rc) |
|---|
| 1313 | int rc; |
|---|
| 1314 | { |
|---|
| 1315 | int i,n,igiz; |
|---|
| 1316 | LONGX idbx,nused; |
|---|
| 1317 | char *p,*q,usedbn[CIMPL+1],line[BUFSIZ+1]; |
|---|
| 1318 | VGIZPSTRU *gizmap; |
|---|
| 1319 | GIZMSTRU *gizmhp,*gizmp; |
|---|
| 1320 | |
|---|
| 1321 | if ((p=parmgizp) != NULL) { |
|---|
| 1322 | |
|---|
| 1323 | if (!upcrec) recallok((upcrec=nrecs),(LONGX)sizeof(M0STRU)); |
|---|
| 1324 | if (!upirec) recallok((upirec=nrecs),MAXMFRL); |
|---|
| 1325 | |
|---|
| 1326 | for (idbx=0L; idbx < ndbxs; idbx++) { |
|---|
| 1327 | for (gizmap=VDBXvgzrp(idbx), igiz=0; gizmap; igiz++, |
|---|
| 1328 | gizmap=gizmap->nextp) { |
|---|
| 1329 | sprintf(usedbn,"%s%d",parmgizp,igiz); |
|---|
| 1330 | recisis0(usedbn); record(upcrec,usedbn,0L); |
|---|
| 1331 | nused=0; |
|---|
| 1332 | if (parmtrace) printf("+++ %s/giz%d=%s\n", |
|---|
| 1333 | VDBXname(idbx),igiz,gizmap->gdbnp); |
|---|
| 1334 | for (i=0; i <= 255; i++) { |
|---|
| 1335 | gizmhp=gizmap->ghdrp[i]; |
|---|
| 1336 | if (!gizmhp) continue; |
|---|
| 1337 | for (gizmp=gizmhp; gizmp; gizmp=gizmp->nextp) { |
|---|
| 1338 | if (gizmp->nused == 0) continue; |
|---|
| 1339 | nused++; |
|---|
| 1340 | record(upirec,usedbn,VMF0nxtmfn(upcrec)); |
|---|
| 1341 | VMFRstatus(upirec)=ACTIVE; q=line; |
|---|
| 1342 | sprintf(q,"A10 #%"_LD_"#",gizmp->nused); q+=strlen(q); |
|---|
| 1343 | sprintf(q,"H1 %d ",gizmp->isize); q+=strlen(q); |
|---|
| 1344 | memcpy(q,gizmp->ipatt,n=gizmp->isize); q+=n; |
|---|
| 1345 | sprintf(q,"H2 %d ",gizmp->osize); q+=strlen(q); |
|---|
| 1346 | memcpy(q,gizmp->opatt,n=gizmp->osize); q+=n; |
|---|
| 1347 | sprintf(q,"A31 #%d#",gizmp->isize); q+=strlen(q); |
|---|
| 1348 | sprintf(q,"A32 #%d#",gizmp->osize); q+=strlen(q); |
|---|
| 1349 | *q = '\0'; |
|---|
| 1350 | if ((p=fldupdat(upirec,line)) != NULL) fatal(p); |
|---|
| 1351 | recupdat(upcrec,upirec); |
|---|
| 1352 | } |
|---|
| 1353 | } |
|---|
| 1354 | if (parmtrace) printf("+++ %s = %"_LD_" entries\n",usedbn,nused); |
|---|
| 1355 | dbxflush(usedbn); |
|---|
| 1356 | } |
|---|
| 1357 | } |
|---|
| 1358 | } |
|---|
| 1359 | |
|---|
| 1360 | exit(rc); |
|---|
| 1361 | } |
|---|
| 1362 | |
|---|
| 1363 | |
|---|
| 1364 | /* ========================== mp_scan/mp_edit ============================= */ |
|---|
| 1365 | #if PROC |
|---|
| 1366 | |
|---|
| 1367 | void mp_scan(gidbnp,specp) |
|---|
| 1368 | char *gidbnp; |
|---|
| 1369 | char *specp; |
|---|
| 1370 | { |
|---|
| 1371 | |
|---|
| 1372 | if (mp_n >= MAXNPPP) fatal("MAXNPPP"); |
|---|
| 1373 | |
|---|
| 1374 | mp_areap=loadfile(gidbnp,'@',specp,mp_areap,fmtasize+1,'\0'); |
|---|
| 1375 | if (!mp_areap) fatal(specp); |
|---|
| 1376 | |
|---|
| 1377 | if (parmtrace) { |
|---|
| 1378 | printf("+++ proc=%c",OPENFCHR); printf("%s",mp_areap); |
|---|
| 1379 | printf("%c ..",CLOSFCHR); if (getchar() != '\n') mxexit(0); |
|---|
| 1380 | } |
|---|
| 1381 | |
|---|
| 1382 | if (fmt_gener(&mp_pgmp[mp_n],mp_areap)) fatal(specp+fmt_errof); |
|---|
| 1383 | |
|---|
| 1384 | mp_n++; |
|---|
| 1385 | } |
|---|
| 1386 | |
|---|
| 1387 | void mp_edit(irec,i1,i2) |
|---|
| 1388 | LONGX irec; |
|---|
| 1389 | int i1; |
|---|
| 1390 | int i2; |
|---|
| 1391 | { |
|---|
| 1392 | int ippp; |
|---|
| 1393 | LONGX lns; |
|---|
| 1394 | UBYTE *p; |
|---|
| 1395 | RECSTRU *recp; |
|---|
| 1396 | #define MXRELPROC 1 |
|---|
| 1397 | #if MXRELPROC |
|---|
| 1398 | UBYTE c; |
|---|
| 1399 | LONGX ld,x,xnocc; |
|---|
| 1400 | UWORD tag1,tag2; |
|---|
| 1401 | #endif |
|---|
| 1402 | |
|---|
| 1403 | recp=vrecp[irec]; |
|---|
| 1404 | |
|---|
| 1405 | for (ippp=i1; ippp <= i2; ippp++) { |
|---|
| 1406 | |
|---|
| 1407 | *mp_areap = '\0'; /* call format */ |
|---|
| 1408 | lns=fmt_inter(mp_pgmp[ippp],irec,fmtasize,mp_areap,fmtasize); |
|---|
| 1409 | |
|---|
| 1410 | if (parmtrace) |
|---|
| 1411 | printf("+++ proc=%"_LD_"=%s.\n",lns,mp_areap); |
|---|
| 1412 | |
|---|
| 1413 | #if MXRELPROC |
|---|
| 1414 | if (mp_areap[0] == '.' && toupper(mp_areap[1]) == 'A') { |
|---|
| 1415 | for (p=mp_areap+2, ld=0; *p; p++) |
|---|
| 1416 | if (isdigit(*p)) ld=10*ld+(int)*p-(int)'0'; |
|---|
| 1417 | else break; |
|---|
| 1418 | tag1=(UWORD)ld; |
|---|
| 1419 | if (!tag1) fatal(mp_areap); |
|---|
| 1420 | c= *p; |
|---|
| 1421 | switch (c) { |
|---|
| 1422 | case '+': |
|---|
| 1423 | case '-': |
|---|
| 1424 | for (p++, ld=0; *p; p++) |
|---|
| 1425 | if (isdigit(*p)) ld=10*ld+(int)*p-(int)'0'; |
|---|
| 1426 | else break; |
|---|
| 1427 | tag2=(UWORD)ld; |
|---|
| 1428 | if (!tag2) fatal(mp_areap); |
|---|
| 1429 | if (*p) fatal(mp_areap); |
|---|
| 1430 | p=mp_areap; |
|---|
| 1431 | sprintf(p,"D%"_LD_,(LONGX)tag1); p+=strlen(p); |
|---|
| 1432 | for (xnocc=nocc(irec,tag2), x=1; x <= xnocc; x++) { |
|---|
| 1433 | sprintf(p,"A%"_LD_"/%"_LD_"/",(LONGX)tag1,(c == '+')?x:xnocc-x+1); |
|---|
| 1434 | p+=strlen(p); |
|---|
| 1435 | } |
|---|
| 1436 | break; |
|---|
| 1437 | default: |
|---|
| 1438 | fatal(mp_areap); |
|---|
| 1439 | } |
|---|
| 1440 | } |
|---|
| 1441 | #endif |
|---|
| 1442 | if ((p=fldupdat(irec,mp_areap)) != NULL) |
|---|
| 1443 | fatal(p); |
|---|
| 1444 | |
|---|
| 1445 | if (parmtrace) |
|---|
| 1446 | prtfields(recp,MFRmfn); |
|---|
| 1447 | } |
|---|
| 1448 | } |
|---|
| 1449 | |
|---|
| 1450 | #endif /* PROC */ |
|---|