Don't abort on out of memory when creating page cache
[qemu-kvm.git] / include / qemu / readline.h
bloba89fe4a9a9644c5af3ef50b560e1247b95e08cdf
1 #ifndef READLINE_H
2 #define READLINE_H
4 #define READLINE_CMD_BUF_SIZE 4095
5 #define READLINE_MAX_CMDS 64
6 #define READLINE_MAX_COMPLETIONS 256
8 typedef void ReadLinePrintfFunc(void *opaque, const char *fmt, ...);
9 typedef void ReadLineFlushFunc(void *opaque);
10 typedef void ReadLineFunc(void *opaque, const char *str,
11 void *readline_opaque);
12 typedef void ReadLineCompletionFunc(void *opaque,
13 const char *cmdline);
15 typedef struct ReadLineState {
16 char cmd_buf[READLINE_CMD_BUF_SIZE + 1];
17 int cmd_buf_index;
18 int cmd_buf_size;
20 char last_cmd_buf[READLINE_CMD_BUF_SIZE + 1];
21 int last_cmd_buf_index;
22 int last_cmd_buf_size;
24 int esc_state;
25 int esc_param;
27 char *history[READLINE_MAX_CMDS];
28 int hist_entry;
30 ReadLineCompletionFunc *completion_finder;
31 char *completions[READLINE_MAX_COMPLETIONS];
32 int nb_completions;
33 int completion_index;
35 ReadLineFunc *readline_func;
36 void *readline_opaque;
37 int read_password;
38 char prompt[256];
40 ReadLinePrintfFunc *printf_func;
41 ReadLineFlushFunc *flush_func;
42 void *opaque;
43 } ReadLineState;
45 void readline_add_completion(ReadLineState *rs, const char *str);
46 void readline_set_completion_index(ReadLineState *rs, int completion_index);
48 const char *readline_get_history(ReadLineState *rs, unsigned int index);
50 void readline_handle_byte(ReadLineState *rs, int ch);
52 void readline_start(ReadLineState *rs, const char *prompt, int read_password,
53 ReadLineFunc *readline_func, void *readline_opaque);
54 void readline_restart(ReadLineState *rs);
55 void readline_show_prompt(ReadLineState *rs);
57 ReadLineState *readline_init(ReadLinePrintfFunc *printf_func,
58 ReadLineFlushFunc *flush_func,
59 void *opaque,
60 ReadLineCompletionFunc *completion_finder);
62 #endif /* !READLINE_H */