diff options
| author | Marty Connor | 2006-08-09 04:30:35 +0200 |
|---|---|---|
| committer | Marty Connor | 2006-08-09 04:30:35 +0200 |
| commit | 41af7457a8c731ed358f70ae3c78983893ae84ad (patch) | |
| tree | 1049f7efa4a666efb7905e135ce4b0e90393a2fb /src/include | |
| parent | Add a couple of small but vital parts to PXENV_UDP_WRITE. (diff) | |
| download | ipxe-41af7457a8c731ed358f70ae3c78983893ae84ad.tar.gz ipxe-41af7457a8c731ed358f70ae3c78983893ae84ad.tar.xz ipxe-41af7457a8c731ed358f70ae3c78983893ae84ad.zip | |
Merge of Fredrik Hultin command_line
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/cmdline.h | 8 | ||||
| -rw-r--r-- | src/include/cmdlinelib.h | 99 | ||||
| -rw-r--r-- | src/include/cmdlist.h | 16 | ||||
| -rw-r--r-- | src/include/command.h | 15 |
4 files changed, 138 insertions, 0 deletions
diff --git a/src/include/cmdline.h b/src/include/cmdline.h new file mode 100644 index 000000000..9ab29c537 --- /dev/null +++ b/src/include/cmdline.h @@ -0,0 +1,8 @@ +#ifndef CMDLINE_H +#define CMDLINE_H + +/* Command line external functions */ + +void cmdl_start(); + +#endif diff --git a/src/include/cmdlinelib.h b/src/include/cmdlinelib.h new file mode 100644 index 000000000..1eb689940 --- /dev/null +++ b/src/include/cmdlinelib.h @@ -0,0 +1,99 @@ +/* Command line library */ +#ifndef CMDLINELIB_H +#define CMDLINELIB_H + +#define CMDL_BUFFER_SIZE 256 +//#define CMDL_OUTPUT_SIZE 256 +#define CMDL_PROMPT_SIZE 8 +#define CMDL_MAX_TAB_COMPLETE_RESULT 256 + +typedef int (*cmdl_putchar_t)(int); +typedef int (*cmdl_printf_t)( const char *format, ... ); +typedef int (*cmdl_getchar_t)(); + +#ifndef NULL +#define NULL ((void *)0) +#endif + +enum{ + CMDL_LEFT, + CMDL_RIGHT +}; + +enum{ + CMDLK_FW=6, + CMDLK_BW=2, + CMDLK_BS=8, + CMDLK_HOME=2, + CMDLK_END=5, + CMDLK_DELTOEND=11, + CMDLK_DELARG=23, + CMDLK_ENTER=0x0d, + CMDLK_RETURN=0x0a, + CMDLK_TAB=9 +}; + +typedef struct{ + + // buffers + + //char* output; + char* buffer; + char* prompt; + + // options and values + + int cursor; + //int has_output; + int exit; + int refresh; + int tabstate; + int insert; + + // callbacks + + cmdl_putchar_t putchar; + cmdl_getchar_t getchar; + cmdl_printf_t printf; + +}cmd_line; + +typedef struct{ + int argc; + char **argv; +}cmdl_param_list; + +void cmdl_setputchar(cmd_line* cmd, cmdl_putchar_t in); +void cmdl_setgetchar(cmd_line* cmd, cmdl_getchar_t in); +void cmdl_setprintf(cmd_line* cmd, cmdl_printf_t in); + +//void cmdl_builtin_help(cmd_line* cmd, char* command); + +void cmdl_parsechar(cmd_line* cmd, char in); + +void cmdl_addreplace(cmd_line* cmd, char in); +void cmdl_addinsert(cmd_line* cmd, char in); +void cmdl_enterloop(cmd_line* cmd); +void cmdl_exec(cmd_line* cmd); +void cmdl_setexit(cmd_line* cmd, int exit); +int cmdl_getexit(cmd_line* cmd); +void cmdl_clearoutput(cmd_line* cmd); +void cmdl_clearbuffer(cmd_line* cmd); +int cmdl_printf(cmd_line* cmd, const char *format, ...); +char* cmdl_getoutput(cmd_line* cmd); +//void cmdl_addoutput_str(cmd_line* cmd, char output[CMDL_OUTPUT_SIZE]); +void cmdl_addstr(cmd_line* cmd, char* str); +int cmdl_movecursor(cmd_line* cmd, int direction); +char* cmdl_getbuffer(cmd_line* cmd); +void cmdl_addchar(cmd_line* cmd, char in); +int cmdl_check(cmd_line* cmd); +void cmdl_del(cmd_line* cmd); +cmd_line* cmdl_create(); +void cmdl_free(cmd_line* cmd); +char *cmdl_getprompt(cmd_line* cmd); +void cmdl_setpropmt(cmd_line* cmd, char prompt[CMDL_PROMPT_SIZE]); +cmdl_param_list* cmdl_getparams(const char* command); +void cmdl_tabcomplete(cmd_line *cmd); + +#endif + diff --git a/src/include/cmdlist.h b/src/include/cmdlist.h new file mode 100644 index 000000000..623cac765 --- /dev/null +++ b/src/include/cmdlist.h @@ -0,0 +1,16 @@ +#ifndef COMMANDLIST_H +#define COMMANDLIST_H + +void test_req(); +void test2_req(); +void help_req(); + +void commandlist() +{ + test_req(); + test2_req(); + help_req(); +} + +#endif + diff --git a/src/include/command.h b/src/include/command.h new file mode 100644 index 000000000..113ca2f0a --- /dev/null +++ b/src/include/command.h @@ -0,0 +1,15 @@ +#ifndef COMMAND_H +#define COMMAND_H + +#include <gpxe/tables.h> + +struct command { + const char *name; // The name of the command + const char *usage; // Description of how to use the command + const char *desc; // Short description of the command + int ( *exec ) ( int argc, char **argv); // The command function to call +}; + +#define __command __table ( commands, 01 ) +#endif + |
