cmdlib.h (4343B)
1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 5 This file is part of Quake III Arena source code. 6 7 Quake III Arena source code is free software; you can redistribute it 8 and/or modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the License, 10 or (at your option) any later version. 11 12 Quake III Arena source code is distributed in the hope that it will be 13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Foobar; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 =========================================================================== 21 */ 22 // cmdlib.h 23 24 #ifndef __CMDLIB__ 25 #define __CMDLIB__ 26 27 #ifdef _WIN32 28 #pragma warning(disable : 4244) // MIPS 29 #pragma warning(disable : 4136) // X86 30 #pragma warning(disable : 4051) // ALPHA 31 32 #pragma warning(disable : 4018) // signed/unsigned mismatch 33 #pragma warning(disable : 4305) // truncate from double to float 34 35 #pragma check_stack(off) 36 37 #endif 38 39 #include <stdio.h> 40 #include <string.h> 41 #include <stdlib.h> 42 #include <errno.h> 43 #include <ctype.h> 44 #include <time.h> 45 #include <stdarg.h> 46 47 #ifdef _WIN32 48 49 #pragma intrinsic( memset, memcpy ) 50 51 #endif 52 53 #ifndef __BYTEBOOL__ 54 #define __BYTEBOOL__ 55 typedef enum { qfalse, qtrue } qboolean; 56 typedef unsigned char byte; 57 #endif 58 59 #define MAX_OS_PATH 1024 60 #define MEM_BLOCKSIZE 4096 61 62 // the dec offsetof macro doesnt work very well... 63 #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier) 64 65 66 // set these before calling CheckParm 67 extern int myargc; 68 extern char **myargv; 69 70 char *strupr (char *in); 71 char *strlower (char *in); 72 int Q_strncasecmp( const char *s1, const char *s2, int n ); 73 int Q_stricmp( const char *s1, const char *s2 ); 74 void Q_getwd( char *out ); 75 76 int Q_filelength (FILE *f); 77 int FileTime( const char *path ); 78 79 void Q_mkdir( const char *path ); 80 81 extern char qdir[1024]; 82 extern char gamedir[1024]; 83 extern char writedir[1024]; 84 void SetQdirFromPath( const char *path ); 85 char *ExpandArg( const char *path ); // from cmd line 86 char *ExpandPath( const char *path ); // from scripts 87 char *ExpandGamePath (const char *path); 88 char *ExpandPathAndArchive( const char *path ); 89 90 91 double I_FloatTime( void ); 92 93 void Error( const char *error, ... ); 94 int CheckParm( const char *check ); 95 96 FILE *SafeOpenWrite( const char *filename ); 97 FILE *SafeOpenRead( const char *filename ); 98 void SafeRead (FILE *f, void *buffer, int count); 99 void SafeWrite (FILE *f, const void *buffer, int count); 100 101 int LoadFile( const char *filename, void **bufferptr ); 102 int LoadFileBlock( const char *filename, void **bufferptr ); 103 int TryLoadFile( const char *filename, void **bufferptr ); 104 void SaveFile( const char *filename, const void *buffer, int count ); 105 qboolean FileExists( const char *filename ); 106 107 void DefaultExtension( char *path, const char *extension ); 108 void DefaultPath( char *path, const char *basepath ); 109 void StripFilename( char *path ); 110 void StripExtension( char *path ); 111 112 void ExtractFilePath( const char *path, char *dest ); 113 void ExtractFileBase( const char *path, char *dest ); 114 void ExtractFileExtension( const char *path, char *dest ); 115 116 int ParseNum (const char *str); 117 118 short BigShort (short l); 119 short LittleShort (short l); 120 int BigLong (int l); 121 int LittleLong (int l); 122 float BigFloat (float l); 123 float LittleFloat (float l); 124 125 126 char *COM_Parse (char *data); 127 128 extern char com_token[1024]; 129 extern qboolean com_eof; 130 131 char *copystring(const char *s); 132 133 134 void CRC_Init(unsigned short *crcvalue); 135 void CRC_ProcessByte(unsigned short *crcvalue, byte data); 136 unsigned short CRC_Value(unsigned short crcvalue); 137 138 void CreatePath( const char *path ); 139 void QCopyFile( const char *from, const char *to ); 140 141 extern qboolean archive; 142 extern char archivedir[1024]; 143 144 145 extern qboolean verbose; 146 void qprintf( const char *format, ... ); 147 void _printf( const char *format, ... ); 148 149 void ExpandWildcards( int *argc, char ***argv ); 150 151 152 // for compression routines 153 typedef struct 154 { 155 void *data; 156 int count, width, height; 157 } cblock_t; 158 159 160 #endif