diff options
Diffstat (limited to 'libcli.h')
-rw-r--r-- | libcli.h | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -16,8 +16,6 @@ extern "C" { #define CLI_QUIT -2 #define CLI_ERROR_ARG -3 -#define MAX_HISTORY 256 - #define PRIVILEGE_UNPRIVILEGED 0 #define PRIVILEGE_PRIVILEGED 15 #define MODE_ANY -1 @@ -30,8 +28,15 @@ extern "C" { #define PRINT_FILTERED 0x01 #define PRINT_BUFFERED 0x02 -#define CLI_MAX_LINE_LENGTH 4096 -#define CLI_MAX_LINE_WORDS 128 +#ifndef CLI_MAX_LINE_LENGTH +#define CLI_MAX_LINE_LENGTH 128 +#endif +#ifndef CLI_MAX_LINE_WORDS +#define CLI_MAX_LINE_WORDS 16 +#endif +#ifndef CLI_MAX_HISTORY +#define CLI_MAX_HISTORY 256 +#endif struct cli_def { int completion_callback; @@ -42,7 +47,7 @@ struct cli_def { char *banner; struct unp *users; char *enable_password; - char *history[MAX_HISTORY]; + char *history[CLI_MAX_HISTORY]; char showprompt; char *promptchar; char *hostname; @@ -52,7 +57,6 @@ struct cli_def { int state; struct cli_filter *filters; void (*print_callback)(struct cli_def *cli, const char *string); - FILE *client; /* internal buffers */ void *conn; void *service; @@ -65,6 +69,9 @@ struct cli_def { time_t last_action; int telnet_protocol; void *user_context; + int sockfd; + ssize_t (*read_callback)(struct cli_def *cli, void *buf, size_t count); + ssize_t (*write_callback)(struct cli_def *cli, const void *buf, size_t count); }; struct cli_filter { @@ -113,6 +120,8 @@ void cli_bufprint(struct cli_def *cli, const char *format, ...) __attribute__((f void cli_vabufprint(struct cli_def *cli, const char *format, va_list ap); void cli_error(struct cli_def *cli, const char *format, ...) __attribute__((format (printf, 2, 3))); void cli_print_callback(struct cli_def *cli, void (*callback)(struct cli_def *, const char *)); +void cli_read_callback(struct cli_def *cli, ssize_t (*callback)(struct cli_def *, void *, size_t)); +void cli_write_callback(struct cli_def *cli, ssize_t (*callback)(struct cli_def *, const void *, size_t)); void cli_free_history(struct cli_def *cli); void cli_set_idle_timeout(struct cli_def *cli, unsigned int seconds); void cli_set_idle_timeout_callback(struct cli_def *cli, unsigned int seconds, int (*callback)(struct cli_def *)); |