summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDenis Vlasenko2007-01-22 07:21:38 +0000
committerDenis Vlasenko2007-01-22 07:21:38 +0000
commit8e1c71529c2bf38a04d4a117e625e59044a0785a (patch)
tree2f115293c25e7ee9307f268ec198e2cf486ff070 /include
parent00cdbd8fc20a4e2e2208f90a2691a3806c931b06 (diff)
downloadbusybox-8e1c71529c2bf38a04d4a117e625e59044a0785a.zip
busybox-8e1c71529c2bf38a04d4a117e625e59044a0785a.tar.gz
Convert cmdedit into more generic line input facility
(make history and completion optional at runtime). Use it for fdisk, as an example. Some unrelated fixes in fdisk are also here.
Diffstat (limited to 'include')
-rw-r--r--include/libbb.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 0b066d1..f990b0e 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -583,6 +583,42 @@ extern unsigned long long bb_makedev(unsigned int major, unsigned int minor);
#endif
+#if ENABLE_FEATURE_COMMAND_EDITING
+/* It's NOT just ENABLEd or disabled. It's a number: */
+#ifdef CONFIG_FEATURE_COMMAND_HISTORY
+#define MAX_HISTORY (CONFIG_FEATURE_COMMAND_HISTORY + 0)
+#else
+#define MAX_HISTORY 0
+#endif
+struct line_input_t {
+ int flags;
+ const char *path_lookup;
+#if MAX_HISTORY
+ int cnt_history;
+ int cur_history;
+ USE_FEATURE_COMMAND_SAVEHISTORY(const char *hist_file;)
+ char *history[MAX_HISTORY + 1];
+#endif
+};
+enum {
+ DO_HISTORY = 1 * (MAX_HISTORY > 0),
+ SAVE_HISTORY = 2 * (MAX_HISTORY > 0) * ENABLE_FEATURE_COMMAND_SAVEHISTORY,
+ TAB_COMPLETION = 4 * ENABLE_FEATURE_COMMAND_TAB_COMPLETION,
+ USERNAME_COMPLETION = 8 * ENABLE_FEATURE_COMMAND_USERNAME_COMPLETION,
+ VI_MODE = 0x10 * ENABLE_FEATURE_COMMAND_EDITING_VI,
+ WITH_PATH_LOOKUP = 0x20,
+ FOR_SHELL = DO_HISTORY | SAVE_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
+};
+typedef struct line_input_t line_input_t;
+line_input_t *new_line_input_t(int flags);
+int read_line_input(const char* prompt, char* command, int maxsize, line_input_t *state);
+#else
+int read_line_input(const char* prompt, char* command, int maxsize);
+#define read_line_input(prompt, command, maxsize, state) \
+ read_line_input(prompt, command, maxsize)
+#endif
+
+
#ifndef COMM_LEN
#ifdef TASK_COMM_LEN
enum { COMM_LEN = TASK_COMM_LEN };