+ struct cvar_state_s *cvars; // which cvar system is this cmd state able to access? (&cvars_all or &cvars_null)
+ int cvars_flagsmask; // which CVAR_* flags should be visible to this interpreter? (CF_CLIENT | CF_SERVER, or just CF_SERVER)
+
+ int cmd_flags; // cmd flags that identify this interpreter
+
+ qbool (*Handle)(struct cmd_state_s *, struct cmd_function_s *, const char *, enum cmd_source_s);
+ qbool (*NotFound)(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);
+qbool Cmd_SV_NotFound(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;
+ double delay;
+ size_t size;
+ size_t length;
+ 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);