source: mainline/uspace/app/bdsh/cmds/cmds.h@ ee79df74

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since ee79df74 was d752cf4, checked in by Tim Post <echo@…>, 17 years ago

Eliminate 'restrict' from command structure, get rid of needless aliases.
Order of search is builtin → module → external, there is no need to
restrict commands to (non)interative shells only any longer.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1#ifndef CMDS_H
2#define CMDS_H
3
4#include "config.h"
5#include "scli.h"
6
7/* Temporary to store strings */
8#define EXT_HELP "extended"
9#define SHORT_HELP "short"
10#define TEST_ANNOUNCE "Hello, this is :"
11
12/* Simple levels of help displays */
13#define HELP_SHORT 0
14#define HELP_LONG 1
15
16/* Acceptable buffer sizes (for strn functions) */
17/* TODO: Move me, other files duplicate these needlessly */
18#define BUFF_LARGE 1024
19#define BUFF_SMALL 255
20
21/* Return macros for int type entry points */
22#define CMD_FAILURE 1
23#define CMD_SUCCESS 0
24
25/* Types for module command entry and help */
26typedef int (* mod_entry_t)(char **);
27typedef void (* mod_help_t)(unsigned int);
28
29/* Built-in commands need to be able to modify cliuser_t */
30typedef int (* builtin_entry_t)(char **, cliuser_t *);
31typedef void (* builtin_help_t)(unsigned int);
32
33/* Module structure */
34typedef struct {
35 char *name; /* Name of the command */
36 char *desc; /* Description of the command */
37 mod_entry_t entry; /* Command (exec) entry function */
38 mod_help_t help; /* Command (help) entry function */
39} module_t;
40
41/* Builtin structure, same as modules except different types of entry points */
42typedef struct {
43 char *name;
44 char *desc;
45 builtin_entry_t entry;
46 builtin_help_t help;
47 int restricted;
48} builtin_t;
49
50/* Declared in cmds/modules/modules.h and cmds/builtins/builtins.h
51 * respectively */
52extern module_t modules[];
53extern builtin_t builtins[];
54
55/* Prototypes for module launchers */
56extern int module_is_restricted(int);
57extern int is_module(const char *);
58extern int is_module_alias(const char *);
59extern char * alias_for_module(const char *);
60extern int help_module(int, unsigned int);
61extern int run_module(int, char *[]);
62
63/* Prototypes for builtin launchers */
64extern int builtin_is_restricted(int);
65extern int is_builtin(const char *);
66extern int is_builtin_alias(const char *);
67extern char * alias_for_builtin(const char *);
68extern int help_builtin(int, unsigned int);
69extern int run_builtin(int, char *[], cliuser_t *);
70
71#endif
Note: See TracBrowser for help on using the repository browser.