misc.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. Copyright (C) 2009-2011 id Software LLC, a ZeniMax Media company.
  3. Copyright (C) 2009 Id Software, Inc.
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. char *va( const char *format, ... );
  17. void Com_Printf( const char *fmt, ... );
  18. void Com_Error( const char *fmt, ... );
  19. int HashString( const char *string );
  20. /*
  21. Command execution takes a NUL-terminated string, breaks it into tokens,
  22. then searches for a command or variable that matches the first token.
  23. */
  24. typedef void (*xcommand_t) (void);
  25. // called by the init functions of other parts of the program to
  26. // register commands and functions to call for them.
  27. // The cmd_name is referenced later, so it should not be in temp memory
  28. // if function is NULL, the command will be forwarded to the server
  29. // as a clc_stringcmd instead of executed locally
  30. void Cmd_AddCommand( const char *cmd_name, xcommand_t function );
  31. // print all the added commands
  32. void Cmd_ListCommands_f();
  33. // attempts to match a partial command for automatic command line completion
  34. // returns NULL if nothing fits
  35. char *Cmd_CompleteCommand( const char *partial );
  36. // The functions that execute commands get their parameters with these
  37. // functions. Cmd_Argv () will return an empty string, not a NULL
  38. // if arg > argc, so string operations are always safe.
  39. int Cmd_Argc( void );
  40. const char *Cmd_Argv( int arg );
  41. // Takes a NUL-terminated string. Does not need to be /n terminated.
  42. // breaks the string up into argc / argv tokens.
  43. void Cmd_TokenizeString( const char *text );
  44. // Parses a single line of text into arguments and tries to execute it
  45. // as if it was typed at the console
  46. void Cmd_ExecuteString( const char *text );
  47. // execute each line of the config file
  48. void Cmd_ExecuteFile( const char *fullPathName );