Merge branch 'cmd' into dev

Conflicts:
	include/ucore/atomic.h
	include/ucore/dstr.h
This commit is contained in:
Nils O. Selåsdal
2014-12-07 15:46:06 +01:00
2 changed files with 102 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
#ifndef UC_CMD_H_
#define UC_CMD_H_
#include <stdint.h>
enum UCCmdResult {
UC_CMDRES_OK,
UC_CMDRES_WARN,
UC_CMDRES_ERR
};
struct UCCmdDef;
struct UCVTerm;
typedef enum UCCmdResult (*uc_cmd_handler)(struct UCCmd *cmd, struct UCVTerm *term, int arg, char *argv[]);
struct UCCmdDef {
uint32_t cmd_id;
uint32_t cmd_flags;
const char *cmd_syntax;
const char *cmd_desc;
uc_cmd_handler cmd_cb;
};
#define UC_DEF_CMD_DEF(id, flags, syntax, desc)\
static const struct UCCmdDef uc_cmd_def ## cmd_id {\
.cmd_id = cmd_id,\
.cmd_flags = flags,\
.cmd_syntax = syntax,\
.cmd_desc = desc,\
};
#define UC_DEF_CMD_FUNC(id)\
static enum UCCmdResult uc_cmd_func_ ## id (struct UCCmd *cmd, struct UCVTerm *term, int nargs, char *args[])
#define UC_DEF_CMD(id, flags, syntax, desc)\
UC_DEF_CMD_DEF(id, flags, syntax, desc)\
UC_DEF_CMD_FUNC(id)
UC_DEF_CMD(111, 0 ,
"show peers",
"Show all connected peers")
{
}
#endif
/