X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ftools%2Fsysdb%2Finput.h;h=0ba5c0a4dd385169fc439c1fe133b33464f609a8;hb=49b5a4d2e8e4fb1e4f67c2a368d8d2e3e76b765f;hp=00b915beabea13735804bc3c1ebc480630d1aa84;hpb=a2edc622eb8aa5ff956757a846405d7cbd05c646;p=sysdb.git diff --git a/src/tools/sysdb/input.h b/src/tools/sysdb/input.h index 00b915b..0ba5c0a 100644 --- a/src/tools/sysdb/input.h +++ b/src/tools/sysdb/input.h @@ -37,9 +37,37 @@ typedef struct { sdb_strbuf_t *input; size_t tokenizer_pos; size_t query_len; + + bool interactive; + bool eof; } sdb_input_t; -#define SDB_INPUT_INIT { NULL, NULL, 0, 0 } +#define SDB_INPUT_INIT { NULL, NULL, 0, 0, 1, 0 } + +/* + * sysdb_input: + * Input object to be used by the 'sysdb' command line tool. + */ +extern sdb_input_t *sysdb_input; + +/* + * sdb_input_init: + * Initialize the input handler. + */ +int +sdb_input_init(sdb_input_t *input); + +/* + * sdb_input_mainloop: + * Wait for and handle all user and server input until end-of-file is read + * from the user (on the standard input channel). + * + * Returns: + * - 0 on success + * - a negative value else + */ +int +sdb_input_mainloop(void); /* * sdb_input_readline: @@ -53,8 +81,7 @@ typedef struct { * - A negative value in case of an error. */ ssize_t -sdb_input_readline(sdb_input_t *input, char *buf, - int *n_chars, size_t max_chars); +sdb_input_readline(char *buf, size_t *n_chars, size_t max_chars); /* * sdb_input_exec_query: @@ -62,14 +89,7 @@ sdb_input_readline(sdb_input_t *input, char *buf, * server's reply and prints errors or returned data to standard output. */ int -sdb_input_exec_query(sdb_input_t *input); - -/* - * scanner - */ - -void -sdb_input_set(sdb_input_t *new_input); +sdb_input_exec_query(void); #endif /* SYSDB_INPUT_H */