0
|
1 /*
|
|
2 * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 *
|
|
5 * This code is free software; you can redistribute it and/or modify it
|
|
6 * under the terms of the GNU General Public License version 2 only, as
|
|
7 * published by the Free Software Foundation.
|
|
8 *
|
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 * version 2 for more details (a copy is included in the LICENSE file that
|
|
13 * accompanied this code).
|
|
14 *
|
|
15 * You should have received a copy of the GNU General Public License version
|
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 *
|
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 * have any questions.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 #ifndef SHELL_IMP_H
|
|
26 #define SHELL_IMP_H
|
|
27
|
|
28 #ifdef __cplusplus
|
|
29 extern "C" {
|
|
30 #endif
|
|
31
|
|
32 #include <stdio.h>
|
|
33
|
|
34 /*
|
|
35 CCR info
|
|
36
|
|
37 Vesrion history:
|
|
38
|
|
39 1.0 - Initial CCR release
|
|
40
|
|
41 Release information for automatic CCR updates:
|
|
42
|
|
43 BEGIN RELEASE NOTES: (signifies what gets put into CCR release notes)
|
|
44 1.1
|
|
45 - Entry points for va_list style msgs; new shell_imp_vmsg()
|
|
46 and shell_imp_verrmsg()
|
|
47 - shell_imp_env_checker() is now shell_imp_var_checker().
|
|
48 Also the var_checker callback gets passed interp.
|
|
49 1.2 - interposition framework (used by jdbx)
|
|
50 - access to input FILE pointer.
|
|
51
|
|
52 END RELEASE NOTES: (signifies what gets put into CCR release notes)
|
|
53
|
|
54 Following is used as a CCR version number:
|
|
55 #define CCR_SHELL_IMP_VERSION 1.1
|
|
56 */
|
|
57
|
|
58 #include <stdarg.h>
|
|
59
|
|
60 #define SHELL_IMP_MAJOR 1
|
|
61 #define SHELL_IMP_MINOR 2
|
|
62 #define SHELL_IMP_FLAG_GLOB 0x1
|
|
63 #define SHELL_IMP_FLAG_ARGQ 0x2
|
|
64
|
|
65 typedef void *shell_imp_interp_t;
|
|
66 typedef void *shell_imp_command_t;
|
|
67 typedef int shell_imp_fun_t(shell_imp_interp_t, int, char **, void *);
|
|
68
|
|
69 int
|
|
70 shell_imp_init(
|
|
71 int, /* major version number */
|
|
72 int, /* minor version number */
|
|
73 shell_imp_interp_t, /* interpreter */
|
|
74 int, /* argc */
|
|
75 char *[] /* argv */
|
|
76 );
|
|
77
|
|
78 int
|
|
79 shell_imp_fini(shell_imp_interp_t);
|
|
80
|
|
81 shell_imp_command_t
|
|
82 shell_imp_define_command(char *, /* command name e.g. "tnf" */
|
|
83 shell_imp_fun_t *, /* callback function */
|
|
84 int, /* SHELL_IMP_FLAG_* bit vector */
|
|
85 void *, /* client_data Passed as last arg to
|
|
86 /* callback function */
|
|
87 char * /* help message, e.g. */
|
|
88 /* "enable the specified tnf probes" */
|
|
89 );
|
|
90
|
|
91 int
|
|
92 shell_imp_undefine_command(shell_imp_command_t);
|
|
93
|
|
94 int
|
|
95 shell_imp_var_checker(shell_imp_interp_t,
|
|
96 const char *, /* var name */
|
|
97 int (*)(shell_imp_interp_t, const char*) /* env checker */
|
|
98 );
|
|
99
|
|
100 int
|
|
101 shell_imp_execute(shell_imp_interp_t, const char *);
|
|
102
|
|
103 const char *
|
|
104 shell_imp_get_var(shell_imp_interp_t, const char *);
|
|
105
|
|
106 void
|
|
107 shell_imp_msg(shell_imp_interp_t, const char *, ...);
|
|
108
|
|
109 void
|
|
110 shell_imp_errmsg(shell_imp_interp_t, const char *, ...);
|
|
111
|
|
112 void
|
|
113 shell_imp_vmsg(shell_imp_interp_t, const char *, va_list);
|
|
114
|
|
115 void
|
|
116 shell_imp_verrmsg(shell_imp_interp_t, const char *, va_list);
|
|
117
|
|
118
|
|
119
|
|
120 /*
|
|
121 * Stuff added for 1.2
|
|
122 */
|
|
123
|
|
124 struct shell_imp_interposition_info_t {
|
|
125 shell_imp_fun_t *
|
|
126 new_func;
|
|
127 void * new_client_data;
|
|
128 shell_imp_fun_t *
|
|
129 original_func;
|
|
130 void * original_client_data;
|
|
131 int original_flags;
|
|
132 };
|
|
133
|
|
134 typedef int shell_imp_dispatcher_t(shell_imp_interp_t, int, char **,
|
|
135 shell_imp_interposition_info_t *);
|
|
136
|
|
137 shell_imp_command_t
|
|
138 shell_imp_interpose(char *name,
|
|
139 shell_imp_fun_t *new_func,
|
|
140 int flags,
|
|
141 void *client_data,
|
|
142 char * description,
|
|
143 shell_imp_dispatcher_t *);
|
|
144
|
|
145 int shell_imp_uninterpose(shell_imp_command_t);
|
|
146
|
|
147 int
|
|
148 shell_imp_dispatch_interposition(shell_imp_interp_t,
|
|
149 shell_imp_interposition_info_t *,
|
|
150 int argc, char *argv[]);
|
|
151
|
|
152 int
|
|
153 shell_imp_dispatch_original(shell_imp_interp_t,
|
|
154 shell_imp_interposition_info_t *,
|
|
155 int argc, char *argv[]);
|
|
156
|
|
157 FILE *
|
|
158 shell_imp_cur_input(shell_imp_interp_t);
|
|
159
|
|
160 #ifdef __cplusplus
|
|
161 }
|
|
162 #endif
|
|
163
|
|
164 #endif
|