1: # include <stdio.h> 2: # include <ingres.h> 3: # include <batch.h> 4: # include <opsys.h> 5: # include <version.h> 6: # include <pv.h> 7: # include <symbol.h> 8: # include <sccs.h> 9: 10: SCCSID(@(#)sort.c 8.1 12/31/84) 11: 12: sortfile(infile, d, del) 13: char *infile; 14: register DESC *d; 15: int del; 16: { 17: char out[MAXNAME + 4]; 18: register int j, i; 19: char buf[50]; 20: char *temp; 21: int len; 22: 23: if (del) 24: { 25: concat(DEL_OUT, Fileset, out); 26: if ((Del_outfp = fopen(out, "w")) == NULL) 27: syserr("can't open %s", out); 28: fclose(Del_outfp); 29: } 30: else 31: { 32: concat(REPL_OUT, Fileset, out); 33: if ((Repl_outfp = fopen(out, "w")) == NULL) 34: syserr("can't open %s", out); 35: fclose(Repl_outfp); 36: } 37: 38: flush_rel(d, TRUE); 39: resetacc(NULL); 40: 41: len = length(Fileset) + 1; 42: /* 43: temp = (char *) need(Qbuf, len); 44: */ 45: temp = (char *) calloc(1,len); 46: bmove(Fileset, temp, len); 47: 48: initp(); 49: setp(PV_STR, temp); 50: setp(PV_STR, infile); 51: setp(PV_STR, out); 52: 53: setp(PV_STR, d->reldum.relid); 54: setp(PV_STR, d->reldum.relowner); 55: setp(PV_INT, d->reldum.relspec); 56: setp(PV_INT, d->reldum.relindxd); 57: setp(PV_INT, d->reldum.relstat2); 58: setp(PV_INT, d->reldum.relstat); 59: setp(PV_INT, d->reldum.relsave); 60: setp(PV_INT, d->reldum.reltups); 61: setp(PV_INT, d->reldum.relatts); 62: setp(PV_INT, d->reldum.relwid); 63: setp(PV_INT, d->reldum.relprim); 64: setp(PV_INT, d->reldum.relfree); 65: setp(PV_INT, d->reldum.relstamp); 66: /* whether or not relation is ordered is irrelevant */ 67: setp(PV_INT, 0); 68: 69: setp(PV_STR, d->relvname); 70: setp(PV_INT, d->relfp); 71: setp(PV_INT, d->relopn); 72: setp(PV_INT, d->reladds); 73: setp(PV_INT, d->reltid.ltid); 74: for (i = 0; i <= d->reldum.relatts; ++i) 75: { 76: setp(PV_INT, d->reloff[i]); 77: setp(PV_INT, d->relfrmt[i]); 78: setp(PV_INT, d->relfrml[i]); 79: setp(PV_INT, d->relxtra[i]); 80: setp(PV_INT, d->relgiven[i]); 81: } 82: 83: call(mdKSORT, NULL); 84: 85: flush_rel(d, TRUE); 86: resetacc(NULL); 87: 88: if (del) 89: fclose(Del_outfp); 90: else 91: fclose(Repl_outfp); 92: cfree(temp); 93: }