cmds.h

00001 #ifndef CMDS_H
00002 #define CMDS_H
00003 
00004 #include "config.h"
00005 #include "scli.h"
00006 
00007 /* Temporary to store strings */
00008 #define EXT_HELP      "extended"
00009 #define SHORT_HELP    "short"
00010 #define TEST_ANNOUNCE "Hello, this is :"
00011 
00012 /* Simple levels of help displays */
00013 #define HELP_SHORT 0
00014 #define HELP_LONG  1
00015 
00016 /* Acceptable buffer sizes (for strn functions) */
00017 /* TODO: Move me, other files duplicate these needlessly */
00018 #define BUFF_LARGE  1024
00019 #define BUFF_SMALL  255
00020 
00021 /* Return macros for int type entry points */
00022 #define CMD_FAILURE 1
00023 #define CMD_SUCCESS 0
00024 
00025 /* Types for module command entry and help */
00026 typedef int (* mod_entry_t)(char **);
00027 typedef void (* mod_help_t)(unsigned int);
00028 
00029 /* Built-in commands need to be able to modify cliuser_t */
00030 typedef int (* builtin_entry_t)(char **, cliuser_t *);
00031 typedef void (* builtin_help_t)(unsigned int);
00032 
00033 /* Module structure */
00034 typedef struct {
00035         const char *name;   /* Name of the command */
00036         const char *desc;   /* Description of the command */
00037         mod_entry_t entry;  /* Command (exec) entry function */
00038         mod_help_t help;    /* Command (help) entry function */
00039 } module_t;
00040 
00041 /* Builtin structure, same as modules except different types of entry points */
00042 typedef struct {
00043         const char *name;
00044         const char *desc;
00045         builtin_entry_t entry;
00046         builtin_help_t help;
00047         int restricted;
00048 } builtin_t;
00049 
00050 /* Declared in cmds/modules/modules.h and cmds/builtins/builtins.h
00051  * respectively */
00052 extern module_t modules[];
00053 extern builtin_t builtins[];
00054 
00055 /* Prototypes for module launchers */
00056 extern int module_is_restricted(int);
00057 extern int is_module(const char *);
00058 extern int is_module_alias(const char *);
00059 extern char *alias_for_module(const char *);
00060 extern int help_module(int, unsigned int);
00061 extern int run_module(int, char *[]);
00062 
00063 /* Prototypes for builtin launchers */
00064 extern int builtin_is_restricted(int);
00065 extern int is_builtin(const char *);
00066 extern int is_builtin_alias(const char *);
00067 extern char *alias_for_builtin(const char *);
00068 extern int help_builtin(int, unsigned int);
00069 extern int run_builtin(int, char *[], cliuser_t *);
00070 
00071 #endif

Generated on Thu Jun 2 07:45:40 2011 for HelenOS/USB by  doxygen 1.4.7