engine/EngineConsoleCommand.c
/*	Parses the given string into command line tokens.
*/
Parses the given string into command line tokens.
Parses the given string into command line tokens .
void Cmd_TokenizeString (char *text)
{
	int		i;
	for (i=0 ; i<cmd_argc ; i++)
		free(cmd_argv[i]);
	cmd_argc = 0;
	cmd_args = NULL;
	for(;;)
	{
		while(*text && *text <= ' ' && *text != '\n')
		{
			text++;
		}
		if (*text == '\n')
		{
			text++;
			break;
		}
		if(!*text)
			return;
		if (cmd_argc == 1)
			 cmd_args = text;
		text = COM_Parse(text);
		if (!text)
			return;
		if (cmd_argc < MAX_ARGS)
		{
			cmd_argv[cmd_argc] = (char*)malloc_or_die(strlen(com_token) + 1);
			strcpy(cmd_argv[cmd_argc], com_token);
			cmd_argc++;
		}
	}
}
void Cmd_TokenizeString ( char * text ) { int i ; for ( i = 0 ; i < cmd_argc ; i ++ ) free ( cmd_argv [ i ] ) ; cmd_argc = 0 ; cmd_args = NULL ; for ( ; ; ) { while ( * text && * text <= ' ' && * text != ' \n ' ) { text ++ ; } if ( * text == ' \n ' ) { text ++ ; break ; } if ( ! * text ) return ; if ( cmd_argc == 1 ) cmd_args = text ; text = COM_Parse ( text ) ; if ( ! text ) return ; if ( cmd_argc < MAX_ARGS ) { cmd_argv [ cmd_argc ] = ( char * ) malloc_or_die ( strlen ( com_token ) + 1 ) ; strcpy ( cmd_argv [ cmd_argc ] , com_token ) ; cmd_argc ++ ; } } }
Parses the given string into command line tokens.
Parses the given string into command line tokens .
// clear the args from the last string // skip whitespace up to a /n // a newline seperates commands in the buffer