00001
00002
00003
00012 #ifndef _clish_shell_h
00013 #define _clish_shell_h
00014
00015 #include <stdio.h>
00016 #include <pthread.h>
00017
00018 #include "lub/c_decl.h"
00019 #include "lub/types.h"
00020 #include "lub/argv.h"
00021
00022 #include "tinyrl/tinyrl.h"
00023
00024 #include "view.h"
00025
00026 _BEGIN_C_DECL
00027
00028 typedef struct clish_shell_s clish_shell_t;
00029
00030
00031
00032
00054 typedef bool_t
00055 clish_shell_init_fn_t(
00059 const clish_shell_t *shell
00060 );
00061
00077 typedef void
00078 clish_shell_fini_fn_t(
00082 const clish_shell_t *shell
00083 );
00084
00096 typedef void
00097 clish_shell_cmd_line_fn_t(
00101 const clish_shell_t *instance,
00105 const char *cmd_line
00106 );
00107
00129 typedef bool_t
00130 clish_shell_script_fn_t(
00134 const clish_shell_t *instance,
00138 const char *script
00139 );
00140
00162 typedef bool_t
00163 clish_shell_access_fn_t(
00167 const clish_shell_t *instance,
00173 const char *access
00174 );
00189 typedef bool_t
00190 clish_shell_builtin_fn_t(
00194 const clish_shell_t *instance,
00198 const lub_argv_t *argv
00199 );
00200
00205 typedef struct
00206 {
00207 const char *name;
00210 clish_shell_builtin_fn_t *callback;
00211 } clish_shell_builtin_t;
00212
00218 typedef struct
00219 {
00220 clish_shell_init_fn_t *init_fn;
00221 clish_shell_access_fn_t *access_fn;
00222 clish_shell_cmd_line_fn_t *cmd_line_fn;
00223 clish_shell_script_fn_t *script_fn;
00224 clish_shell_fini_fn_t *fini_fn;
00225 const clish_shell_builtin_t *cmd_list;
00226 } clish_shell_hooks_t;
00227
00228
00229
00230 int
00231 clish_shell_spawn_and_wait(const clish_shell_hooks_t *hooks,
00232 void *cookie);
00248 bool_t
00249 clish_shell_spawn(
00254 pthread_t *pthread,
00260 const pthread_attr_t *attr,
00266 const clish_shell_hooks_t *hooks,
00271 void *cookie
00272 );
00273 bool_t
00274 clish_shell_spawn_from_file(const clish_shell_hooks_t *hooks,
00275 void *cookie,
00276 const char *filename);
00277
00278 clish_shell_t *
00279 clish_shell_new(const clish_shell_hooks_t *hooks,
00280 void *cookie,
00281 FILE *istream);
00282
00283
00284
00285
00286
00287
00288 bool_t
00289 clish_shell_startup(clish_shell_t *instance);
00290 void
00291 clish_shell_delete(clish_shell_t *instance);
00292 clish_view_t *
00293 clish_shell_find_create_view(clish_shell_t *instance,
00294 const char *name,
00295 const char *prompt);
00296 clish_ptype_t *
00297 clish_shell_find_create_ptype(clish_shell_t *instance,
00298 const char *name,
00299 const char *text,
00300 const char *pattern,
00301 clish_ptype_method_e method,
00302 clish_ptype_preprocess_e preprocess);
00303 int
00304 clish_shell_xml_read(clish_shell_t *instance,
00305 const char *filename);
00306 void
00307 clish_shell_help(clish_shell_t *instance,
00308 const char *line);
00309 bool_t
00310 clish_shell_execute(clish_shell_t *instance,
00311 const clish_command_t *cmd,
00312 clish_pargv_t **pargv);
00313 bool_t
00314 clish_shell_readline(clish_shell_t *shell,
00315 const char *prompt,
00316 const clish_command_t **cmd,
00317 clish_pargv_t **pargv);
00318 void
00319 clish_shell_set_context(clish_shell_t *instance,
00320 const char *viewname);
00321 void
00322 clish_shell_dump(clish_shell_t *instance);
00323 void
00324 clish_shell_close(clish_shell_t *instance);
00325
00326
00327
00328 const clish_view_t *
00329 clish_shell__get_view(const clish_shell_t *instance);
00330 const char *
00331 clish_shell__get_viewid(const clish_shell_t *instance);
00332 const char *
00333 clish_shell__get_overview(const clish_shell_t *instance);
00334 tinyrl_t *
00335 clish_shell__get_tinyrl(const clish_shell_t *instance);
00336 void *
00337 clish_shell__get_client_cookie(const clish_shell_t *instance);
00338
00339 _END_C_DECL
00340 #endif
00341