aboutsummaryrefslogtreecommitdiff
path: root/src/trinitycore
diff options
context:
space:
mode:
authormaximius <none@none>2009-08-15 19:16:47 -0700
committermaximius <none@none>2009-08-15 19:16:47 -0700
commit53bc13fad8b7ad0caed27bf545365765b2f68f76 (patch)
tree76e9304217128c21f3aea179def6b66147bb10d5 /src/trinitycore
parente5813517947e5af7ecc5fbef7516a8252f458f52 (diff)
*Cleanup
--HG-- branch : trunk
Diffstat (limited to 'src/trinitycore')
-rw-r--r--src/trinitycore/CliRunnable.cpp105
1 files changed, 52 insertions, 53 deletions
diff --git a/src/trinitycore/CliRunnable.cpp b/src/trinitycore/CliRunnable.cpp
index fb7276548ce..ab006e3d046 100644
--- a/src/trinitycore/CliRunnable.cpp
+++ b/src/trinitycore/CliRunnable.cpp
@@ -44,48 +44,47 @@
char * command_finder(const char* text, int state)
{
- static int idx,len;
- const char* ret;
- ChatCommand *cmd = ChatHandler::getCommandTable();
+ static int idx,len;
+ const char* ret;
+ ChatCommand *cmd = ChatHandler::getCommandTable();
- if(!state)
- {
- idx = 0;
- len = strlen(text);
- }
+ if(!state)
+ {
+ idx = 0;
+ len = strlen(text);
+ }
- while(ret = cmd[idx].Name)
- {
- if(!cmd[idx].AllowConsole)
- {
- idx++;
- continue;
- }
+ while(ret = cmd[idx].Name)
+ {
+ if(!cmd[idx].AllowConsole)
+ {
+ idx++;
+ continue;
+ }
- idx++;
- //printf("Checking %s \n", cmd[idx].Name);
- if (strncmp(ret, text, len) == 0)
- return strdup(ret);
- if(cmd[idx].Name == NULL)
- break;
- }
+ idx++;
+ //printf("Checking %s \n", cmd[idx].Name);
+ if (strncmp(ret, text, len) == 0)
+ return strdup(ret);
+ if(cmd[idx].Name == NULL)
+ break;
+ }
- return ((char*)NULL);
+ return ((char*)NULL);
}
char ** cli_completion(const char * text, int start, int end)
{
- char ** matches;
- matches = (char**)NULL;
+ char ** matches;
+ matches = (char**)NULL;
- if(start == 0)
- matches = rl_completion_matches((char*)text,&command_finder);
- else
- rl_bind_key('\t',rl_abort);
- return (matches);
+ if(start == 0)
+ matches = rl_completion_matches((char*)text,&command_finder);
+ else
+ rl_bind_key('\t',rl_abort);
+ return (matches);
}
-
#endif
void utf8print(const char* str)
@@ -395,45 +394,45 @@ void CliRunnable::run()
char *command_str ; // = fgets(commandbuf,sizeof(commandbuf),stdin);
- #if PLATFORM == WINDOWS
- command_str = fgets(commandbuf,sizeof(commandbuf),stdin);
- #else
- command_str = readline("TC>");
- rl_bind_key('\t',rl_complete);
- #endif
- if (command_str != NULL)
+ #if PLATFORM == WINDOWS
+ command_str = fgets(commandbuf,sizeof(commandbuf),stdin);
+ #else
+ command_str = readline("TC>");
+ rl_bind_key('\t',rl_complete);
+ #endif
+ if (command_str != NULL)
{
for(int x=0;command_str[x];x++)
if(command_str[x]=='\r'||command_str[x]=='\n')
- {
- command_str[x]=0;
- break;
- }
+ {
+ command_str[x]=0;
+ break;
+ }
if(!*command_str)
{
- #if PLATFORM == WINDOWS
- printf("TC>");
- #endif
+ #if PLATFORM == WINDOWS
+ printf("TC>");
+ #endif
continue;
}
std::string command;
if(!consoleToUtf8(command_str,command)) // convert from console encoding to utf8
{
- #if PLATFORM == WINDOWS
- printf("TC>");
- #endif
+ #if PLATFORM == WINDOWS
+ printf("TC>");
+ #endif
continue;
}
- fflush(stdout);
+ fflush(stdout);
sWorld.QueueCliCommand(&utf8print,command.c_str());
- #if PLATFORM != WINDOWS
- add_history(command.c_str());
- #endif
+ #if PLATFORM != WINDOWS
+ add_history(command.c_str());
+ #endif
- }
+ }
else if (feof(stdin))
{
World::StopNow(SHUTDOWN_EXIT_CODE);