|
|
1.1 ! root 1: # include <stdio.h> ! 2: # include <ingres.h> ! 3: # include <aux.h> ! 4: # include <access.h> ! 5: # include <symbol.h> ! 6: # include <sccs.h> ! 7: ! 8: SCCSID(@(#)printup.c 7.1 2/5/81) ! 9: ! 10: /* ! 11: ** PRINTUP -- print tuple ! 12: ** ! 13: ** Parameters: ! 14: ** d -- a descriptor describing the tuple. ! 15: ** tuple -- the tuple to print. ! 16: ** ! 17: ** Returns: ! 18: ** ?? ! 19: ** ! 20: ** Side Effects: ! 21: ** None. ! 22: */ ! 23: ! 24: # define PAGELGTH 56 ! 25: ! 26: int Printlgth; ! 27: extern struct out_arg Out_arg; ! 28: ! 29: printup(d, tuple) ! 30: DESC *d; ! 31: char *tuple; ! 32: { ! 33: register char *ftype, *flen; ! 34: register short *foff; ! 35: int i, type; ! 36: ! 37: ftype = &d->relfrmt[1]; ! 38: flen = &d->relfrml[1]; ! 39: foff = &d->reloff[1]; ! 40: i = d->reldum.relatts; ! 41: ! 42: /* If relation is S_BINARY then print char fields escaped */ ! 43: if (d->reldum.relstat & S_BINARY) ! 44: { ! 45: while (i--) ! 46: printatt((type = *ftype++) == CHAR ? BINARY : type, *flen++, &tuple[*foff++]); ! 47: } ! 48: else ! 49: { ! 50: while (i--) ! 51: printatt(*ftype++, *flen++, &tuple[*foff++]); ! 52: } ! 53: printeol(); ! 54: } ! 55: ! 56: printatt(type, length, value) ! 57: char type; ! 58: register int length; ! 59: register ANYTYPE *value; ! 60: { ! 61: char buf[MAXFIELD]; ! 62: ANYTYPE valbuf; ! 63: extern char *iocv(); ! 64: register char *p; ! 65: ! 66: putc(Out_arg.coldelim, stdout); ! 67: switch (type) ! 68: { ! 69: case INT: ! 70: switch (length) ! 71: { ! 72: case 1: ! 73: printfatt(Out_arg.i1width, iocv(value->i1type)); ! 74: break; ! 75: ! 76: case 2: ! 77: printfatt(Out_arg.i2width, iocv(value->i2type)); ! 78: break; ! 79: ! 80: case 4: ! 81: printfatt(Out_arg.i4width, locv(value->i4type)); ! 82: break; ! 83: ! 84: default: ! 85: syserr("printatt: i%d", length); ! 86: } ! 87: return (0); ! 88: ! 89: case FLOAT: ! 90: switch (length) ! 91: { ! 92: case 4: ! 93: ftoa(value->f4type, buf, Out_arg.f4width, Out_arg.f4prec, Out_arg.f4style); ! 94: printfatt(Out_arg.f4width, buf); ! 95: break; ! 96: ! 97: case 8: ! 98: ftoa(value->f8type, buf, Out_arg.f8width, Out_arg.f8prec, Out_arg.f8style); ! 99: printfatt(Out_arg.f8width, buf); ! 100: break; ! 101: ! 102: default: ! 103: syserr("printatt: f%d", length); ! 104: } ! 105: return (0); ! 106: ! 107: case CHAR: ! 108: length &= 0377; ! 109: fwrite(value, 1, length, stdout); ! 110: if ((length = Out_arg.c0width - length) > 0) ! 111: while (length--) ! 112: putc(' ', stdout); ! 113: return (0); ! 114: ! 115: case BINARY: ! 116: length &= 0377; ! 117: p = (char *) value; ! 118: while (length--) ! 119: xputchar(*p++); ! 120: return (0); ! 121: ! 122: default: ! 123: syserr("printatt type %d", type); ! 124: } ! 125: } ! 126: /* ! 127: ** FORMATTED ATTRIBUTE PRINT ! 128: ** ! 129: ** Attribute 'value' is printed. It is type 'type' and has a ! 130: ** field width of 'width'. ! 131: */ ! 132: ! 133: printfatt(width, value) ! 134: int width; ! 135: char *value; ! 136: { ! 137: register char *p; ! 138: register int w; ! 139: register int v; ! 140: ! 141: w = width; ! 142: p = value; ! 143: v = length(p); ! 144: ! 145: if (v > w) ! 146: { ! 147: /* field overflow */ ! 148: while (w--) ! 149: putc('*', stdout); ! 150: return; ! 151: } ! 152: ! 153: /* output the field */ ! 154: for (w -= v; w > 0; w--) ! 155: putc(' ', stdout); ! 156: fwrite(p, 1, v, stdout); ! 157: } ! 158: ! 159: ! 160: printeol() ! 161: { ! 162: putc(Out_arg.coldelim, stdout); ! 163: putc('\n', stdout); ! 164: } ! 165: ! 166: printeh() ! 167: { ! 168: register int i; ! 169: ! 170: putc(Out_arg.coldelim, stdout); ! 171: for (i = 1; i < Printlgth; i++) ! 172: putc('-', stdout); ! 173: printeol(); ! 174: } ! 175: ! 176: printhdr(type, length, value) ! 177: char type; ! 178: register int length; ! 179: register char *value; ! 180: { ! 181: register int i; ! 182: char c; ! 183: ! 184: switch (type) ! 185: { ! 186: case INT: ! 187: switch (length) ! 188: { ! 189: case 1: ! 190: length = Out_arg.i1width; ! 191: break; ! 192: ! 193: case 2: ! 194: length = Out_arg.i2width; ! 195: break; ! 196: ! 197: case 4: ! 198: length = Out_arg.i4width; ! 199: break; ! 200: ! 201: default: ! 202: syserr("printhdr: i%d", length); ! 203: } ! 204: break; ! 205: ! 206: case FLOAT: ! 207: switch (length) ! 208: { ! 209: case 4: ! 210: length = Out_arg.f4width; ! 211: break; ! 212: ! 213: case 8: ! 214: length = Out_arg.f8width; ! 215: break; ! 216: ! 217: default: ! 218: syserr("printhdr: f%d", length); ! 219: } ! 220: break; ! 221: ! 222: case CHAR: ! 223: length &= 0377; ! 224: if (length < Out_arg.c0width) ! 225: length = Out_arg.c0width; ! 226: break; ! 227: ! 228: default: ! 229: syserr("printhdr: type 0%o", type); ! 230: } ! 231: ! 232: putc(Out_arg.coldelim, stdout); ! 233: for (i = 0; i < length && i < MAXNAME; i++) ! 234: if (c = *value++) ! 235: putc(c, stdout); ! 236: else ! 237: break; ! 238: ! 239: for ( ; i < length; i++) ! 240: putc(' ', stdout); ! 241: ! 242: Printlgth += length + 1; ! 243: } ! 244: ! 245: beginhdr() ! 246: { ! 247: Printlgth = 0; ! 248: putchar('\n'); ! 249: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.