| 1 | /* ------------------------------ mxget.c ---------------------------------- */ |
|---|
| 2 | |
|---|
| 3 | #include <stdio.h> |
|---|
| 4 | #include <ctype.h> |
|---|
| 5 | #include <string.h> |
|---|
| 6 | |
|---|
| 7 | #include "cisis.h" /* CISIS Interface header file */ |
|---|
| 8 | #include "cirun.h" /* CISIS Interface runtime declarations */ |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | void mxsyntax(void); |
|---|
| 12 | void mxsyntax() |
|---|
| 13 | { |
|---|
| 14 | printf("%s",cicopyr("Utility MXGET")); |
|---|
| 15 | printf("\n"); |
|---|
| 16 | printf("mxget [cipar=<file>] <fmt_spec> \n"); |
|---|
| 17 | printf("\n"); |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | #define cistderr stderr |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | void main(argc,argv) |
|---|
| 25 | int argc; |
|---|
| 26 | char *argv[]; |
|---|
| 27 | |
|---|
| 28 | { |
|---|
| 29 | RECSTRU *recp; /* mandatory for defines REC RDB MF0 MFR DIR, FIELDP */ |
|---|
| 30 | |
|---|
| 31 | int iarg; |
|---|
| 32 | long rc; |
|---|
| 33 | |
|---|
| 34 | char *cgipfxp="tag"; |
|---|
| 35 | UWORD cgitag=2000; |
|---|
| 36 | |
|---|
| 37 | /* int cicgi0(int *argc, char *argv[], char **wwwp, UWORD taghxsub, char *taghpfxp); */ |
|---|
| 38 | char *wwwp; |
|---|
| 39 | char *xp,*p,*q; |
|---|
| 40 | long wwrec1,wwrec2; |
|---|
| 41 | char *cgispecp; |
|---|
| 42 | |
|---|
| 43 | if (argc < 2) { |
|---|
| 44 | mxsyntax(); |
|---|
| 45 | exit(1); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | RECORD(wwrec1=nrecs,"null",1L); RECrc=RCNORMAL; MFRstatus=ACTIVE; |
|---|
| 49 | RECORD(wwrec2=nrecs,"null",1L); xp=(char *)MFX; /* current */ |
|---|
| 50 | for (iarg=1; iarg < argc; iarg++) { |
|---|
| 51 | |
|---|
| 52 | cgispecp=argv[iarg]; |
|---|
| 53 | wwwp=NULL; cicgi0(NULL, NULL, &wwwp, cgitag, cgipfxp); |
|---|
| 54 | if (!wwwp) wwwp=""; |
|---|
| 55 | sprintf(xp,"D%ld",(long)cgitag); fldupdat(wwrec1,xp); |
|---|
| 56 | p=fldupdat(wwrec1,wwwp); if (p) fatal(p); |
|---|
| 57 | rc=recfmt(wwrec1,RECnbytes,cgispecp,p=xp,RECnbytes); |
|---|
| 58 | if (rc < 0) fatal(cgispecp); |
|---|
| 59 | while (*p) { |
|---|
| 60 | for (q=p; *p; p++) |
|---|
| 61 | if (*p == '\r' || *p == '\n') { |
|---|
| 62 | *p++='\0'; if (*p == '\n') *p++='\0'; break; |
|---|
| 63 | } |
|---|
| 64 | printf("%s\n",q); |
|---|
| 65 | } |
|---|
| 66 | break; |
|---|
| 67 | |
|---|
| 68 | } /* end for */ |
|---|
| 69 | |
|---|
| 70 | exit(0); |
|---|
| 71 | } |
|---|