10Sstevel@tonic-gate /*
2*2881Smp153739 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3*2881Smp153739 * Use is subject to license terms.
40Sstevel@tonic-gate */
50Sstevel@tonic-gate
60Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
70Sstevel@tonic-gate
80Sstevel@tonic-gate /*
90Sstevel@tonic-gate * Copyright 1987, 1988 by MIT Student Information Processing Board
100Sstevel@tonic-gate *
110Sstevel@tonic-gate * For copyright information, see copyright.h.
120Sstevel@tonic-gate */
130Sstevel@tonic-gate
140Sstevel@tonic-gate #include "copyright.h"
150Sstevel@tonic-gate #include "ss_internal.h"
160Sstevel@tonic-gate
170Sstevel@tonic-gate #define ssrt ss_request_table /* for some readable code... */
180Sstevel@tonic-gate
190Sstevel@tonic-gate void
ss_add_request_table(sci_idx,rqtbl_ptr,position,code_ptr)200Sstevel@tonic-gate ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr)
210Sstevel@tonic-gate int sci_idx;
220Sstevel@tonic-gate ssrt *rqtbl_ptr;
230Sstevel@tonic-gate int position; /* 1 -> becomes second... */
240Sstevel@tonic-gate int *code_ptr;
250Sstevel@tonic-gate {
260Sstevel@tonic-gate register ss_data *info;
270Sstevel@tonic-gate register int i, size;
280Sstevel@tonic-gate
290Sstevel@tonic-gate info = ss_info(sci_idx);
300Sstevel@tonic-gate for (size=0; info->rqt_tables[size] != (ssrt *)NULL; size++)
310Sstevel@tonic-gate ;
320Sstevel@tonic-gate /* size == C subscript of NULL == #elements */
330Sstevel@tonic-gate size += 2; /* new element, and NULL */
34*2881Smp153739 info->rqt_tables = (ssrt **)realloc(info->rqt_tables,
35*2881Smp153739 size*sizeof(ssrt));
360Sstevel@tonic-gate if (info->rqt_tables == (ssrt **)NULL) {
370Sstevel@tonic-gate *code_ptr = errno;
380Sstevel@tonic-gate return;
390Sstevel@tonic-gate }
400Sstevel@tonic-gate if (position > size - 2)
410Sstevel@tonic-gate position = size - 2;
420Sstevel@tonic-gate
430Sstevel@tonic-gate if (size > 1)
440Sstevel@tonic-gate for (i = size - 2; i >= position; i--)
450Sstevel@tonic-gate info->rqt_tables[i+1] = info->rqt_tables[i];
460Sstevel@tonic-gate
470Sstevel@tonic-gate info->rqt_tables[position] = rqtbl_ptr;
480Sstevel@tonic-gate info->rqt_tables[size-1] = (ssrt *)NULL;
490Sstevel@tonic-gate *code_ptr = 0;
500Sstevel@tonic-gate }
510Sstevel@tonic-gate
520Sstevel@tonic-gate void
ss_delete_request_table(sci_idx,rqtbl_ptr,code_ptr)530Sstevel@tonic-gate ss_delete_request_table(sci_idx, rqtbl_ptr, code_ptr)
540Sstevel@tonic-gate int sci_idx;
550Sstevel@tonic-gate ssrt *rqtbl_ptr;
560Sstevel@tonic-gate int *code_ptr;
570Sstevel@tonic-gate {
580Sstevel@tonic-gate register ss_data *info;
590Sstevel@tonic-gate register ssrt **rt1, **rt2;
600Sstevel@tonic-gate
610Sstevel@tonic-gate *code_ptr = SS_ET_TABLE_NOT_FOUND;
620Sstevel@tonic-gate info = ss_info(sci_idx);
630Sstevel@tonic-gate rt1 = info->rqt_tables;
640Sstevel@tonic-gate for (rt2 = rt1; *rt1; rt1++) {
650Sstevel@tonic-gate if (*rt1 != rqtbl_ptr) {
660Sstevel@tonic-gate *rt2++ = *rt1;
670Sstevel@tonic-gate *code_ptr = 0;
680Sstevel@tonic-gate }
690Sstevel@tonic-gate }
700Sstevel@tonic-gate *rt2 = (ssrt *)NULL;
710Sstevel@tonic-gate return;
720Sstevel@tonic-gate }
73