#include "cmdlib.h"
#include "windows.h"
Include dependency graph for cmdlib.cpp:

Go to the source code of this file.
Defines | |
| #define | MEM_BLOCKSIZE 4096 |
| #define | PATHSEPERATOR '/' |
Functions | |
| float | BigFloat (float l) |
| int | BigLong (int l) |
| short | BigShort (short l) |
| void | ConvertDOSToUnixName (char *dst, const char *src) |
| void | DefaultExtension (char *path, char *extension) |
| void | DefaultPath (char *path, char *basepath) |
| void | Error (const char *pFormat,...) |
| void | ErrorNum (int nErr, const char *pFormat,...) |
| void | ExtractFileBase (const char *path, char *dest) |
| void | ExtractFileExtension (const char *path, char *dest) |
| void | ExtractFileName (const char *path, char *dest) |
| void | ExtractFilePath (const char *path, char *dest) |
| float | LittleFloat (float l) |
| int | LittleLong (int l) |
| short | LittleShort (short l) |
| int | LoadFile (const char *filename, void **bufferptr) |
| int | LoadFileNoCrash (const char *filename, void **bufferptr) |
| void | Printf (const char *pFormat,...) |
| void | PrintfNum (int nErr, const char *pFormat,...) |
| int | Q_filelength (FILE *f) |
| void * | qblockmalloc (size_t nSize) |
| void * | qmalloc (size_t nSize) |
| FILE * | SafeOpenRead (const char *filename) |
| FILE * | SafeOpenWrite (const char *filename) |
| void | SafeRead (FILE *f, void *buffer, int count) |
| void | SafeWrite (FILE *f, const void *buffer, int count) |
| void | SaveFile (const char *filename, void *buffer, int count) |
| void | SetErrorHandler (PFN_ERR pe) |
| void | SetErrorHandlerNum (PFN_ERR_NUM pe) |
| void | SetPrintfHandler (PFN_PRINTF_NUM pe) |
| void | SetPrintfHandler (PFN_PRINTF pe) |
| char * | StrDup (const char *pStr) |
| char * | StrDup (char *pStr) |
| void | StripExtension (char *path) |
| void | StripFilename (char *path) |
Variables | |
| PFN_ERR * | g_pfnError = NULL |
| PFN_ERR_NUM * | g_pfnErrorNum = NULL |
| PFN_PRINTF * | g_pfnPrintf = NULL |
| PFN_PRINTF_NUM * | g_pfnPrintfNum = NULL |
|
|
Definition at line 89 of file cmdlib.cpp. |
|
|
Definition at line 9 of file cmdlib.cpp. |
|
|
Definition at line 529 of file cmdlib.cpp. 00530 {
00531 union {byte b[4]; float f;} in, out;
00532
00533 in.f = l;
00534 out.b[0] = in.b[3];
00535 out.b[1] = in.b[2];
00536 out.b[2] = in.b[1];
00537 out.b[3] = in.b[0];
00538
00539 return out.f;
00540 }
|
|
|
Definition at line 512 of file cmdlib.cpp. 00513 {
00514 byte b1,b2,b3,b4;
00515
00516 b1 = l&255;
00517 b2 = (l>>8)&255;
00518 b3 = (l>>16)&255;
00519 b4 = (l>>24)&255;
00520
00521 return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
00522 }
|
|
|
Definition at line 496 of file cmdlib.cpp. 00497 {
00498 byte b1,b2;
00499
00500 b1 = l&255;
00501 b2 = (l>>8)&255;
00502
00503 return (b1<<8) + b2;
00504 }
|
|
||||||||||||
|
Definition at line 393 of file cmdlib.cpp. References src. 00394 {
00395 while ( *src )
00396 {
00397 if ( *src == '\\' )
00398 *dst = '/';
00399 else
00400 *dst = *src;
00401 dst++; src++;
00402 }
00403 *dst = 0;
00404 }
|
|
||||||||||||
|
Definition at line 253 of file cmdlib.cpp. References PATHSEPERATOR, src, strcat(), and strlen(). 00254 {
00255 char *src;
00256 //
00257 // if path doesn't have a .EXT, append extension
00258 // (extension should include the .)
00259 //
00260 src = path + strlen(path) - 1;
00261
00262 while (*src != PATHSEPERATOR && src != path)
00263 {
00264 if (*src == '.')
00265 return; // it has an extension
00266 src--;
00267 }
00268
00269 strcat (path, extension);
00270 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 273 of file cmdlib.cpp. References basepath(), strcat(), and strcpy(). 00274 {
00275 char temp[128];
00276
00277 if (path[0] == PATHSEPERATOR)
00278 return; // absolute path location
00279 strcpy (temp,path);
00280 strcpy (path,basepath);
00281 strcat (path,temp);
00282 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 19 of file cmdlib.cpp. References g_pfnError, va_end, va_list, and va_start. 00020 {
00021 if (g_pfnError)
00022 {
00023 va_list arg_ptr;
00024 va_start(arg_ptr, pFormat);
00025 g_pfnError(pFormat, arg_ptr);
00026 va_end(arg_ptr);
00027 }
00028 }
|
|
||||||||||||||||
|
Definition at line 41 of file cmdlib.cpp. References g_pfnErrorNum, va_end, va_list, and va_start. 00042 {
00043 if (g_pfnErrorNum)
00044 {
00045 va_list arg_ptr;
00046 va_start(arg_ptr, pFormat);
00047 g_pfnErrorNum(nErr, pFormat, arg_ptr);
00048 va_end(arg_ptr);
00049 }
00050 }
|
|
||||||||||||
|
Definition at line 352 of file cmdlib.cpp. 00353 {
00354 const char *src;
00355
00356 src = path + strlen(path) - 1;
00357
00358 //
00359 // back up until a \ or the start
00360 //
00361 while (src != path && *(src-1) != '/'
00362 && *(src-1) != '\\' )
00363 src--;
00364
00365 while (*src && *src != '.')
00366 {
00367 *dest++ = *src++;
00368 }
00369 *dest = 0;
00370 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 372 of file cmdlib.cpp. References src, strcpy(), and strlen(). 00373 {
00374 const char *src;
00375
00376 src = path + strlen(path) - 1;
00377
00378 //
00379 // back up until a . or the start
00380 //
00381 while (src != path && *(src-1) != '.')
00382 src--;
00383 if (src == path)
00384 {
00385 *dest = 0; // no extension
00386 return;
00387 }
00388
00389 strcpy (dest,src);
00390 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 332 of file cmdlib.cpp. Referenced by QE_ExpandBspString(). 00333 {
00334 const char *src;
00335
00336 src = path + strlen(path) - 1;
00337
00338 //
00339 // back up until a \ or the start
00340 //
00341 while (src != path && *(src-1) != '/'
00342 && *(src-1) != '\\' )
00343 src--;
00344
00345 while (*src)
00346 {
00347 *dest++ = *src++;
00348 }
00349 *dest = 0;
00350 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 316 of file cmdlib.cpp. References memcpy(), src, and strlen(). 00317 {
00318 const char *src;
00319
00320 src = path + strlen(path) - 1;
00321
00322 //
00323 // back up until a \ or the start
00324 //
00325 while (src != path && *(src-1) != PATHSEPERATOR)
00326 src--;
00327
00328 memcpy (dest, path, src-path);
00329 dest[src-path] = 0;
00330 }
|
Here is the call graph for this function:

|
|
Definition at line 542 of file cmdlib.cpp. 00543 {
00544 return l;
00545 }
|
|
|
Definition at line 524 of file cmdlib.cpp. 00525 {
00526 return l;
00527 }
|
|
|
Definition at line 506 of file cmdlib.cpp. 00507 {
00508 return l;
00509 }
|
|
||||||||||||
|
Definition at line 181 of file cmdlib.cpp. References buffer, f, fclose(), fopen(), length(), NULL, Q_filelength(), qblockmalloc(), SafeRead(), and strlen(). 00182 {
00183 FILE *f;
00184 int length;
00185 void *buffer;
00186
00187 *bufferptr = NULL;
00188
00189 if (filename == NULL || strlen(filename) == 0)
00190 {
00191 return -1;
00192 }
00193
00194 f = fopen (filename, "rb");
00195 if (!f)
00196 {
00197 return -1;
00198 }
00199 length = Q_filelength (f);
00200 buffer = qblockmalloc (length+1);
00201 ((char *)buffer)[length] = 0;
00202 SafeRead (f, buffer, length);
00203 fclose (f);
00204
00205 *bufferptr = buffer;
00206 return length;
00207 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 217 of file cmdlib.cpp. References buffer, f, fclose(), fopen(), length(), Q_filelength(), qmalloc(), and SafeRead(). Referenced by QE_LoadProject(). 00218 {
00219 FILE *f;
00220 int length;
00221 void *buffer;
00222
00223 f = fopen (filename, "rb");
00224 if (!f)
00225 return -1;
00226 length = Q_filelength (f);
00227 buffer = qmalloc (length+1);
00228 ((char *)buffer)[length] = 0;
00229 SafeRead (f, buffer, length);
00230 fclose (f);
00231
00232 *bufferptr = buffer;
00233 return length;
00234 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 30 of file cmdlib.cpp. References g_pfnPrintf, va_end, va_list, and va_start. 00031 {
00032 if (g_pfnPrintf)
00033 {
00034 va_list arg_ptr;
00035 va_start(arg_ptr, pFormat);
00036 g_pfnPrintf(pFormat, arg_ptr);
00037 va_end(arg_ptr);
00038 }
00039 }
|
|
||||||||||||||||
|
Definition at line 52 of file cmdlib.cpp. References g_pfnPrintfNum, va_end, va_list, and va_start. 00053 {
00054 if (g_pfnPrintfNum)
00055 {
00056 va_list arg_ptr;
00057 va_start(arg_ptr, pFormat);
00058 g_pfnPrintfNum(nErr, pFormat, arg_ptr);
00059 va_end(arg_ptr);
00060 }
00061 }
|
|
|
Definition at line 117 of file cmdlib.cpp. References f, fseek(), ftell(), SEEK_END, and SEEK_SET. 00118 {
00119 int pos;
00120 int end;
00121
00122 pos = ftell (f);
00123 fseek (f, 0, SEEK_END);
00124 end = ftell (f);
00125 fseek (f, pos, SEEK_SET);
00126
00127 return end;
00128 }
|
Here is the call graph for this function:

|
|
Definition at line 90 of file cmdlib.cpp. References b, malloc(), MEM_BLOCKSIZE, and memset(). Referenced by LoadFile(). 00091 {
00092 void *b;
00093 // round up to threshold
00094 int nAllocSize = nSize % MEM_BLOCKSIZE;
00095 if ( nAllocSize > 0)
00096 {
00097 nSize += MEM_BLOCKSIZE - nAllocSize;
00098 }
00099 b = malloc(nSize + 1);
00100 memset (b, 0, nSize);
00101 return b;
00102 }
|
Here is the call graph for this function:

|
|
Definition at line 104 of file cmdlib.cpp. References b, malloc(), and memset(). Referenced by Brush_Alloc(), Eclass_hasModel(), Eclass_InitFromText(), Entity_Clone(), Entity_CopyClone(), Entity_Create(), Entity_Parse(), Face_Alloc(), GetCachedModel(), Group_Add(), Group_Alloc(), LoadFileNoCrash(), LoadModel(), MakeNewPatch(), MakeNewTerrain(), Map_New(), ParseEpair(), QERApp_AllocateEpair(), QERApp_CreateEntityHandle(), QERApp_GetPoints(), SetKeyValue(), Texture_CreateSolid(), Texture_LoadTexture(), Texture_LoadTGATexture(), Texture_MakeDefault(), Texture_MakeNoshadertexture(), and Winding_Clone(). 00105 {
00106 void *b;
00107 b = malloc(nSize + 1);
00108 memset (b, 0, nSize);
00109 return b;
00110 }
|
Here is the call graph for this function:

|
|
Definition at line 146 of file cmdlib.cpp. References errno, Error(), f, fopen(), and strerror(). 00147 {
00148 FILE *f;
00149
00150 f = fopen(filename, "rb");
00151
00152 if (!f)
00153 {
00154 Error ("Error opening %s: %s",filename,strerror(errno));
00155 }
00156
00157 return f;
00158 }
|
Here is the call graph for this function:

|
|
Definition at line 132 of file cmdlib.cpp. References errno, Error(), f, fopen(), and strerror(). 00133 {
00134 FILE *f;
00135
00136 f = fopen(filename, "wb");
00137
00138 if (!f)
00139 {
00140 Error ("Error opening %s: %s",filename,strerror(errno));
00141 }
00142
00143 return f;
00144 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 161 of file cmdlib.cpp. References buffer, count, Error(), f, and fread(). 00162 {
00163 if ( (int)fread (buffer, 1, count, f) != count)
00164 Error ("File read failure");
00165 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 168 of file cmdlib.cpp. References buffer, count, Error(), f, and fwrite(). 00169 {
00170 if ( (int)fwrite (buffer, 1, count, f) != count)
00171 Error ("File read failure");
00172 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 242 of file cmdlib.cpp. 00243 {
00244 FILE *f;
00245
00246 f = SafeOpenWrite (filename);
00247 SafeWrite (f, buffer, count);
00248 fclose (f);
00249 }
|
|
|
Definition at line 65 of file cmdlib.cpp. References g_pfnError. 00066 {
00067 g_pfnError = pe;
00068 }
|
|
|
Definition at line 75 of file cmdlib.cpp. References g_pfnErrorNum. 00076 {
00077 g_pfnErrorNum = pe;
00078 }
|
|
|
Definition at line 80 of file cmdlib.cpp. References g_pfnPrintfNum. 00081 {
00082 g_pfnPrintfNum = pe;
00083 }
|
|
|
Definition at line 70 of file cmdlib.cpp. 00071 {
00072 g_pfnPrintf = pe;
00073 }
|
|
|
Definition at line 416 of file cmdlib.cpp. References strcpy(), and strlen(). 00417 {
00418 if (pStr)
00419 {
00420 return strcpy(new char[strlen(pStr)+1], pStr);
00421 }
00422 return NULL;
00423 }
|
Here is the call graph for this function:

|
|
Definition at line 407 of file cmdlib.cpp. 00408 {
00409 if (pStr)
00410 {
00411 return strcpy(new char[strlen(pStr)+1], pStr);
00412 }
00413 return NULL;
00414 }
|
|
|
Definition at line 295 of file cmdlib.cpp. References length(), and strlen(). 00296 {
00297 int length;
00298
00299 length = strlen(path)-1;
00300 while (length > 0 && path[length] != '.')
00301 {
00302 length--;
00303 if (path[length] == '/')
00304 return; // no extension
00305 }
00306 if (length)
00307 path[length] = 0;
00308 }
|
Here is the call graph for this function:

|
|
Definition at line 285 of file cmdlib.cpp. References length(), and strlen(). 00286 {
00287 int length;
00288
00289 length = strlen(path)-1;
00290 while (length > 0 && path[length] != PATHSEPERATOR)
00291 length--;
00292 path[length] = 0;
00293 }
|
Here is the call graph for this function:

|
|
Definition at line 13 of file cmdlib.cpp. Referenced by Error(), and SetErrorHandler(). |
|
|
Definition at line 15 of file cmdlib.cpp. Referenced by ErrorNum(), and SetErrorHandlerNum(). |
|
|
Definition at line 14 of file cmdlib.cpp. Referenced by Printf(), and SetPrintfHandler(). |
|
|
Definition at line 16 of file cmdlib.cpp. Referenced by PrintfNum(), and SetPrintfHandler(). |
1.3.9.1