123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
-
- #ifndef _clish_shell_h
- #define _clish_shell_h
- #include <stdio.h>
- #include <pthread.h>
- #include "lub/c_decl.h"
- #include "lub/types.h"
- #include "lub/argv.h"
- #include "tinyrl/tinyrl.h"
- #include "view.h"
- #include "konf/net.h"
- #define CLISH_LOCK_PATH "/tmp/clish.lock"
- #define CLISH_LOCK_WAIT 20
- typedef struct clish_context_s clish_context_t;
- typedef struct clish_shell_s clish_shell_t;
- typedef enum {
- SHELL_STATE_INITIALISING,
- SHELL_STATE_READY,
- SHELL_STATE_HELPING,
- SHELL_STATE_SCRIPT_ERROR,
- SHELL_STATE_EOF,
- SHELL_STATE_SYNTAX_ERROR,
- SHELL_STATE_CLOSING
- } clish_shell_state_t;
- _BEGIN_C_DECL
-
- typedef bool_t clish_shell_init_fn_t(
-
- const clish_shell_t * shell);
-
- typedef void clish_shell_fini_fn_t(
-
- const clish_shell_t * shell);
-
- typedef void clish_shell_cmd_line_fn_t(
-
- const clish_shell_t * instance,
-
- const char *cmd_line);
- typedef bool_t clish_shell_script_fn_t(
-
- clish_shell_t * instance,
-
- const clish_command_t * cmd,
-
- const char *script,
- char ** out);
- typedef bool_t clish_shell_config_fn_t(
-
- const clish_shell_t * instance,
-
- const clish_command_t * cmd,
-
- clish_pargv_t * pargv);
-
- typedef bool_t clish_shell_access_fn_t(
-
- const clish_shell_t * instance,
-
- const char *access);
-
- typedef bool_t clish_shell_builtin_fn_t(
-
- const clish_shell_t * instance,
-
- const lub_argv_t * argv);
- typedef struct {
- const char *name;
- clish_shell_builtin_fn_t *callback;
-
- } clish_shell_builtin_t;
- typedef struct {
- clish_shell_init_fn_t *init_fn;
- clish_shell_access_fn_t *access_fn;
- clish_shell_cmd_line_fn_t *cmd_line_fn;
- clish_shell_script_fn_t *script_fn;
- clish_shell_fini_fn_t *fini_fn;
- clish_shell_config_fn_t *config_fn;
- const clish_shell_builtin_t *cmd_list;
- } clish_shell_hooks_t;
- #if 0
- int clish_shell_spawn_and_wait(const clish_shell_hooks_t * hooks, void *cookie);
-
- bool_t clish_shell_spawn(
-
- pthread_t * pthread,
-
- const pthread_attr_t * attr,
-
- const clish_shell_hooks_t * hooks,
-
- void *cookie);
- #endif
- clish_shell_t *clish_shell_new(const clish_shell_hooks_t * hooks,
- void *cookie,
- FILE * istream,
- FILE * ostream,
- bool_t stop_on_error);
- bool_t clish_shell_startup(clish_shell_t * instance);
- void clish_shell_delete(clish_shell_t * instance);
- clish_view_t *clish_shell_find_create_view(clish_shell_t * instance,
- const char *name,
- const char *prompt);
- clish_ptype_t *clish_shell_find_create_ptype(clish_shell_t * instance,
- const char *name,
- const char *text,
- const char *pattern,
- clish_ptype_method_e method,
- clish_ptype_preprocess_e preprocess);
- int clish_shell_xml_read(clish_shell_t * instance, const char *filename);
- void clish_shell_help(clish_shell_t * instance, const char *line);
- bool_t clish_shell_execute(clish_shell_t * instance,
- const clish_command_t * cmd, clish_pargv_t * pargv, char ** out);
- bool_t clish_shell_line(clish_shell_t * instance, const char *prompt,
- const clish_command_t ** cmd, clish_pargv_t ** pargv, const char *str);
- bool_t clish_shell_forceline(clish_shell_t *instance, const char *line, char ** out);
- bool_t clish_shell_readline(clish_shell_t *instance, char ** out);
- void clish_shell_set_context(clish_shell_t * instance, const char *viewname);
- void clish_shell_dump(clish_shell_t * instance);
- void clish_shell_close(clish_shell_t * instance);
- bool_t clish_shell_push_file(clish_shell_t * instance, const char * fname,
- bool_t stop_on_error);
- bool_t clish_shell_push_fd(clish_shell_t * instance, FILE * file,
- bool_t stop_on_error);
- const clish_view_t *clish_shell__get_view(const clish_shell_t * instance);
- unsigned clish_shell__get_depth(const clish_shell_t * instance);
- const char *clish_shell__get_viewid(const clish_shell_t * instance);
- const char *clish_shell__get_overview(const clish_shell_t * instance);
- tinyrl_t *clish_shell__get_tinyrl(const clish_shell_t * instance);
- void *clish_shell__get_client_cookie(const clish_shell_t * instance);
- void
- clish_shell__set_pwd(clish_shell_t * instance, unsigned index,
- const char * line, clish_view_t * view, char * viewid);
- char *clish_shell__get_pwd_line(const clish_shell_t * instance,
- unsigned index);
- char *clish_shell__get_pwd_full(const clish_shell_t * instance, unsigned depth);
- clish_view_t *clish_shell__get_pwd_view(const clish_shell_t * instance,
- unsigned index);
- char *clish_shell__get_pwd_viewid(const clish_shell_t * instance,
- unsigned index);
- char *clish_shell__get_line(const clish_command_t * cmd, clish_pargv_t * pargv);
- konf_client_t *clish_shell__get_client(const clish_shell_t * instance);
- FILE *clish_shell__get_istream(const clish_shell_t * instance);
- FILE *clish_shell__get_ostream(const clish_shell_t * instance);
- void clish_shell__set_lockfile(clish_shell_t * instance, const char * path);
- char * clish_shell__get_lockfile(clish_shell_t * instance);
- int clish_shell__set_socket(clish_shell_t * instance, const char * path);
- int clish_shell_spawn(clish_shell_t * instance,
- const pthread_attr_t * attr);
- int clish_shell_wait(clish_shell_t * instance);
- int clish_shell_spawn_and_wait(clish_shell_t * instance,
- const pthread_attr_t * attr);
- void clish_shell_load_scheme(clish_shell_t * instance, const char * xml_path);
- bool_t clish_shell_loop(clish_shell_t * instance);
- clish_shell_state_t clish_shell__get_state(const clish_shell_t * instance);
- void clish_shell__set_state(clish_shell_t * instance,
- clish_shell_state_t state);
- void clish_shell__set_startup_view(clish_shell_t * instance, const char * viewname);
- void clish_shell__set_startup_viewid(clish_shell_t * instance, const char * viewid);
- void clish_shell__set_default_shebang(clish_shell_t * instance, const char * shebang);
- const char * clish_shell__get_default_shebang(const clish_shell_t * instance);
- char * clish_shell__expand_text(const clish_shell_t *instance,
- clish_command_t *cmd, clish_pargv_t *pargv, const char *text);
- char * clish_shell__expand_variable(const clish_shell_t *instance,
- clish_command_t *cmd, clish_pargv_t *pargv, const char *var);
- const char * clish_shell__get_fifo(clish_shell_t * instance);
- void clish_shell__set_interactive(clish_shell_t * instance, bool_t interactive);
- bool_t clish_shell__get_interactive(const clish_shell_t * instance);
- bool_t clish_shell__get_utf8(const clish_shell_t * instance);
- void clish_shell__set_utf8(clish_shell_t * instance, bool_t utf8);
- _END_C_DECL
- #endif
|