UFO: Alien Invasion
Loading...
Searching...
No Matches
cmd.h
Go to the documentation of this file.
1
11
12/*
13Copyright (C) 1997-2001 Id Software, Inc.
14
15This program is free software; you can redistribute it and/or
16modify it under the terms of the GNU General Public License
17as published by the Free Software Foundation; either version 2
18of the License, or (at your option) any later version.
19
20This program is distributed in the hope that it will be useful,
21but WITHOUT ANY WARRANTY; without even the implied warranty of
22MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23
24See the GNU General Public License for more details.
25
26You should have received a copy of the GNU General Public License
27along with this program; if not, write to the Free Software
28Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29
30*/
31
32#pragma once
33
34#include "filesys.h"
35#include "../shared/cxx.h"
36#include "../shared/sharedptr.h"
37#include <stdarg.h>
38
39#include "../shared/cxx.h"
40void Cbuf_Init(void);
41void Cbuf_Shutdown(void);
42void Cbuf_AddText(const char* format, ...) __attribute__((format(__printf__, 1, 2)));
43
46/* inserted at the beginning of the buffer, before any remaining unexecuted */
47/* commands. */
48void Cbuf_InsertText(const char* text);
49
52void Cbuf_AddEarlyCommands(bool clear);
53
59bool Cbuf_AddLateCommands(void);
60
67void Cbuf_Execute(void);
68
73void Cbuf_CopyToDefer(void);
74void Cbuf_InsertFromDefer(void);
75
76#ifdef DEBUG
77void Cmd_PrintDebugCommands(void);
78#endif
79
80
81/*=========================================================================== */
82
83
84typedef void (*xcommand_t) (void);
85
86typedef struct cmdList_s {
87 const char* name;
89 const char* description;
90} cmdList_t;
91
97public:
98 virtual ~CmdListener() {}
99 virtual void onAdd (const char* cmdName) = 0;
100 virtual void onRemove (const char* cmdName) = 0;
101};
102
104
105void Cmd_Init(void);
106void Cmd_Shutdown(void);
107
115void Cmd_AddCommand(const char* cmd_name, xcommand_t function, const char* desc = nullptr);
116
117void Cmd_RemoveCommand(const char* cmd_name);
118void Cmd_TableCheck(void);
119void Cmd_TableAddList(const cmdList_t* cmdList);
120void Cmd_TableRemoveList(const cmdList_t* cmdList);
121
122void Cmd_AddParamCompleteFunction(const char* cmd_name, int (*function)(const char* partial, const char** match));
123
124void Cmd_AddUserdata(const char* cmd_name, void* userdata);
125void* Cmd_GetUserdata (const char* cmd_name);
126
135bool Cmd_GenericCompleteFunction(char const* candidate, char const* partial, char const** match);
136
140bool Cmd_Exists(const char* cmd_name);
141
147
153
158int Cmd_CompleteCommandParameters(const char* command, const char* partial, const char** match);
159int Cmd_CompleteCommand(const char* partial, const char** match);
160
166int Cmd_Argc(void);
167const char* Cmd_Argv(int arg);
168const char* Cmd_Args(void);
169void* Cmd_Userdata(void);
170
171void Cmd_TokenizeString(const char* text, bool macroExpand, bool replaceWhitespaces = true);
172
177void Cmd_ExecuteString(const char* text, ...) __attribute__((format(__printf__, 1, 2)));
178void Cmd_vExecuteString(const char* fmt, va_list ap);
179
185void Cmd_ForwardToServer(void);
186
190const char* Cmd_GetCommandDesc(const char* command);
191
195void Cmd_BufClear(void);
196
202
206void Cmd_Dummy_f(void);
207
208#include "ScopedCommand.h"
void Cmd_ForwardToServer(void)
adds the current command line as a clc_stringcmd to the client message. things like action,...
Definition cl_main.cpp:98
Listener for command changes.
Definition cmd.h:96
virtual void onAdd(const char *cmdName)=0
virtual ~CmdListener()
Definition cmd.h:98
virtual void onRemove(const char *cmdName)=0
void Cmd_WriteAliases(qFILE *f)
Write lines containing "aliasa alias value" for all aliases with the archive flag set to true.
Definition cmd.cpp:454
void Cbuf_InsertText(const char *text)
Adds command text immediately after the current command.
Definition cmd.cpp:157
void Cmd_Dummy_f(void)
Dummy binding if you don't want unknown commands forwarded to the server.
Definition cmd.cpp:1083
void Cbuf_Execute(void)
Pulls off terminated lines of text from the command buffer and sends them through Cmd_ExecuteString...
Definition cmd.cpp:214
void Cbuf_AddEarlyCommands(bool clear)
Adds command line parameters as script statements Commands lead with a +, and continue until another ...
Definition cmd.cpp:275
void Cbuf_InsertFromDefer(void)
Copies back any deferred commands.
Definition cmd.cpp:201
bool Cbuf_AddLateCommands(void)
Adds command line parameters as script statements.
Definition cmd.cpp:298
void Cbuf_CopyToDefer(void)
Defers any outstanding commands.
Definition cmd.cpp:191
void Cmd_vExecuteString(const char *fmt, va_list ap)
Definition cmd.cpp:952
void Cmd_BufClear(void)
Clears the argv vector and set argc to zero.
Definition cmd.cpp:543
const char * Cmd_GetCommandDesc(const char *cmdName)
Returns the command description for a given command.
Definition cmd.cpp:629
void Cmd_AddCommand(const char *cmd_name, xcommand_t function, const char *desc=nullptr)
called by the init functions of other parts of the program to register commands and functions to call...
Definition cmd.cpp:744
void Cbuf_Shutdown(void)
Definition cmd.cpp:117
const char * Cmd_Argv(int arg)
Returns a given argument.
Definition cmd.cpp:516
void * Cmd_GetUserdata(const char *cmd_name)
Fetches the userdata for a console command.
Definition cmd.cpp:700
void Cmd_TableAddList(const cmdList_t *cmdList)
Definition cmd.cpp:853
void(* xcommand_t)(void)
Definition cmd.h:84
bool Cmd_Exists(const char *cmd_name)
used by the cvar code to check for cvar / command name overlap
Definition cmd.cpp:887
void Cmd_AddParamCompleteFunction(const char *cmd_name, int(*function)(const char *partial, const char **match))
Definition cmd.cpp:679
void Cmd_TokenizeString(const char *text, bool macroExpand, bool replaceWhitespaces=true)
Parses the given string into command line tokens.
Definition cmd.cpp:565
int Cmd_CompleteCommandParameters(const char *command, const char *partial, const char **match)
attempts to match a partial command for automatic command line completion returns nullptr if nothing ...
Definition cmd.cpp:903
void Cmd_RegisterCmdListener(CmdListenerPtr listener)
Registers a command listener.
Definition cmd.cpp:869
void Cmd_UnRegisterCmdListener(CmdListenerPtr listener)
Unregisters a command listener.
Definition cmd.cpp:878
void Cmd_ExecuteString(const char *text,...) __attribute__((format(__printf__
Parses a single line of text into arguments and tries to execute it as if it was typed at the console...
void Cmd_Init(void)
Definition cmd.cpp:1127
void Cmd_AddUserdata(const char *cmd_name, void *userdata)
Adds userdata to the console command.
Definition cmd.cpp:724
const char * Cmd_Args(void)
Returns a single string containing argv(1) to argv(argc()-1).
Definition cmd.cpp:526
bool Cmd_GenericCompleteFunction(char const *candidate, char const *partial, char const **match)
Definition cmd.cpp:648
void Cmd_RemoveCommand(const char *cmd_name)
Removes a command from script interface.
Definition cmd.cpp:786
SharedPtr< CmdListener > CmdListenerPtr
Definition cmd.h:103
void Cmd_TableCheck(void)
Check both the functiontable and the associated hashtable for invalid entries.
Definition cmd.cpp:826
void Cbuf_Init(void)
allocates an initial text buffer that will grow as needed
Definition cmd.cpp:109
int Cmd_Argc(void)
The functions that execute commands get their parameters with these functions. Cmd_Argv() will return...
Definition cmd.cpp:505
void Cbuf_AddText(const char *format,...) __attribute__((format(__printf__
void Cmd_TableRemoveList(const cmdList_t *cmdList)
Definition cmd.cpp:859
void * Cmd_Userdata(void)
Return the userdata of the called command.
Definition cmd.cpp:534
void Cmd_Shutdown(void)
Definition cmd.cpp:1145
int Cmd_CompleteCommand(const char *partial, const char **match)
Unix like tab completion for console commands.
Definition cmd.cpp:924
#define __attribute__(x)
Definition cxx.h:37
Filesystem header file.
void format(__printf__, 1, 2)))
QGL_EXTERN void(APIENTRY *qglActiveTexture)(GLenum texture)
QGL_EXTERN GLfloat f
Definition r_gl.h:114
const char * description
Definition cmd.h:89
const char * name
Definition cmd.h:87
xcommand_t function
Definition cmd.h:88