xref: /titanic_50/usr/src/lib/krb5/ss/request_tbl.c (revision dfb96a4f56fb431b915bc67e5d9d5c8d4f4f6679)
1 /*
2  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 /*
9  * Copyright 1987, 1988 by MIT Student Information Processing Board
10  *
11  * For copyright information, see copyright.h.
12  */
13 
14 #include "copyright.h"
15 #include "ss_internal.h"
16 
17 #define ssrt ss_request_table	/* for some readable code... */
18 
19 void
20 ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr)
21 	int sci_idx;
22 	ssrt *rqtbl_ptr;
23 	int position;		/* 1 -> becomes second... */
24 	int *code_ptr;
25 {
26 	register ss_data *info;
27 	register int i, size;
28 
29 	info = ss_info(sci_idx);
30 	for (size=0; info->rqt_tables[size] != (ssrt *)NULL; size++)
31 		;
32 	/* size == C subscript of NULL == #elements */
33 	size += 2;		/* new element, and NULL */
34 	info->rqt_tables = (ssrt **)realloc(info->rqt_tables,
35 					    size*sizeof(ssrt));
36 	if (info->rqt_tables == (ssrt **)NULL) {
37 		*code_ptr = errno;
38 		return;
39 	}
40 	if (position > size - 2)
41 		position = size - 2;
42 
43 	if (size > 1)
44 		for (i = size - 2; i >= position; i--)
45 			info->rqt_tables[i+1] = info->rqt_tables[i];
46 
47 	info->rqt_tables[position] = rqtbl_ptr;
48 	info->rqt_tables[size-1] = (ssrt *)NULL;
49 	*code_ptr = 0;
50 }
51 
52 void
53 ss_delete_request_table(sci_idx, rqtbl_ptr, code_ptr)
54      int sci_idx;
55      ssrt *rqtbl_ptr;
56      int *code_ptr;
57 {
58      register ss_data *info;
59      register ssrt **rt1, **rt2;
60 
61      *code_ptr = SS_ET_TABLE_NOT_FOUND;
62      info = ss_info(sci_idx);
63      rt1 = info->rqt_tables;
64      for (rt2 = rt1; *rt1; rt1++) {
65 	  if (*rt1 != rqtbl_ptr) {
66 	       *rt2++ = *rt1;
67 	       *code_ptr = 0;
68 	  }
69      }
70      *rt2 = (ssrt *)NULL;
71      return;
72 }
73