# console_internal.h

Go to the documentation of this file.

    00001 /* $Id: console_internal.h 15428 2009-02-09 02:57:15Z rubidium $ */
    00002
    00005 #ifndef CONSOLE_INTERNAL_H
    00006 #define CONSOLE_INTERNAL_H
    00007
    00008 #include "console_func.h"
    00009
    00010 enum {
    00011   ICON_CMDLN_SIZE     = 1024,
    00012   ICON_MAX_STREAMSIZE = 2048,
    00013 };
    00014
    00015 enum IConsoleVarTypes {
    00016   ICONSOLE_VAR_BOOLEAN,
    00017   ICONSOLE_VAR_BYTE,
    00018   ICONSOLE_VAR_UINT16,
    00019   ICONSOLE_VAR_UINT32,
    00020   ICONSOLE_VAR_INT16,
    00021   ICONSOLE_VAR_INT32,
    00022   ICONSOLE_VAR_STRING
    00023 };
    00024
    00025 enum IConsoleHookTypes {
    00026   ICONSOLE_HOOK_ACCESS,
    00027   ICONSOLE_HOOK_PRE_ACTION,
    00028   ICONSOLE_HOOK_POST_ACTION
    00029 };
    00030
    00036 typedef bool IConsoleHook();
    00037 struct IConsoleHooks{
    00038   IConsoleHook *access;
    00039   IConsoleHook *pre;
    00040   IConsoleHook *post;
    00041 };
    00042
    00050 typedef bool (IConsoleCmdProc)(byte argc, char *argv[]);
    00051
    00052 struct IConsoleCmd {
    00053   char *name;
    00054   IConsoleCmd *next;
    00055
    00056   IConsoleCmdProc *proc;
    00057   IConsoleHooks hook;
    00058 };
    00059
    00069 struct IConsoleVar {
    00070   char *name;
    00071   IConsoleVar *next;
    00072
    00073   void *addr;
    00074   uint32 size;
    00075   char *help;
    00076   IConsoleVarTypes type;
    00077   IConsoleCmdProc *proc;
    00078   IConsoleHooks hook;
    00079 };
    00080
    00092 struct IConsoleAlias {
    00093   char *name;
    00094   IConsoleAlias *next;
    00095
    00096   char *cmdline;
    00097 };
    00098
    00099 /* console parser */
    00100 extern IConsoleCmd   *_iconsole_cmds;
    00101 extern IConsoleVar   *_iconsole_vars;
    00102 extern IConsoleAlias *_iconsole_aliases;
    00103
    00104 /* console functions */
    00105 void IConsoleClearBuffer();
    00106 void IConsoleOpen();
    00107
    00108 /* Commands */
    00109 void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc);
    00110 void IConsoleAliasRegister(const char *name, const char *cmd);
    00111 IConsoleCmd *IConsoleCmdGet(const char *name);
    00112 IConsoleAlias *IConsoleAliasGet(const char *name);
    00113
    00114 /* Variables */
    00115 void IConsoleVarRegister(const char *name, void *addr, IConsoleVarTypes type, const char *help);
    00116 void IConsoleVarStringRegister(const char *name, void *addr, uint32 size, const char *help);
    00117 IConsoleVar *IConsoleVarGet(const char *name);
    00118 void IConsoleVarPrintGetValue(const IConsoleVar *var);
    00119 void IConsoleVarPrintSetValue(const IConsoleVar *var);
    00120
    00121 /* Parser */
    00122 void IConsoleVarExec(const IConsoleVar *var, byte tokencount, char *token[]);
    00123
    00124 /* console std lib (register ingame commands/aliases/variables) */
    00125 void IConsoleStdLibRegister();
    00126
    00127 /* Hooking code */
    00128 void IConsoleCmdHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc);
    00129 void IConsoleVarHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc);
    00130 void IConsoleVarProcAdd(const char *name, IConsoleCmdProc *proc);
    00131
    00132 /* Supporting functions */
    00133 bool GetArgumentInteger(uint32 *value, const char *arg);
    00134
    00135 void IConsoleGUIInit();
    00136 void IConsoleGUIFree();
    00137 void IConsoleGUIPrint(ConsoleColour colour_code, char *string);
    00138
    00139 #endif /* CONSOLE_INTERNAL_H */