| 1 | /* ---------------------------------------------------------------- GENQLF.C */ |
|---|
| 2 | |
|---|
| 3 | #include "wheredef.h" |
|---|
| 4 | |
|---|
| 5 | #define VERSION_UPDATE 1 |
|---|
| 6 | #define VERSION_UNIX 1 |
|---|
| 7 | |
|---|
| 8 | #include <stdio.h> |
|---|
| 9 | #include <stdlib.h> |
|---|
| 10 | #include <string.h> |
|---|
| 11 | |
|---|
| 12 | #if VERSION_PC |
|---|
| 13 | #include "..\include\cisis.h" |
|---|
| 14 | #include "..\include\cirun.h" |
|---|
| 15 | #include "..\include\ciscr.h" |
|---|
| 16 | #include "..\include\cienv.h" |
|---|
| 17 | #endif |
|---|
| 18 | #if VERSION_HP |
|---|
| 19 | #include "cisis.h" |
|---|
| 20 | #include "cirun.h" |
|---|
| 21 | #include "cienv.h" |
|---|
| 22 | #endif |
|---|
| 23 | #if VERSION_UNIX |
|---|
| 24 | #include <curses.h> |
|---|
| 25 | #include "cisis.h" |
|---|
| 26 | #include "cirun.h" |
|---|
| 27 | #include "globdef.h" |
|---|
| 28 | //#include "ciscr.h" |
|---|
| 29 | #include "cienv.h" |
|---|
| 30 | #endif |
|---|
| 31 | |
|---|
| 32 | #define FILEQLF argv[1] |
|---|
| 33 | #define DBDECSREC argv[2] |
|---|
| 34 | |
|---|
| 35 | char buffup[7001],sup[501]; |
|---|
| 36 | |
|---|
| 37 | void main(argc,argv) |
|---|
| 38 | int argc; |
|---|
| 39 | char *argv[]; |
|---|
| 40 | { |
|---|
| 41 | RECSTRU *recp; |
|---|
| 42 | FILE *f; |
|---|
| 43 | char prevtype[5],type[5],qlf[5]; |
|---|
| 44 | long limit,qtde = 0L,prevmfn,mfn,nd; |
|---|
| 45 | int tag1,tag2,tell,tag = 0,count = 0,nread; |
|---|
| 46 | |
|---|
| 47 | strcpy(prevtype,""); |
|---|
| 48 | strcpy(type," "); |
|---|
| 49 | strcpy(qlf," "); |
|---|
| 50 | if (argc < 7) { |
|---|
| 51 | printf("parms: fileqlf dbdecsrec tag1 tag2 tell limit\n"); |
|---|
| 52 | exit(0); |
|---|
| 53 | } |
|---|
| 54 | tag1 = atoi(argv[3]); |
|---|
| 55 | tag2 = atoi(argv[4]); |
|---|
| 56 | tell = atoi(argv[5]); |
|---|
| 57 | limit = atol(argv[6]); |
|---|
| 58 | |
|---|
| 59 | if ((f = fopen(FILEQLF,"r")) == NULL) fatal(FILEQLF); |
|---|
| 60 | |
|---|
| 61 | record(2L,DBDECSREC,0L); |
|---|
| 62 | if (VRECrc(2L) != RCNORMAL) fatal("genqlf/record"); |
|---|
| 63 | for (prevmfn = 0L; ; ) { |
|---|
| 64 | nread = fscanf(f,"%"_LD_"|%c%c|%c%c%c|%"_LD_"\n", |
|---|
| 65 | &mfn,&type[0],&type[1],&qlf[0],&qlf[1],&qlf[2],&nd); |
|---|
| 66 | |
|---|
| 67 | #if VERSION_UPDATE |
|---|
| 68 | #else |
|---|
| 69 | printf("%6"_LD_"|%s|%s|%10"_LD_"\n",mfn,type,qlf,nd); |
|---|
| 70 | #endif |
|---|
| 71 | if (mfn != prevmfn || strcmp(type,prevtype) != 0 || nread != 7) { |
|---|
| 72 | if (prevmfn) { |
|---|
| 73 | #if VERSION_UPDATE |
|---|
| 74 | RECORD(1L,DBDECSREC,prevmfn); |
|---|
| 75 | if (RECrc != RCNORMAL) { |
|---|
| 76 | printf("n�o encontrado em %s(mfn=%"_LD_").\n",DBDECSREC, |
|---|
| 77 | prevmfn); |
|---|
| 78 | prevmfn = mfn; |
|---|
| 79 | strcpy(prevtype,type); |
|---|
| 80 | continue; |
|---|
| 81 | } |
|---|
| 82 | env_modfld(1L,tag,buffup,0L); |
|---|
| 83 | if (recupdat(2L,1L)) fatal("genqlf/recupdat"); |
|---|
| 84 | #else |
|---|
| 85 | printf("%s",buffup); |
|---|
| 86 | getchar(); |
|---|
| 87 | #endif |
|---|
| 88 | if (mfn != prevmfn) { |
|---|
| 89 | if (++count >= tell) { printf("%"_LD_"\n",prevmfn); count = 0; } |
|---|
| 90 | if (limit) if ((++qtde) >= limit) |
|---|
| 91 | { printf("limite encontrado\n"); break; } |
|---|
| 92 | } |
|---|
| 93 | } |
|---|
| 94 | if (nread != 7) break; |
|---|
| 95 | *buffup = '\0'; |
|---|
| 96 | tag = type[0] != '.' ? tag1 : tag2; |
|---|
| 97 | prevmfn = mfn; |
|---|
| 98 | strcpy(prevtype,type); |
|---|
| 99 | } |
|---|
| 100 | if (strcmp(qlf," ") == 0) strcpy(qlf+1,"TT"); |
|---|
| 101 | sprintf(sup,"^q%-.2s^t%"_LD_,qlf+1,nd); |
|---|
| 102 | strcat(buffup,sup); |
|---|
| 103 | } |
|---|
| 104 | if (nread != EOF) fatal("NOT EOF"); |
|---|
| 105 | fclose(f); |
|---|
| 106 | exit(0); |
|---|
| 107 | } |
|---|