xref: /titanic_51/usr/src/lib/krb5/ss/invocation.c (revision b3697b90e692e3e5d859fb77d285d4c056d99eda)
1 /*
2  * Copyright 1987, 1988 by MIT Student Information Processing Board
3  *
4  * For copyright information, see copyright.h.
5  */
6 
7 /*
8  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
9  * Use is subject to license terms.
10  */
11 
12 
13 #include "ss_internal.h"
14 #include "copyright.h"
15 #define	size	sizeof(ss_data *)
16 
17 
18 int ss_create_invocation(subsystem_name, version_string, info_ptr,
19 			 request_table_ptr, code_ptr)
20 	char *subsystem_name, *version_string;
21 	char *info_ptr;
22 	ss_request_table *request_table_ptr;
23 	int *code_ptr;
24 {
25 	register int sci_idx;
26 	register ss_data *new_table;
27 	register ss_data **table;
28 
29 	*code_ptr = 0;
30 	table = _ss_table;
31 	new_table = (ss_data *) malloc(sizeof(ss_data));
32 
33 	if (table == (ss_data **) NULL) {
34 		table = (ss_data **) malloc(2 * size);
35 		table[0] = table[1] = (ss_data *)NULL;
36 	}
37 
38 	for (sci_idx = 1; table[sci_idx] != (ss_data *)NULL; sci_idx++)
39 		;
40 	table = (ss_data **) realloc((char *)table,
41 				     ((unsigned)sci_idx+2)*size);
42 	table[sci_idx+1] = (ss_data *) NULL;
43 	table[sci_idx] = new_table;
44 
45 	new_table->subsystem_name = subsystem_name;
46 	new_table->subsystem_version = version_string;
47 	new_table->argv = (char **)NULL;
48 	new_table->current_request = (char *)NULL;
49 	new_table->info_dirs = (char **)malloc(sizeof(char *));
50 	*new_table->info_dirs = (char *)NULL;
51 	new_table->info_ptr = info_ptr;
52 	/* Solaris Kerberos */
53 	new_table->prompt = malloc((unsigned)strlen(subsystem_name)+3);
54 	strcpy(new_table->prompt, subsystem_name);
55 	strcat(new_table->prompt, ": ");
56 #ifdef silly
57 	new_table->abbrev_info = ss_abbrev_initialize("/etc/passwd", code_ptr);
58 #else
59 	new_table->abbrev_info = NULL;
60 #endif
61 	new_table->flags.escape_disabled = 0;
62 	new_table->flags.abbrevs_disabled = 0;
63 	new_table->rqt_tables =
64 		(ss_request_table **) calloc(2, sizeof(ss_request_table *));
65 	*(new_table->rqt_tables) = request_table_ptr;
66 	*(new_table->rqt_tables+1) = (ss_request_table *) NULL;
67 	_ss_table = table;
68 	return(sci_idx);
69 }
70 
71 void
72 ss_delete_invocation(sci_idx)
73 	int sci_idx;
74 {
75 	register ss_data *t;
76 	int ignored_code;
77 
78 	t = ss_info(sci_idx);
79 	free(t->prompt);
80 	free(t->rqt_tables);
81 	while(t->info_dirs[0] != (char *)NULL)
82 		ss_delete_info_dir(sci_idx, t->info_dirs[0], &ignored_code);
83 	free((char *)t->info_dirs);
84 	free((char *)t);
85 }
86