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
,
15 typedef struct ReadLineState
{
16 char cmd_buf
[READLINE_CMD_BUF_SIZE
+ 1];
20 char last_cmd_buf
[READLINE_CMD_BUF_SIZE
+ 1];
21 int last_cmd_buf_index
;
22 int last_cmd_buf_size
;
27 char *history
[READLINE_MAX_CMDS
];
30 ReadLineCompletionFunc
*completion_finder
;
31 char *completions
[READLINE_MAX_COMPLETIONS
];
35 ReadLineFunc
*readline_func
;
36 void *readline_opaque
;
40 ReadLinePrintfFunc
*printf_func
;
41 ReadLineFlushFunc
*flush_func
;
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
,
60 ReadLineCompletionFunc
*completion_finder
);
62 #endif /* !READLINE_H */