+ int argc;
+ const char *cmdline;
+ const char *argv[MAX_ARGS];
+ const char *null_string;
+ const char *args;
+ cmd_source_t source;
+
+ cmd_buf_t *cbuf;
+
+ cmd_userdefined_t *userdefined; // possible csqc functions and aliases to execute
+
+ cmd_function_t *engine_functions;
+
+ struct cvar_state_s *cvars; // which cvar system is this cmd state able to access? (&cvars_all or &cvars_null)
+ unsigned cvars_flagsmask; // which CVAR_* flags should be visible to this interpreter? (CF_CLIENT | CF_SERVER, or just CF_SERVER)
+ unsigned cmd_flagsmask; // cmd flags that identify this interpreter
+
+ qbool (*Handle)(struct cmd_state_s *, struct cmd_function_s *, const char *, enum cmd_source_s);
+}
+cmd_state_t;
+
+qbool Cmd_Callback(cmd_state_t *cmd, cmd_function_t *func, const char *text, cmd_source_t src);
+qbool Cmd_CL_Callback(cmd_state_t *cmd, cmd_function_t *func, const char *text, cmd_source_t src);
+qbool Cmd_SV_Callback(cmd_state_t *cmd, cmd_function_t *func, const char *text, cmd_source_t src);
+
+typedef struct cmd_input_s
+{
+ llist_t list;
+ cmd_state_t *source;
+ vec_t delay;
+ size_t size; ///< excludes \0 terminator
+ size_t length; ///< excludes \0 terminator
+ char *text;
+ qbool pending;
+} cmd_input_t;
+
+extern cmd_userdefined_t cmd_userdefined_all; // aliases and csqc functions
+extern cmd_userdefined_t cmd_userdefined_null; // intentionally empty
+
+// command interpreter for local commands injected by SVQC, CSQC, MQC, server or client engine code
+// uses cmddefs_all
+extern cmd_state_t *cmd_local;
+// command interpreter for server commands received over network from clients
+// uses cmddefs_null
+extern cmd_state_t *cmd_serverfromclient;
+
+extern qbool host_stuffcmdsrun;
+
+void Cbuf_Lock(cmd_buf_t *cbuf);
+void Cbuf_Unlock(cmd_buf_t *cbuf);
+
+/*! as new commands are generated from the console or keybindings,
+ * the text is added to the end of the command buffer.
+ */
+void Cbuf_AddText (cmd_state_t *cmd, const char *text);
+
+/*! when a command wants to issue other commands immediately, the text is
+ * inserted at the beginning of the buffer, before any remaining unexecuted
+ * commands.
+ */
+void Cbuf_InsertText (cmd_state_t *cmd, const char *text);
+
+/*! Pulls off terminated lines of text from the command buffer and sends
+ * them through Cmd_ExecuteString. Stops when the buffer is empty.
+ * Normally called once per frame, but may be explicitly invoked.
+ * \note Do not call inside a command function!
+ */
+void Cbuf_Execute (cmd_buf_t *cbuf);
+/*! Performs deferred commands and runs Cbuf_Execute, called by Host_Frame */
+void Cbuf_Frame (cmd_buf_t *cbuf);
+/// Clears all command buffers
+void Cbuf_Clear(cmd_buf_t *cbuf);