cmdlib.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1997-2006 Id Software, Inc.
  4. This file is part of Quake 2 Tools source code.
  5. Quake 2 Tools source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake 2 Tools source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Quake 2 Tools source code; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. // cmdlib.h
  19. #ifndef __CMDLIB__
  20. #define __CMDLIB__
  21. #include <stdio.h>
  22. #include <string.h>
  23. #include <stdlib.h>
  24. #include <errno.h>
  25. #include <ctype.h>
  26. #include <time.h>
  27. #include <stdarg.h>
  28. #ifndef __BYTEBOOL__
  29. #define __BYTEBOOL__
  30. typedef enum {false, true} qboolean;
  31. typedef unsigned char byte;
  32. #endif
  33. // the dec offsetof macro doesn't work very well...
  34. #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)
  35. // set these before calling CheckParm
  36. extern int myargc;
  37. extern char **myargv;
  38. int Q_strncasecmp (char *s1, char *s2, int n);
  39. int Q_strcasecmp (char *s1, char *s2);
  40. int Q_filelength (FILE *f);
  41. double I_FloatTime (void);
  42. void Error (char *error, ...);
  43. int CheckParm (char *check);
  44. void ParseCommandLine (char *lpCmdLine);
  45. FILE *SafeOpenWrite (char *filename);
  46. FILE *SafeOpenRead (char *filename);
  47. void SafeRead (FILE *f, void *buffer, int count);
  48. void SafeWrite (FILE *f, void *buffer, int count);
  49. int LoadFile (char *filename, void **bufferptr);
  50. int LoadFileNoCrash (char *filename, void **bufferptr);
  51. void SaveFile (char *filename, void *buffer, int count);
  52. void DefaultExtension (char *path, char *extension);
  53. void DefaultPath (char *path, char *basepath);
  54. void StripFilename (char *path);
  55. void StripExtension (char *path);
  56. void ExtractFilePath (char *path, char *dest);
  57. void ExtractFileName (char *path, char *dest);
  58. void ExtractFileBase (char *path, char *dest);
  59. void ExtractFileExtension (char *path, char *dest);
  60. int ParseNum (char *str);
  61. short BigShort (short l);
  62. short LittleShort (short l);
  63. int BigLong (int l);
  64. int LittleLong (int l);
  65. float BigFloat (float l);
  66. float LittleFloat (float l);
  67. char *COM_Parse (char *data);
  68. extern char com_token[1024];
  69. extern qboolean com_eof;
  70. #define MAX_NUM_ARGVS 32
  71. extern int argc;
  72. extern char *argv[MAX_NUM_ARGVS];
  73. #endif