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