17c478bd9Sstevel@tonic-gate /*
2*56a424ccSmp153739 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3*56a424ccSmp153739 * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate */
57c478bd9Sstevel@tonic-gate
67c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
77c478bd9Sstevel@tonic-gate
87c478bd9Sstevel@tonic-gate /*
97c478bd9Sstevel@tonic-gate * Copyright 1987, 1988 by MIT Student Information Processing Board
107c478bd9Sstevel@tonic-gate *
117c478bd9Sstevel@tonic-gate * For copyright information, see copyright.h.
127c478bd9Sstevel@tonic-gate */
137c478bd9Sstevel@tonic-gate
147c478bd9Sstevel@tonic-gate #include "copyright.h"
157c478bd9Sstevel@tonic-gate #include "ss_internal.h"
167c478bd9Sstevel@tonic-gate
177c478bd9Sstevel@tonic-gate #define ssrt ss_request_table /* for some readable code... */
187c478bd9Sstevel@tonic-gate
197c478bd9Sstevel@tonic-gate void
ss_add_request_table(sci_idx,rqtbl_ptr,position,code_ptr)207c478bd9Sstevel@tonic-gate ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr)
217c478bd9Sstevel@tonic-gate int sci_idx;
227c478bd9Sstevel@tonic-gate ssrt *rqtbl_ptr;
237c478bd9Sstevel@tonic-gate int position; /* 1 -> becomes second... */
247c478bd9Sstevel@tonic-gate int *code_ptr;
257c478bd9Sstevel@tonic-gate {
267c478bd9Sstevel@tonic-gate register ss_data *info;
277c478bd9Sstevel@tonic-gate register int i, size;
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate info = ss_info(sci_idx);
307c478bd9Sstevel@tonic-gate for (size=0; info->rqt_tables[size] != (ssrt *)NULL; size++)
317c478bd9Sstevel@tonic-gate ;
327c478bd9Sstevel@tonic-gate /* size == C subscript of NULL == #elements */
337c478bd9Sstevel@tonic-gate size += 2; /* new element, and NULL */
34*56a424ccSmp153739 info->rqt_tables = (ssrt **)realloc(info->rqt_tables,
35*56a424ccSmp153739 size*sizeof(ssrt));
367c478bd9Sstevel@tonic-gate if (info->rqt_tables == (ssrt **)NULL) {
377c478bd9Sstevel@tonic-gate *code_ptr = errno;
387c478bd9Sstevel@tonic-gate return;
397c478bd9Sstevel@tonic-gate }
407c478bd9Sstevel@tonic-gate if (position > size - 2)
417c478bd9Sstevel@tonic-gate position = size - 2;
427c478bd9Sstevel@tonic-gate
437c478bd9Sstevel@tonic-gate if (size > 1)
447c478bd9Sstevel@tonic-gate for (i = size - 2; i >= position; i--)
457c478bd9Sstevel@tonic-gate info->rqt_tables[i+1] = info->rqt_tables[i];
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate info->rqt_tables[position] = rqtbl_ptr;
487c478bd9Sstevel@tonic-gate info->rqt_tables[size-1] = (ssrt *)NULL;
497c478bd9Sstevel@tonic-gate *code_ptr = 0;
507c478bd9Sstevel@tonic-gate }
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate void
ss_delete_request_table(sci_idx,rqtbl_ptr,code_ptr)537c478bd9Sstevel@tonic-gate ss_delete_request_table(sci_idx, rqtbl_ptr, code_ptr)
547c478bd9Sstevel@tonic-gate int sci_idx;
557c478bd9Sstevel@tonic-gate ssrt *rqtbl_ptr;
567c478bd9Sstevel@tonic-gate int *code_ptr;
577c478bd9Sstevel@tonic-gate {
587c478bd9Sstevel@tonic-gate register ss_data *info;
597c478bd9Sstevel@tonic-gate register ssrt **rt1, **rt2;
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate *code_ptr = SS_ET_TABLE_NOT_FOUND;
627c478bd9Sstevel@tonic-gate info = ss_info(sci_idx);
637c478bd9Sstevel@tonic-gate rt1 = info->rqt_tables;
647c478bd9Sstevel@tonic-gate for (rt2 = rt1; *rt1; rt1++) {
657c478bd9Sstevel@tonic-gate if (*rt1 != rqtbl_ptr) {
667c478bd9Sstevel@tonic-gate *rt2++ = *rt1;
677c478bd9Sstevel@tonic-gate *code_ptr = 0;
687c478bd9Sstevel@tonic-gate }
697c478bd9Sstevel@tonic-gate }
707c478bd9Sstevel@tonic-gate *rt2 = (ssrt *)NULL;
717c478bd9Sstevel@tonic-gate return;
727c478bd9Sstevel@tonic-gate }
73