/**
@section LICENSE
Copyright (C) 1996-1997 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

/*
Any number of commands can be added in a frame, from several different sources.
Most commands come from either keybindings or console line input, but remote
servers can also send across commands and entire text files can be execed.

The + command line options are also added to the command buffer.

The game starts with a Cbuf_AddText ("exec quake.rc\n"); Cbuf_Execute ();
*/


void Cbuf_Init (void);
void Cbuf_AddText (char *text);
void Cbuf_InsertText (char *text);
void Cbuf_Execute (void);

/*
Command execution takes a null terminated string, breaks it into tokens,
then searches for a command or variable that matches the first token.

Commands can come from three sources, but the handler functions may choose
to disallow the action or forward it to a remote server if the source is
not appropriate.
*/

/// Function pointer to the *_f functions
typedef void (*xcommand_t) (void);

///////////////////////////////////////////////////////////////////////////
/// @brief	Linked List; 
///////////////////////////////////////////////////////////////////////////
typedef enum
{
	src_client,		///< Came in over a net connection as a clc_stringcmd.
					///< Host_client will be valid during this state.
	src_command		///< From the command buffer
} cmd_source_t;

extern	cmd_source_t	cmd_source;

void	Cmd_Init (void);
void	Cmd_AddCommand (char *cmd_name, xcommand_t function);
bool	Cmd_Exists (char *cmd_name);
char 	*Cmd_CompleteCommand (char *partial);
int		Cmd_Argc (void);
char	*Cmd_Argv (int arg);
char	*Cmd_Args (void);
int		Cmd_CheckParm (char *parm);
void	Cmd_TokenizeString (char *text);
void	Cmd_ExecuteString (char *text, cmd_source_t src);
void	Cmd_ForwardToServer (void);

///////////////////////////////////////////////////////////////////////////
/// @brief	Used by command functions to send output to either the graphics
///			console or passed as a print message to the client.
///////////////////////////////////////////////////////////////////////////
void	Cmd_Print (char *text);
