Index: include/asterisk/cli.h =================================================================== --- include/asterisk/cli.h (revision 94167) +++ include/asterisk/cli.h (working copy) @@ -32,6 +32,8 @@ void ast_cli(int fd, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +extern char ast_config_alternate_cli; + #define RESULT_SUCCESS 0 #define RESULT_SHOWUSAGE 1 #define RESULT_FAILURE 2 Index: main/asterisk.c =================================================================== --- main/asterisk.c (revision 94167) +++ main/asterisk.c (working copy) @@ -194,6 +194,7 @@ struct console consoles[AST_MAX_CONNECTS]; +char ast_config_alternate_cli = 0; char defaultlanguage[MAX_LANGUAGE] = DEFAULT_LANGUAGE; static int ast_el_add_history(char *); @@ -408,6 +409,7 @@ ast_cli(a->fd, " Web Manager (AMI/HTTP): %s\n", check_webmanager_enabled() ? "Enabled" : "Disabled"); ast_cli(a->fd, " Call data records: %s\n", check_cdr_enabled() ? "Enabled" : "Disabled"); ast_cli(a->fd, " Realtime Architecture (ARA): %s\n", ast_realtime_enabled() ? "Enabled" : "Disabled"); + ast_cli(a->fd, " Alternate CLI syntax: %s\n", ast_config_alternate_cli ? "Enabled" : "Disabled"); /*! \todo we could check musiconhold, voicemail, smdi, adsi, queues */ @@ -2437,6 +2439,7 @@ _SETVAR(ast_config_AST_PID, DEFAULT_PID); _SETVAR(ast_config_AST_SOCKET, DEFAULT_SOCKET); _SETVAR(ast_config_AST_RUN_DIR, DEFAULT_RUN_DIR); + ast_config_alternate_cli = 0; /* no asterisk.conf? no problem, use buildtime config! */ if (!cfg) { @@ -2603,6 +2606,8 @@ option_minmemfree = 0; } #endif + } else if (!strcasecmp(v->name, "alternatecli")) { + ast_config_alternate_cli = ast_true(v->value); } } ast_config_destroy(cfg); Index: main/cli.c =================================================================== --- main/cli.c (revision 94167) +++ main/cli.c (working copy) @@ -1438,6 +1438,23 @@ /* XXX check that usage and command are filled up */ s = ast_skip_blanks(e->command); s = e->command = ast_strdup(s); + + /* Reverse the first and second words */ + if (ast_config_alternate_cli) { + char *tmp = ast_strdupa(e->command); + char *pieces[3] = { tmp, }; + if ((pieces[1] = strchr(tmp, ' '))) { + *pieces[1] = '\0'; + pieces[1]++; + if ((pieces[2] = strchr(pieces[1], ' '))) { + *pieces[2] = '\0'; + pieces[2]++; + snprintf(e->command, strlen(e->command) + 1, "%s %s %s", pieces[1], pieces[0], pieces[2]); + fprintf(stderr, "Changing command to '%s'\n", e->command); + } + } + } + for (i=0; !ast_strlen_zero(s) && i < AST_MAX_CMD_LEN-1; i++) { *dst++ = s; /* store string */ s = ast_skip_nonblanks(s);