cmdlib.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena 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 III Arena 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 Foobar; 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. #pragma check_stack(off)
  28. #endif
  29. #include <stdio.h>
  30. #include <string.h>
  31. #include <stdlib.h>
  32. #include <errno.h>
  33. #include <ctype.h>
  34. #include <time.h>
  35. #include <stdarg.h>
  36. #ifdef _WIN32
  37. #pragma intrinsic( memset, memcpy )
  38. #endif
  39. #ifndef __BYTEBOOL__
  40. #define __BYTEBOOL__
  41. typedef enum { qfalse, qtrue } qboolean;
  42. typedef unsigned char byte;
  43. #endif
  44. #define MAX_OS_PATH 1024
  45. #define MEM_BLOCKSIZE 4096
  46. // the dec offsetof macro doesnt work very well...
  47. #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)
  48. // set these before calling CheckParm
  49. extern int myargc;
  50. extern char **myargv;
  51. char *strupr (char *in);
  52. char *strlower (char *in);
  53. int Q_strncasecmp( const char *s1, const char *s2, int n );
  54. int Q_stricmp( const char *s1, const char *s2 );
  55. void Q_getwd( char *out );
  56. int Q_filelength (FILE *f);
  57. int FileTime( const char *path );
  58. void Q_mkdir( const char *path );
  59. extern char qdir[1024];
  60. extern char gamedir[1024];
  61. extern char writedir[1024];
  62. void SetQdirFromPath( const char *path );
  63. char *ExpandArg( const char *path ); // from cmd line
  64. char *ExpandPath( const char *path ); // from scripts
  65. char *ExpandGamePath (const char *path);
  66. char *ExpandPathAndArchive( const char *path );
  67. double I_FloatTime( void );
  68. void Error( const char *error, ... );
  69. int CheckParm( const char *check );
  70. FILE *SafeOpenWrite( const char *filename );
  71. FILE *SafeOpenRead( const char *filename );
  72. void SafeRead (FILE *f, void *buffer, int count);
  73. void SafeWrite (FILE *f, const void *buffer, int count);
  74. int LoadFile( const char *filename, void **bufferptr );
  75. int LoadFileBlock( const char *filename, void **bufferptr );
  76. int TryLoadFile( const char *filename, void **bufferptr );
  77. void SaveFile( const char *filename, const void *buffer, int count );
  78. qboolean FileExists( const char *filename );
  79. void DefaultExtension( char *path, const char *extension );
  80. void DefaultPath( char *path, const char *basepath );
  81. void StripFilename( char *path );
  82. void StripExtension( char *path );
  83. void ExtractFilePath( const char *path, char *dest );
  84. void ExtractFileBase( const char *path, char *dest );
  85. void ExtractFileExtension( const char *path, char *dest );
  86. int ParseNum (const char *str);
  87. short BigShort (short l);
  88. short LittleShort (short l);
  89. int BigLong (int l);
  90. int LittleLong (int l);
  91. float BigFloat (float l);
  92. float LittleFloat (float l);
  93. char *COM_Parse (char *data);
  94. extern char com_token[1024];
  95. extern qboolean com_eof;
  96. char *copystring(const char *s);
  97. void CRC_Init(unsigned short *crcvalue);
  98. void CRC_ProcessByte(unsigned short *crcvalue, byte data);
  99. unsigned short CRC_Value(unsigned short crcvalue);
  100. void CreatePath( const char *path );
  101. void QCopyFile( const char *from, const char *to );
  102. extern qboolean archive;
  103. extern char archivedir[1024];
  104. extern qboolean verbose;
  105. void qprintf( const char *format, ... );
  106. void _printf( const char *format, ... );
  107. void ExpandWildcards( int *argc, char ***argv );
  108. // for compression routines
  109. typedef struct
  110. {
  111. void *data;
  112. int count, width, height;
  113. } cblock_t;
  114. #endif