From a3fecfc4e984f3f734f5f5481f1b756ad3b93caf Mon Sep 17 00:00:00 2001 From: panikon Date: Mon, 31 Mar 2014 17:26:34 -0300 Subject: 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 --- src/common/console.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 9 deletions(-) (limited to 'src/common/console.c') 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) { -- cgit v1.2.3-70-g09d2