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(int sci_idx, ssrt *rqtbl_ptr, int position, int *code_ptr) 15 { 16 ss_data *info; 17 int i, size; 18 19 info = ss_info(sci_idx); 20 for (size=0; info->rqt_tables[size] != (ssrt *)NULL; size++) 21 ; 22 /* size == C subscript of NULL == #elements */ 23 size += 2; /* new element, and NULL */ 24 info->rqt_tables = (ssrt **)realloc(info->rqt_tables, 25 size*sizeof(ssrt *)); 26 if (info->rqt_tables == (ssrt **)NULL) { 27 *code_ptr = errno; 28 return; 29 } 30 if (position > size - 2) 31 position = size - 2; 32 33 if (size > 1) 34 for (i = size - 2; i >= position; i--) 35 info->rqt_tables[i+1] = info->rqt_tables[i]; 36 37 info->rqt_tables[position] = rqtbl_ptr; 38 info->rqt_tables[size-1] = (ssrt *)NULL; 39 *code_ptr = 0; 40 } 41 42 void 43 ss_delete_request_table(int sci_idx, ssrt *rqtbl_ptr, int *code_ptr) 44 { 45 ss_data *info; 46 ssrt **rt1, **rt2; 47 48 *code_ptr = SS_ET_TABLE_NOT_FOUND; 49 info = ss_info(sci_idx); 50 rt1 = info->rqt_tables; 51 for (rt2 = rt1; *rt1; rt1++) { 52 if (*rt1 != rqtbl_ptr) { 53 *rt2++ = *rt1; 54 *code_ptr = 0; 55 } 56 } 57 *rt2 = (ssrt *)NULL; 58 return; 59 } 60