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