cmdlib.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. #ifdef _WIN32
  22. #pragma warning(disable : 4244) // MIPS
  23. #pragma warning(disable : 4136) // X86
  24. #pragma warning(disable : 4051) // ALPHA
  25. #pragma warning(disable : 4018) // signed/unsigned mismatch
  26. #pragma warning(disable : 4305) // truncate from double to float
  27. #endif
  28. #include <stdio.h>
  29. #include <string.h>
  30. #include <stdlib.h>
  31. #include <errno.h>
  32. #include <ctype.h>
  33. #include <time.h>
  34. #include <stdarg.h>
  35. #ifndef __BYTEBOOL__
  36. #define __BYTEBOOL__
  37. typedef enum {false, true} qboolean;
  38. typedef unsigned char byte;
  39. #endif
  40. // the dec offsetof macro doesnt work very well...
  41. #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)
  42. // set these before calling CheckParm
  43. extern int myargc;
  44. extern char **myargv;
  45. char *strupr (char *in);
  46. char *strlower (char *in);
  47. int Q_strncasecmp (char *s1, char *s2, int n);
  48. int Q_strcasecmp (char *s1, char *s2);
  49. void Q_getwd (char *out);
  50. int Q_filelength (FILE *f);
  51. int FileTime (char *path);
  52. void Q_mkdir (char *path);
  53. extern char qdir[1024];
  54. extern char gamedir[1024];
  55. void SetQdirFromPath (char *path);
  56. char *ExpandArg (char *path); // from cmd line
  57. char *ExpandPath (char *path); // from scripts
  58. char *ExpandPathAndArchive (char *path);
  59. double I_FloatTime (void);
  60. void Error (char *error, ...);
  61. int CheckParm (char *check);
  62. FILE *SafeOpenWrite (char *filename);
  63. FILE *SafeOpenRead (char *filename);
  64. void SafeRead (FILE *f, void *buffer, int count);
  65. void SafeWrite (FILE *f, void *buffer, int count);
  66. int LoadFile (char *filename, void **bufferptr);
  67. int TryLoadFile (char *filename, void **bufferptr);
  68. void SaveFile (char *filename, void *buffer, int count);
  69. qboolean FileExists (char *filename);
  70. void DefaultExtension (char *path, char *extension);
  71. void DefaultPath (char *path, char *basepath);
  72. void StripFilename (char *path);
  73. void StripExtension (char *path);
  74. void ExtractFilePath (char *path, char *dest);
  75. void ExtractFileBase (char *path, char *dest);
  76. void ExtractFileExtension (char *path, char *dest);
  77. int ParseNum (char *str);
  78. short BigShort (short l);
  79. short LittleShort (short l);
  80. int BigLong (int l);
  81. int LittleLong (int l);
  82. float BigFloat (float l);
  83. float LittleFloat (float l);
  84. char *COM_Parse (char *data);
  85. extern char com_token[1024];
  86. extern qboolean com_eof;
  87. char *copystring(char *s);
  88. void CRC_Init(unsigned short *crcvalue);
  89. void CRC_ProcessByte(unsigned short *crcvalue, byte data);
  90. unsigned short CRC_Value(unsigned short crcvalue);
  91. void CreatePath (char *path);
  92. void QCopyFile (char *from, char *to);
  93. extern qboolean archive;
  94. extern char archivedir[1024];
  95. extern qboolean verbose;
  96. void qprintf (char *format, ...);
  97. void ExpandWildcards (int *argc, char ***argv);
  98. // for compression routines
  99. typedef struct
  100. {
  101. byte *data;
  102. int count;
  103. } cblock_t;
  104. #endif