1: # include "../ingres.h" 2: # include "../tree.h" 3: # include "../symbol.h" 4: 5: 6: struct proctemplate 7: { 8: char *proc_name; 9: int proc_code; 10: char proc_exec; 11: char proc_func; 12: }; 13: 14: struct proctemplate Proc_template[] = 15: { 16: "copy", mdCOPY, 0, 0, 17: "create", mdCREATE, 0, 0, 18: "destroy", mdDESTROY, 0, 0, 19: "display", mdDISPLAY, 0, 0, 20: "help", mdHELP, 0, 0, 21: "index", mdINDEX, 0, 0, 22: "modify", mdMODIFY, 0, 0, 23: "print", mdPRINT, 0, 0, 24: "save", mdSAVE, 0, 0, 25: "update", mdUPDATE, 0, 0, 26: "resetrel", mdRESETREL, 0, 0, 27: "remqm", mdREMQM, 0, 0, 28: 0 29: }; 30: 31: 32: init_proctab(proc, my_id) 33: char *proc; 34: char my_id; 35: 36: /* 37: ** Initialize from the run time process table 38: ** 39: ** Each entry in the proctable is seached for in the 40: ** runtime process table. If an entry isn't found it 41: ** is considered a syserr. If an entry is found the 42: ** first one which has an exec_id of "my_id" is taken. 43: ** Otherwise, the very first entry given will be used. 44: */ 45: 46: { 47: register struct proctemplate *pt; 48: register char *p, *name; 49: char *found; 50: int i; 51: 52: # ifdef xZTR1 53: if (tTf(0, 0)) 54: printf("INIT_PTAB:\n"); 55: # endif 56: 57: for (pt = Proc_template; name = pt->proc_name; pt++) 58: { 59: i = length(name); 60: p = proc; 61: found = NULL; 62: 63: while (*p) 64: { 65: if (bequal(p, name, i)) 66: { 67: /* found a match. skip past the colon */ 68: while (*p++ != ':') 69: ; 70: 71: /* look for an alias in this dbu */ 72: found = p; 73: do 74: { 75: if (*p == my_id) 76: { 77: found = p; 78: break; /* found one */ 79: } 80: p++; 81: p++; 82: } while (*p++ == ','); 83: 84: # ifdef xZTR1 85: if (tTf(0, 1)) 86: printf("%s: %.2s\n", name, found); 87: # endif 88: 89: pt->proc_exec = *found++; 90: pt->proc_func = *found; 91: break; 92: 93: } 94: 95: /* skip to next */ 96: while (*p++ != '\n'); 97: } 98: 99: if (found == NULL) 100: syserr("init_proctab: %s missing from proctab", name); 101: } 102: } 103: 104: 105: get_proctab(code, exec, func) 106: int code; 107: char *exec; 108: char *func; 109: 110: /* 111: ** Find the correct exec & func for a given code 112: */ 113: 114: { 115: register struct proctemplate *p; 116: register int i; 117: 118: i = code; 119: for (p = Proc_template; p->proc_name != NULL; p++) 120: { 121: if (i == p->proc_code) 122: { 123: /* found entry */ 124: *exec = p->proc_exec; 125: *func = p->proc_func; 126: return; 127: } 128: } 129: 130: /* entry not there */ 131: syserr("get_proc:bad code %d", i); 132: }