summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-22 07:21:38 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-22 07:21:38 +0000
commit8e1c71529c2bf38a04d4a117e625e59044a0785a (patch)
tree2f115293c25e7ee9307f268ec198e2cf486ff070 /include
parent00cdbd8fc20a4e2e2208f90a2691a3806c931b06 (diff)
downloadbusybox-w32-8e1c71529c2bf38a04d4a117e625e59044a0785a.tar.gz
busybox-w32-8e1c71529c2bf38a04d4a117e625e59044a0785a.tar.bz2
busybox-w32-8e1c71529c2bf38a04d4a117e625e59044a0785a.zip
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 0b066d1bd..f990b0ebd 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);
583#endif 583#endif
584 584
585 585
586#if ENABLE_FEATURE_COMMAND_EDITING
587/* It's NOT just ENABLEd or disabled. It's a number: */
588#ifdef CONFIG_FEATURE_COMMAND_HISTORY
589#define MAX_HISTORY (CONFIG_FEATURE_COMMAND_HISTORY + 0)
590#else
591#define MAX_HISTORY 0
592#endif
593struct line_input_t {
594 int flags;
595 const char *path_lookup;
596#if MAX_HISTORY
597 int cnt_history;
598 int cur_history;
599 USE_FEATURE_COMMAND_SAVEHISTORY(const char *hist_file;)
600 char *history[MAX_HISTORY + 1];
601#endif
602};
603enum {
604 DO_HISTORY = 1 * (MAX_HISTORY > 0),
605 SAVE_HISTORY = 2 * (MAX_HISTORY > 0) * ENABLE_FEATURE_COMMAND_SAVEHISTORY,
606 TAB_COMPLETION = 4 * ENABLE_FEATURE_COMMAND_TAB_COMPLETION,
607 USERNAME_COMPLETION = 8 * ENABLE_FEATURE_COMMAND_USERNAME_COMPLETION,
608 VI_MODE = 0x10 * ENABLE_FEATURE_COMMAND_EDITING_VI,
609 WITH_PATH_LOOKUP = 0x20,
610 FOR_SHELL = DO_HISTORY | SAVE_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
611};
612typedef struct line_input_t line_input_t;
613line_input_t *new_line_input_t(int flags);
614int read_line_input(const char* prompt, char* command, int maxsize, line_input_t *state);
615#else
616int read_line_input(const char* prompt, char* command, int maxsize);
617#define read_line_input(prompt, command, maxsize, state) \
618 read_line_input(prompt, command, maxsize)
619#endif
620
621
586#ifndef COMM_LEN 622#ifndef COMM_LEN
587#ifdef TASK_COMM_LEN 623#ifdef TASK_COMM_LEN
588enum { COMM_LEN = TASK_COMM_LEN }; 624enum { COMM_LEN = TASK_COMM_LEN };