1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* 3 * Copyright 1987, 1988 by MIT Student Information Processing Board 4 * 5 * For copyright information, see copyright.h. 6 */ 7 8 #include "copyright.h" 9 #include "ss_internal.h" 10 11 #define ssrt ss_request_table /* for some readable code... */ 12 13 void 14 ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr) 15 int sci_idx; 16 ssrt *rqtbl_ptr; 17 int position; /* 1 -> becomes second... */ 18 int *code_ptr; 19 { 20 ss_data *info; 21 int i, size; 22 23 info = ss_info(sci_idx); 24 for (size=0; info->rqt_tables[size] != (ssrt *)NULL; size++) 25 ; 26 /* size == C subscript of NULL == #elements */ 27 size += 2; /* new element, and NULL */ 28 info->rqt_tables = (ssrt **)realloc(info->rqt_tables, 29 size*sizeof(ssrt *)); 30 if (info->rqt_tables == (ssrt **)NULL) { 31 *code_ptr = errno; 32 return; 33 } 34 if (position > size - 2) 35 position = size - 2; 36 37 if (size > 1) 38 for (i = size - 2; i >= position; i--) 39 info->rqt_tables[i+1] = info->rqt_tables[i]; 40 41 info->rqt_tables[position] = rqtbl_ptr; 42 info->rqt_tables[size-1] = (ssrt *)NULL; 43 *code_ptr = 0; 44 } 45 46 void 47 ss_delete_request_table(sci_idx, rqtbl_ptr, code_ptr) 48 int sci_idx; 49 ssrt *rqtbl_ptr; 50 int *code_ptr; 51 { 52 ss_data *info; 53 ssrt **rt1, **rt2; 54 55 *code_ptr = SS_ET_TABLE_NOT_FOUND; 56 info = ss_info(sci_idx); 57 rt1 = info->rqt_tables; 58 for (rt2 = rt1; *rt1; rt1++) { 59 if (*rt1 != rqtbl_ptr) { 60 *rt2++ = *rt1; 61 *code_ptr = 0; 62 } 63 } 64 *rt2 = (ssrt *)NULL; 65 return; 66 } 67