misc.h 2.4 KB

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