/** Parses a single line of text into arguments and tries to execute it. * The text can come from the command buffer, a remote client, or stdin. * * \param ptext A single line of text. */ static void COM_ExecuteString(char *ptext) { xcommand_t *cmd; cmdalias_t *a; COM_TokenizeString(ptext); // execute the command line if (COM_Argc() == 0) return; // no tokens // check functions for (cmd = com_commands; cmd; cmd = cmd->next) { if (!stricmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase! { cmd->function(); return; } } // check aliases for (a = com_alias; a; a = a->next) { if (!stricmp(com_argv[0], a->name)) { COM_BufInsertText(a->value); return; } } // check cvars if (!CV_Command() && con_destlines) CONS_Printf("Unknown command '%s'\n", COM_Argv(0)); }
VISIBLE int Cmd_ExecuteString (const char *text, cmd_source_t src) { cbuf_t *old = cbuf_active; cbuf_active = cmd_cbuf; cmd_source = src; COM_TokenizeString (text, cmd_cbuf->args); Cmd_Command (cmd_cbuf->args); cbuf_active = old; return 0; }
/** Parses a single line of text into arguments and tries to execute it. * The text can come from the command buffer, a remote client, or stdin. * * \param ptext A single line of text. */ static void COM_ExecuteString(char *ptext) { xcommand_t *cmd; cmdalias_t *a; static INT32 recursion = 0; // detects recursion and stops it if it goes too far COM_TokenizeString(ptext); // execute the command line if (COM_Argc() == 0) return; // no tokens // check functions for (cmd = com_commands; cmd; cmd = cmd->next) { if (!stricmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase! { recursion = 0; cmd->function(); return; } } // check aliases for (a = com_alias; a; a = a->next) { if (!stricmp(com_argv[0], a->name)) { if (recursion > MAX_ALIAS_RECURSION) { CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n")); recursion = 0; return; } recursion++; COM_BufInsertText(a->value); return; } } recursion = 0; // check cvars // Hurdler: added at Ebola's request ;) // (don't flood the console in software mode with bad gr_xxx command) if (!CV_Command() && con_destlines) CONS_Printf(M_GetText("Unknown command '%s'\n"), COM_Argv(0)); }
/** Parses a single line of text into arguments and tries to execute it. * The text can come from the command buffer, a remote client, or stdin. * * \param ptext A single line of text. */ static void COM_ExecuteString(char *ptext) { xcommand_t *cmd; cmdalias_t *a; COM_TokenizeString(ptext); // execute the command line if (COM_Argc() == 0) return; // no tokens // check functions for (cmd = com_commands; cmd; cmd = cmd->next) { if (!stricmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase! { cmd->function(); return; } } // check aliases for (a = com_alias; a; a = a->next) { if (!stricmp(com_argv[0], a->name)) { COM_BufInsertText(a->value); return; } } // check cvars // Hurdler: added at Ebola's request ;) // (don't flood the console in software mode with bad gr_xxx command) if (!CV_Command() && con_destlines) CONS_Printf(M_GetText("Unknown command '%s'\n"), COM_Argv(0)); }
static void qtv_connectionless_packet (void) { const char *cmd, *str; MSG_BeginReading (net_message); MSG_ReadLong (net_message); // skip the -1 marker str = MSG_ReadString (net_message); COM_TokenizeString (str, qtv_args); cmd_args = qtv_args; cmd = qtv_args->argv[0]->str; if (!strcmp (cmd, "ping")) { qtv_ping (); } else if (!strcmp (cmd, "status")) { qtv_status (); } else if (!strcmp (cmd, "getchallenge")) { Client_NewConnection (); } else if (cmd[0]) { switch (cmd[0]) { default: goto bad_packet; case A2C_PRINT: Sys_Printf ("%s", str + 1); break; case A2A_PING: qtv_ping (); break; } } else { bad_packet: Sys_Printf ("bad connectionless packet from %s:\n%s\n", NET_AdrToString (net_from), str); } }