summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorpanikon <panikon@zoho.com>2014-03-31 17:26:34 -0300
committerpanikon <panikon@zoho.com>2014-03-31 17:26:34 -0300
commita3fecfc4e984f3f734f5f5481f1b756ad3b93caf (patch)
treeee1cb32de0492191fdd5353d7d9c09b247544d60 /src/common
parentd9f4084d50057f1103cbdae03dea3b4abddaa209 (diff)
downloadhercules-a3fecfc4e984f3f734f5f5481f1b756ad3b93caf.tar.gz
hercules-a3fecfc4e984f3f734f5f5481f1b756ad3b93caf.tar.bz2
hercules-a3fecfc4e984f3f734f5f5481f1b756ad3b93caf.tar.xz
hercules-a3fecfc4e984f3f734f5f5481f1b756ad3b93caf.zip
Updated documentation for pc_statusup2 and pc_statusup
(fixed issue: 7916 http://hercules.ws/board/tracker/issue-7916-wrong-comment-in-pc-statusup2/) Now pc_statusup2 returns stat increase amount as stated in previous documentation Updated *statusup documentation it was wrong Added last update in upgrade index @console.c/.h Documented partially Now two different parsing categories can have functions with same name e.g. - server exit - sql exit
Diffstat (limited to 'src/common')
-rw-r--r--src/common/console.c83
-rw-r--r--src/common/console.h12
2 files changed, 86 insertions, 9 deletions
diff --git a/src/common/console.c b/src/common/console.c
index 94824dc25..ec228b563 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -82,15 +82,35 @@ int console_parse_key_pressed(void) {
return FD_ISSET(STDIN_FILENO, &fds);
}
#endif /* _WIN32 */
-CPCMD(exit) {
+
+/*======================================
+ * CORE: Console commands
+ *--------------------------------------*/
+
+/**
+ * Stops server
+ **/
+CPCMD_C(exit,server) {
runflag = 0;
}
-CPCMD(ers_report) {
+
+/**
+ * Displays ERS-related statistics (Entry Reusage System)
+ **/
+CPCMD_C(ers_report,server) {
ers_report();
}
-CPCMD(mem_report) {
+
+/**
+ * Displays memory usage
+ **/
+CPCMD_C(mem_report,server) {
memmgr_report(line?atoi(line):0);
}
+
+/**
+ * Displays command list
+ **/
CPCMD(help) {
unsigned int i = 0;
for ( i = 0; i < console->cmd_list_count; i++ ) {
@@ -102,22 +122,61 @@ CPCMD(help) {
}
}
}
-/* [Ind/Hercules] */
-CPCMD(malloc_usage) {
+
+/**
+ * [Ind/Hercules]
+ * Displays current malloc usage
+ */
+CPCMD_C(malloc_usage,server) {
unsigned int val = (unsigned int)iMalloc->usage();
ShowInfo("malloc_usage: %.2f MB\n",(double)(val)/1024);
}
-CPCMD(skip) {
+
+/**
+ * Skips an sql update
+ * Usage: sql update skip UPDATE-FILE.sql
+ **/
+CPCMD_C(skip,update) {
if( !line ) {
ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n");
return;
}
Sql_HerculesUpdateSkip(console->SQL, line);
}
+
+/**
+ * Defines a main category
+ * Categories can't be used as commands!
+ * E.G.
+ * sql update skip
+ * 'sql' is the main category
+ * CP_DEF_C(category)
+ **/
#define CP_DEF_C(x) { #x , NULL , NULL, NULL }
+/**
+ * Defines a sub-category
+ * Sub-categories can't be used as commands!
+ * E.G.
+ * sql update skip
+ * 'update' is a sub-category
+ * CP_DEF_C2(command, category)
+ **/
#define CP_DEF_C2(x,y) { #x , NULL , #y, NULL }
-#define CP_DEF_S(x,y) { #x , console_parse_ ## x , #y, NULL }
-#define CP_DEF(x) { #x , console_parse_ ## x , NULL, NULL }
+/**
+ * Defines a command that is inside a category or sub-category
+ * CP_DEF_S(command, category/sub-category)
+ **/
+#define CP_DEF_S(x,y) { #x, CPCMD_C_A(x,y), #y, NULL }
+/**
+ * Defines a command that is _not_ inside any category
+ * CP_DEF_S(command)
+ **/
+#define CP_DEF(x) { #x , CPCMD_A(x), NULL, NULL }
+
+/**
+ * Loads console commands list
+ * See CP_DEF_C, CP_DEF_C2, CP_DEF_S, CP_DEF
+ **/
void console_load_defaults(void) {
struct {
char *name;
@@ -126,11 +185,17 @@ void console_load_defaults(void) {
struct CParseEntry *self;
} default_list[] = {
CP_DEF(help),
+ /**
+ * Server related commands
+ **/
CP_DEF_C(server),
CP_DEF_S(ers_report,server),
CP_DEF_S(mem_report,server),
CP_DEF_S(malloc_usage,server),
CP_DEF_S(exit,server),
+ /**
+ * Sql related commands
+ **/
CP_DEF_C(sql),
CP_DEF_C2(update,sql),
CP_DEF_S(skip,update),
@@ -305,7 +370,7 @@ void console_parse_sub(char *line) {
cmd = cmd->u.next[i];
len += snprintf(sublist + len,CP_CMD_LENGTH * 5,":%s", cmd->cmd);
}
- ShowError("it is only a category, type '"CL_WHITE"%s help"CL_RESET"' to list its subcommands\n",sublist);
+ ShowError("Is only a category, type '"CL_WHITE"%s help"CL_RESET"' to list its subcommands\n",sublist);
}
}
void console_parse(char* line) {
diff --git a/src/common/console.h b/src/common/console.h
index 513c769ff..bd1de4cbf 100644
--- a/src/common/console.h
+++ b/src/common/console.h
@@ -16,9 +16,21 @@
**/
#define CONSOLE_PARSE_SIZE 10
+/**
+ * Default parsing function abstract prototype
+ **/
typedef void (*CParseFunc)(char *line);
+
+/**
+ * Console parsing function prototypes
+ * CPCMD: Console Parsing CoMmand
+ * x - command
+ * y - category
+ **/
#define CPCMD(x) void console_parse_ ##x (char *line)
#define CPCMD_A(x) console_parse_ ##x
+#define CPCMD_C(x,y) void console_parse_ ##y ##x (char *line)
+#define CPCMD_C_A(x,y) console_parse_ ##y ##x
#define CP_CMD_LENGTH 20
struct CParseEntry {