]>
git.ipfire.org Git - thirdparty/e2fsprogs.git/blob - lib/ss/invocation.c
2 * Copyright 1987, 1988 by MIT Student Information Processing Board
4 * Permission to use, copy, modify, and distribute this software and
5 * its documentation for any purpose is hereby granted, provided that
6 * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
7 * advertising or publicity pertaining to distribution of the software
8 * without specific, written prior permission. M.I.T. and the
9 * M.I.T. S.I.P.B. make no representations about the suitability of
10 * this software for any purpose. It is provided "as is" without
11 * express or implied warranty.
17 #include "ss_internal.h"
18 #define size sizeof(ss_data *)
23 int ss_create_invocation(subsystem_name
, version_string
, info_ptr
,
24 request_table_ptr
, code_ptr
)
25 const char *subsystem_name
, *version_string
;
27 ss_request_table
*request_table_ptr
;
31 register ss_data
*new_table
;
32 register ss_data
**table
;
37 new_table
= (ss_data
*) malloc(sizeof(ss_data
));
39 if (table
== (ss_data
**) NULL
) {
40 table
= (ss_data
**) malloc(2 * size
);
41 table
[0] = table
[1] = (ss_data
*)NULL
;
43 initialize_ss_error_table ();
45 for (sci_idx
= 1; table
[sci_idx
] != (ss_data
*)NULL
; sci_idx
++)
47 table
= (ss_data
**) realloc((char *)table
,
48 ((unsigned)sci_idx
+2)*size
);
49 table
[sci_idx
+1] = (ss_data
*) NULL
;
50 table
[sci_idx
] = new_table
;
52 new_table
->subsystem_name
= subsystem_name
;
53 new_table
->subsystem_version
= version_string
;
54 new_table
->argv
= (char **)NULL
;
55 new_table
->current_request
= (char *)NULL
;
56 new_table
->info_dirs
= (char **)malloc(sizeof(char *));
57 *new_table
->info_dirs
= (char *)NULL
;
58 new_table
->info_ptr
= info_ptr
;
59 new_table
->prompt
= malloc((unsigned)strlen(subsystem_name
)+4);
60 strcpy(new_table
->prompt
, subsystem_name
);
61 strcat(new_table
->prompt
, ": ");
63 new_table
->abbrev_info
= ss_abbrev_initialize("/etc/passwd", code_ptr
);
65 new_table
->abbrev_info
= NULL
;
67 new_table
->flags
.escape_disabled
= 0;
68 new_table
->flags
.abbrevs_disabled
= 0;
69 new_table
->rqt_tables
=
70 (ss_request_table
**) calloc(2, sizeof(ss_request_table
*));
71 *(new_table
->rqt_tables
) = request_table_ptr
;
72 *(new_table
->rqt_tables
+1) = (ss_request_table
*) NULL
;
74 new_table
->readline_handle
= 0;
75 new_table
->readline
= 0;
76 new_table
->add_history
= 0;
77 new_table
->redisplay
= 0;
78 new_table
->rl_completion_matches
= 0;
80 #if defined(HAVE_DLOPEN) && defined(SHARED_ELF_LIB)
81 ss_get_readline(sci_idx
);
87 ss_delete_invocation(sci_idx
)
95 free((char *)t
->rqt_tables
);
96 while(t
->info_dirs
[0] != (char *)NULL
)
97 ss_delete_info_dir(sci_idx
, t
->info_dirs
[0], &ignored_code
);
98 free((char *)t
->info_dirs
);
99 #if defined(HAVE_DLOPEN) && defined(SHARED_ELF_LIB)
100 if (t
->readline_shutdown
)
101 (*t
->readline_shutdown
)(t
);