Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

cmdlib.h File Reference

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <stdarg.h>

Include dependency graph for cmdlib.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  cblock_t

Defines

#define MAX_OS_PATH   1024
#define MEM_BLOCKSIZE   4096
#define myoffsetof(type, identifier)   ((size_t)&((type *)0)->identifier)

Typedefs

typedef unsigned char byte

Enumerations

enum  qboolean { qfalse, qtrue }

Functions

void _printf (const char *format,...)
float BigFloat (float l)
int BigLong (int l)
short BigShort (short l)
int CheckParm (const char *check)
char * COM_Parse (char *data)
char * copystring (const char *s)
void CRC_Init (unsigned short *crcvalue)
void CRC_ProcessByte (unsigned short *crcvalue, byte data)
unsigned short CRC_Value (unsigned short crcvalue)
void CreatePath (const char *path)
void DefaultExtension (char *path, const char *extension)
void DefaultPath (char *path, const char *basepath)
void Error (const char *error,...)
char * ExpandArg (const char *path)
char * ExpandGamePath (const char *path)
char * ExpandPath (const char *path)
char * ExpandPathAndArchive (const char *path)
void ExpandWildcards (int *argc, char ***argv)
void ExtractFileBase (const char *path, char *dest)
void ExtractFileExtension (const char *path, char *dest)
void ExtractFilePath (const char *path, char *dest)
qboolean FileExists (const char *filename)
int FileTime (const char *path)
double I_FloatTime (void)
float LittleFloat (float l)
int LittleLong (int l)
short LittleShort (short l)
int LoadFile (const char *filename, void **bufferptr)
int LoadFileBlock (const char *filename, void **bufferptr)
int ParseNum (const char *str)
int Q_filelength (FILE *f)
void Q_getwd (char *out)
void Q_mkdir (const char *path)
int Q_stricmp (const char *s1, const char *s2)
int Q_strncasecmp (const char *s1, const char *s2, int n)
void QCopyFile (const char *from, const char *to)
void qprintf (const char *format,...)
FILESafeOpenRead (const char *filename)
FILESafeOpenWrite (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, const void *buffer, int count)
void SetQdirFromPath (const char *path)
void StripExtension (char *path)
void StripFilename (char *path)
char * strlower (char *in)
char * strupr (char *in)
int TryLoadFile (const char *filename, void **bufferptr)

Variables

qboolean archive
char archivedir [1024]
qboolean com_eof
char com_token [1024]
char gamedir [1024]
int myargc
char ** myargv
char qdir [1024]
qboolean verbose
char writedir [1024]


Define Documentation

#define MAX_OS_PATH   1024
 

Definition at line 59 of file cmdlib.h.

#define MEM_BLOCKSIZE   4096
 

Definition at line 60 of file cmdlib.h.

#define myoffsetof type,
identifier   )     ((size_t)&((type *)0)->identifier)
 

Definition at line 63 of file cmdlib.h.


Typedef Documentation

typedef unsigned char byte
 

Definition at line 56 of file cmdlib.h.


Enumeration Type Documentation

enum qboolean
 

Enumeration values:
qfalse 
qtrue 

Definition at line 55 of file cmdlib.h.

00055 { qfalse, qtrue } qboolean;


Function Documentation

void _printf const char *  format,
  ...
 

Definition at line 178 of file cmdlib.c.

References a, format, LPARAM, NULL, printf(), va_end, va_list, va_start, and vsprintf().

Referenced by AddTriangleModels(), Bspinfo(), CalcPassagePortalVis(), CalcPassageVis(), CalcPHS(), CalcPortalVis(), CalcVis(), CheckAreas_r(), CountActivePortals(), CreateEntityLights(), CreateFilters(), CreateNewFloatPlane(), CreatePassages(), CreateSurfaceLights(), EndBSPFile(), Error(), FinishBrush(), FloodAreas_r(), FogDrawSurfs(), GetThreadWork(), GridAndVertexLighting(), LightMain(), LoadMapFile(), LoadPortals(), LoadShaderImage(), main(), MakeTreePortals_r(), MergeLeafPortals(), MergeLeaves(), ParseShaderFile(), PassageFlow(), PassageMemory(), PassagePortalFlow(), PointToPolygonFormFactor(), PortalFlow(), PrintBrush(), PrintCtrl(), PrintMesh(), PrintOccluded(), PrintPortal(), PrintTree_r(), prl(), ProcessWorldModel(), R_LoadMD3(), RemoveDuplicateBrushPlanes(), RemoveLightsInSolid(), RunThreadsOn(), SetBrushContents(), SplitMeshByPlane(), VisMain(), VL_CalcVisibleLightmapPixelArea(), VL_ChopWinding(), VL_ChopWindingWithBrush(), VL_CreateEntityLights(), VL_CreateFakeSurfaceLights(), VL_CreateSkyLights(), VL_DoForcedTraceLightSurfaces(), VL_InitSurfacesForTesting(), VL_LightmapMatrixFromPoints(), VL_LightSurfaceWithVolume(), VL_LightWorld(), VL_LoadPortals(), VL_Radiosity(), VL_SplitLightVolume(), VL_SplitWinding(), VL_StoreLightmap(), VLightMain(), VS_CalcVisibleLightmapPixelArea(), VS_ChopWinding(), VS_ChopWindingWithBrush(), VS_CreateEntitySpeakers(), VS_CreateFakeSurfaceLights(), VS_CreateSkyLights(), VS_DoForcedTraceLightSurfaces(), VS_InitSurfacesForTesting(), VS_LightmapMatrixFromPoints(), VS_LightSurfaceWithVolume(), VS_LightWorld(), VS_LoadPortals(), VS_Radiosity(), VS_SplitLightVolume(), VS_SplitWinding(), VS_StoreLightmap(), VSoundMain(), WriteBspBrushMap(), WriteGLView(), and WritePortalFile().

00178                                         {
00179     va_list argptr;
00180   char text[4096];
00181   ATOM a;
00182 
00183     va_start (argptr,format);
00184     vsprintf (text, format, argptr);
00185     va_end (argptr);
00186 
00187   printf(text);
00188 
00189 #ifdef WIN32
00190   if (!lookedForServer) {
00191     lookedForServer = qtrue;
00192     hwndOut = FindWindow(NULL, "Q3Map Process Server");
00193     if (hwndOut) {
00194       wm_BroadcastCommand = RegisterWindowMessage( "Q3MPS_BroadcastCommand" );
00195     }
00196   }
00197   if (hwndOut) {
00198     a = GlobalAddAtom(text);
00199     PostMessage(hwndOut, wm_BroadcastCommand, 0, (LPARAM)a);
00200   }
00201 #endif
00202 }

Here is the call graph for this function:

float BigFloat float  l  ) 
 

Definition at line 1052 of file l_cmd.c.

01053 {
01054     union {byte b[4]; float f;} in, out;
01055     
01056     in.f = l;
01057     out.b[0] = in.b[3];
01058     out.b[1] = in.b[2];
01059     out.b[2] = in.b[1];
01060     out.b[3] = in.b[0];
01061     
01062     return out.f;
01063 }

int BigLong int  l  ) 
 

Definition at line 1035 of file l_cmd.c.

01036 {
01037     byte    b1,b2,b3,b4;
01038 
01039     b1 = l&255;
01040     b2 = (l>>8)&255;
01041     b3 = (l>>16)&255;
01042     b4 = (l>>24)&255;
01043 
01044     return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
01045 }

short BigShort short  l  ) 
 

Definition at line 1019 of file l_cmd.c.

01020 {
01021     byte    b1,b2;
01022 
01023     b1 = l&255;
01024     b2 = (l>>8)&255;
01025 
01026     return (b1<<8) + b2;
01027 }

int CheckParm const char *  check  ) 
 

Definition at line 601 of file cmdlib.c.

References check(), i, myargv, and Q_stricmp().

00602 {
00603     int             i;
00604 
00605     for (i = 1;i<myargc;i++)
00606     {
00607         if ( !Q_stricmp(check, myargv[i]) )
00608             return i;
00609     }
00610 
00611     return 0;
00612 }

Here is the call graph for this function:

char* COM_Parse char *  data  ) 
 

Definition at line 438 of file l_cmd.c.

00439 {
00440     int     c;
00441     int     len;
00442     
00443     len = 0;
00444     com_token[0] = 0;
00445     
00446     if (!data)
00447         return NULL;
00448         
00449 // skip whitespace
00450 skipwhite:
00451     while ( (c = *data) <= ' ')
00452     {
00453         if (c == 0)
00454         {
00455             com_eof = true;
00456             return NULL;            // end of file;
00457         }
00458         data++;
00459     }
00460     
00461 // skip // comments
00462     if (c=='/' && data[1] == '/')
00463     {
00464         while (*data && *data != '\n')
00465             data++;
00466         goto skipwhite;
00467     }
00468     
00469 
00470 // handle quoted strings specially
00471     if (c == '\"')
00472     {
00473         data++;
00474         do
00475         {
00476             c = *data++;
00477             if (c=='\"')
00478             {
00479                 com_token[len] = 0;
00480                 return data;
00481             }
00482             com_token[len] = c;
00483             len++;
00484         } while (1);
00485     }
00486 
00487 // parse single characters
00488     if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
00489     {
00490         com_token[len] = c;
00491         len++;
00492         com_token[len] = 0;
00493         return data+1;
00494     }
00495 
00496 // parse a regular word
00497     do
00498     {
00499         com_token[len] = c;
00500         data++;
00501         len++;
00502         c = *data;
00503     if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
00504             break;
00505     } while (c>32);
00506     
00507     com_token[len] = 0;
00508     return data;
00509 }

char* copystring const char *  s  ) 
 

Definition at line 353 of file cmdlib.c.

References b, malloc(), s, strcpy(), and strlen().

00354 {
00355     char    *b;
00356     b = malloc(strlen(s)+1);
00357     strcpy (b, s);
00358     return b;
00359 }

Here is the call graph for this function:

void CRC_Init unsigned short *  crcvalue  ) 
 

Definition at line 92 of file l_crc.c.

Referenced by CRC_ProcessString().

00093 {
00094     *crcvalue = CRC_INIT_VALUE;
00095 } //end of the function CRC_Init

void CRC_ProcessByte unsigned short *  crcvalue,
byte  data
 

Definition at line 102 of file l_crc.c.

References byte.

00103 {
00104     *crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];
00105 } //end of the function CRC_ProcessByte

unsigned short CRC_Value unsigned short  crcvalue  ) 
 

Definition at line 112 of file l_crc.c.

Referenced by CRC_ProcessString().

00113 {
00114     return crcvalue ^ CRC_XOR_VALUE;
00115 } //end of the function CRC_Value

void CreatePath const char *  path  ) 
 

Definition at line 1146 of file cmdlib.c.

References c, memcpy(), Q_mkdir(), and toupper().

Referenced by AASOuputFile(), and QCopyFile().

01147 {
01148     const char  *ofs;
01149     char        c;
01150     char        dir[1024];
01151 
01152 #ifdef _WIN32
01153     int     olddrive = -1;
01154 
01155     if ( path[1] == ':' )
01156     {
01157         olddrive = _getdrive();
01158         _chdrive( toupper( path[0] ) - 'A' + 1 );
01159     }
01160 #endif
01161 
01162     if (path[1] == ':')
01163         path += 2;
01164 
01165     for (ofs = path+1 ; *ofs ; ofs++)
01166     {
01167         c = *ofs;
01168         if (c == '/' || c == '\\')
01169         {   // create the directory
01170             memcpy( dir, path, ofs - path );
01171             dir[ ofs - path ] = 0;
01172             Q_mkdir( dir );
01173         }
01174     }
01175 
01176 #ifdef _WIN32
01177     if ( olddrive != -1 )
01178     {
01179         _chdrive( olddrive );
01180     }
01181 #endif
01182 }

Here is the call graph for this function:

void DefaultExtension char *  path,
const char *  extension
 

Definition at line 789 of file cmdlib.c.

References src, strcat(), and strlen().

Referenced by Bspinfo(), LightMain(), LoadShaderImage(), main(), ParseShaderFile(), SaveAsDialog(), VLightMain(), and VSoundMain().

00790 {
00791     char    *src;
00792 //
00793 // if path doesnt have a .EXT, append extension
00794 // (extension should include the .)
00795 //
00796     src = path + strlen(path) - 1;
00797 
00798     while (*src != '/' && *src != '\\' && src != path)
00799     {
00800         if (*src == '.')
00801             return;                 // it has an extension
00802         src--;
00803     }
00804 
00805     strcat (path, extension);
00806 }

Here is the call graph for this function:

void DefaultPath char *  path,
const char *  basepath
 

Definition at line 809 of file cmdlib.c.

References basepath(), strcat(), and strcpy().

00810 {
00811     char    temp[128];
00812 
00813     if (path[0] == PATHSEPERATOR)
00814         return;                   // absolute path location
00815     strcpy (temp,path);
00816     strcpy (path,basepath);
00817     strcat (path,temp);
00818 }

Here is the call graph for this function:

void Error const char *  error,
  ...
 

Definition at line 143 of file cmdlib.c.

References _printf(), error(), exit(), va_end, va_list, va_start, and vprintf().

00144 {
00145     va_list argptr;
00146 
00147     _printf ("\n************ ERROR ************\n");
00148 
00149     va_start (argptr,error);
00150     vprintf (error,argptr);
00151     va_end (argptr);
00152     _printf ("\r\n");
00153 
00154     exit (1);
00155 }

Here is the call graph for this function:

char* ExpandArg const char *  path  ) 
 

Definition at line 297 of file cmdlib.c.

References Q_getwd(), strcat(), and strcpy().

Referenced by LightMain(), VisMain(), VLightMain(), and VSoundMain().

00298 {
00299     static char full[1024];
00300 
00301     if (path[0] != '/' && path[0] != '\\' && path[1] != ':')
00302     {
00303         Q_getwd (full);
00304         strcat (full, path);
00305     }
00306     else
00307         strcpy (full, path);
00308     return full;
00309 }

Here is the call graph for this function:

char* ExpandGamePath const char *  path  ) 
 

Definition at line 324 of file cmdlib.c.

References Error(), gamedir, sprintf(), and strcpy().

Referenced by LoadAlphaMap().

00325 {
00326     static char full[1024];
00327     if (!qdir)
00328         Error ("ExpandGamePath called without qdir set");
00329     if (path[0] == '/' || path[0] == '\\' || path[1] == ':') {
00330         strcpy( full, path );
00331         return full;
00332     }
00333     sprintf (full, "%s%s", gamedir, path);
00334     return full;
00335 }

Here is the call graph for this function:

char* ExpandPath const char *  path  ) 
 

Definition at line 311 of file cmdlib.c.

References Error(), qdir, sprintf(), and strcpy().

Referenced by ExpandPathAndArchive().

00312 {
00313     static char full[1024];
00314     if (!qdir)
00315         Error ("ExpandPath called without qdir set");
00316     if (path[0] == '/' || path[0] == '\\' || path[1] == ':') {
00317         strcpy( full, path );
00318         return full;
00319     }
00320     sprintf (full, "%s%s", qdir, path);
00321     return full;
00322 }

Here is the call graph for this function:

char* ExpandPathAndArchive const char *  path  ) 
 

Definition at line 337 of file cmdlib.c.

References archivedir, ExpandPath(), QCopyFile(), and sprintf().

00338 {
00339     char    *expanded;
00340     char    archivename[1024];
00341 
00342     expanded = ExpandPath (path);
00343 
00344     if (archive)
00345     {
00346         sprintf (archivename, "%s/%s", archivedir, path);
00347         QCopyFile (expanded, archivename);
00348     }
00349     return expanded;
00350 }

Here is the call graph for this function:

void ExpandWildcards int *  argc,
char ***  argv
 

Definition at line 110 of file l_cmd.c.

00111 {
00112 }

void ExtractFileBase const char *  path,
char *  dest
 

Definition at line 870 of file cmdlib.c.

References src, and strlen().

Referenced by AASOuputFile(), and main().

00871 {
00872     const char    *src;
00873 
00874     src = path + strlen(path) - 1;
00875 
00876 //
00877 // back up until a \ or the start
00878 //
00879     while (src != path && *(src-1) != PATHSEPERATOR)
00880         src--;
00881 
00882     while (*src && *src != '.')
00883     {
00884         *dest++ = *src++;
00885     }
00886     *dest = 0;
00887 }

Here is the call graph for this function:

void ExtractFileExtension const char *  path,
char *  dest
 

Definition at line 889 of file cmdlib.c.

References src, strcpy(), and strlen().

Referenced by AASOuputFile(), Load256Image(), Load32BitImage(), LoadAlphaMap(), QuakeFileType(), and Save256Image().

00890 {
00891     const char    *src;
00892 
00893     src = path + strlen(path) - 1;
00894 
00895 //
00896 // back up until a . or the start
00897 //
00898     while (src != path && *(src-1) != '.')
00899         src--;
00900     if (src == path)
00901     {
00902         *dest = 0;  // no extension
00903         return;
00904     }
00905 
00906     strcpy (dest,src);
00907 }

Here is the call graph for this function:

void ExtractFilePath const char *  path,
char *  dest
 

Definition at line 854 of file cmdlib.c.

References memcpy(), src, and strlen().

00855 {
00856     const char    *src;
00857 
00858     src = path + strlen(path) - 1;
00859 
00860 //
00861 // back up until a \ or the start
00862 //
00863     while (src != path && *(src-1) != '\\' && *(src-1) != '/')
00864         src--;
00865 
00866     memcpy (dest, path, src-path);
00867     dest[src-path] = 0;
00868 }

Here is the call graph for this function:

qboolean FileExists const char *  filename  ) 
 

Definition at line 679 of file cmdlib.c.

References f, fclose(), fopen(), and qboolean.

Referenced by LoadImageFile().

00680 {
00681     FILE    *f;
00682 
00683     f = fopen (filename, "r");
00684     if (!f)
00685         return qfalse;
00686     fclose (f);
00687     return qtrue;
00688 }

Here is the call graph for this function:

int FileTime const char *  path  ) 
 

Definition at line 434 of file cmdlib.c.

00435 {
00436     struct  stat    buf;
00437     
00438     if (stat (path,&buf) == -1)
00439         return -1;
00440     
00441     return buf.st_mtime;
00442 }

double I_FloatTime void   ) 
 

Definition at line 362 of file l_cmd.c.

00363 {
00364     time_t  t;
00365     
00366     time (&t);
00367     
00368     return t;
00369 #if 0
00370 // more precise, less portable
00371     struct timeval tp;
00372     struct timezone tzp;
00373     static int      secbase;
00374 
00375     gettimeofday(&tp, &tzp);
00376     
00377     if (!secbase)
00378     {
00379         secbase = tp.tv_sec;
00380         return tp.tv_usec/1000000.0;
00381     }
00382     
00383     return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;
00384 #endif
00385 }

float LittleFloat float  l  ) 
 

Definition at line 1065 of file l_cmd.c.

01066 {
01067     return l;
01068 }

int LittleLong int  l  ) 
 

Definition at line 1047 of file l_cmd.c.

01048 {
01049     return l;
01050 }

short LittleShort short  l  ) 
 

Definition at line 1029 of file l_cmd.c.

01030 {
01031     return l;
01032 }

int LoadFile const char *  filename,
void **  bufferptr
 

Definition at line 695 of file cmdlib.c.

References buffer, f, fclose(), length(), malloc(), Q_filelength(), SafeOpenRead(), and SafeRead().

Referenced by AddScriptToStack(), CheckBspProcess(), Eclass_ScanFile(), EndBSPFile(), FS_ReadFile(), FS_ReadFileAndCache(), HL_LoadBSPFile(), LoadBMP(), LoadBSPFile(), LoadJPG(), LoadLBM(), LoadModel(), LoadPCX(), LoadShader(), LoadShaders(), LoadTGA(), Map_ImportFile(), Map_LoadFile(), Q1_LoadBSPFile(), Q2_LoadBSPFile(), QCopyFile(), QERApp_LoadFile(), Sin_LoadBSPFile(), Texture_ForName(), Texture_ForNamePath(), and ViewShader().

00696 {
00697     FILE    *f;
00698     int    length;
00699     void    *buffer;
00700 
00701     f = SafeOpenRead (filename);
00702     length = Q_filelength (f);
00703     buffer = malloc (length+1);
00704     ((char *)buffer)[length] = 0;
00705     SafeRead (f, buffer, length);
00706     fclose (f);
00707 
00708     *bufferptr = buffer;
00709     return length;
00710 }

Here is the call graph for this function:

int LoadFileBlock const char *  filename,
void **  bufferptr
 

Definition at line 721 of file cmdlib.c.

References buffer, f, fclose(), length(), malloc(), MEM_BLOCKSIZE, memset(), Q_filelength(), SafeOpenRead(), and SafeRead().

Referenced by LoadImageFile().

00722 {
00723     FILE    *f;
00724     int    length, nBlock, nAllocSize;
00725     void    *buffer;
00726 
00727     f = SafeOpenRead (filename);
00728     length = Q_filelength (f);
00729   nAllocSize = length;
00730   nBlock = nAllocSize % MEM_BLOCKSIZE;
00731   if ( nBlock > 0) {
00732     nAllocSize += MEM_BLOCKSIZE - nBlock;
00733   }
00734     buffer = malloc (nAllocSize+1);
00735   memset(buffer, 0, nAllocSize+1);
00736     SafeRead (f, buffer, length);
00737     fclose (f);
00738 
00739     *bufferptr = buffer;
00740     return length;
00741 }

Here is the call graph for this function:

int ParseNum const char *  str  ) 
 

Definition at line 941 of file cmdlib.c.

References atol(), and ParseHex().

00942 {
00943     if (str[0] == '$')
00944         return ParseHex (str+1);
00945     if (str[0] == '0' && str[1] == 'x')
00946         return ParseHex (str+2);
00947     return atol (str);
00948 }

Here is the call graph for this function:

int Q_filelength FILE f  ) 
 

Definition at line 615 of file l_cmd.c.

References f, fseek(), ftell(), SEEK_END, and SEEK_SET.

Referenced by ASE_Load(), Bspinfo(), LoadFile(), LoadFileBlock(), LoadFileNoCrash(), LoadQuakeFile(), and TryLoadFile().

00616 {
00617     int     pos;
00618     int     end;
00619 
00620     pos = ftell (f);
00621     fseek (f, 0, SEEK_END);
00622     end = ftell (f);
00623     fseek (f, pos, SEEK_SET);
00624 
00625     return end;
00626 }

Here is the call graph for this function:

void Q_getwd char *  out  ) 
 

Definition at line 387 of file l_cmd.c.

References i, and strcat().

Referenced by ExpandArg(), and SetQdirFromPath().

00388 {
00389 #if defined(WIN32) || defined(_WIN32)
00390    getcwd (out, 256);
00391    strcat (out, "\\");
00392 #else
00393    getwd(out);
00394    strcat(out, "/");
00395 #endif
00396 }

Here is the call graph for this function:

void Q_mkdir const char *  path  ) 
 

Definition at line 414 of file cmdlib.c.

References errno, Error(), and strerror().

Referenced by CreatePath().

00415 {
00416 #ifdef WIN32
00417     if (_mkdir (path) != -1)
00418         return;
00419 #else
00420     if (mkdir (path, 0777) != -1)
00421         return;
00422 #endif
00423     if (errno != EEXIST)
00424         Error ("mkdir %s: %s",path, strerror(errno));
00425 }

Here is the call graph for this function:

int Q_stricmp const char *  s1,
const char *  s2
 

Definition at line 785 of file q_shared.c.

00785                                                {
00786     return (s1 && s2) ? Q_stricmpn (s1, s2, 99999) : -1;
00787 }

int Q_strncasecmp const char *  s1,
const char *  s2,
int  n
 

Definition at line 527 of file cmdlib.c.

References n.

Referenced by HL_TextureContents(), ParseShaderFile(), ParseTerrain(), Q1_TextureContents(), Q_strcasecmp(), Q_stricmp(), SetLightStyles(), and SetQdirFromPath().

00528 {
00529     int     c1, c2;
00530     
00531     do
00532     {
00533         c1 = *s1++;
00534         c2 = *s2++;
00535 
00536         if (!n--)
00537             return 0;       // strings are equal until end point
00538         
00539         if (c1 != c2)
00540         {
00541             if (c1 >= 'a' && c1 <= 'z')
00542                 c1 -= ('a' - 'A');
00543             if (c2 >= 'a' && c2 <= 'z')
00544                 c2 -= ('a' - 'A');
00545             if (c1 != c2)
00546                 return -1;      // strings not equal
00547         }
00548     } while (c1);
00549     
00550     return 0;       // strings are equal
00551 }

void QCopyFile const char *  from,
const char *  to
 

Definition at line 1192 of file cmdlib.c.

References buffer, CreatePath(), free(), length(), LoadFile(), and SaveFile().

Referenced by ExpandPathAndArchive().

01193 {
01194     void    *buffer;
01195     int     length;
01196 
01197     length = LoadFile (from, &buffer);
01198     CreatePath (to);
01199     SaveFile (to, buffer, length);
01200     free (buffer);
01201 }

Here is the call graph for this function:

void qprintf const char *  format,
  ...
 

Definition at line 160 of file cmdlib.c.

References format, va_end, va_list, va_start, and vprintf().

Referenced by AAS_CreateArea(), AAS_CreateAreas(), AAS_CreateAreaSettings(), AAS_CreateCurveBrushes(), AAS_FlipSharedFaces(), AAS_GravitationalSubdivision(), AAS_LadderSubdivideArea_r(), AAS_LadderSubdivision(), AAS_MeltAreaFaceWindings(), AAS_MergeAreaFaces(), AAS_MergeAreaPlaneFaces(), AAS_MergeAreas(), AAS_PrintNumGroundFaces(), AAS_StoreFile(), AAS_SubdivideArea_r(), AddTriangleModels(), AllocateLightmaps(), ArrayUsage(), BrushBSP(), BuildTree(), BuildTree_r(), ChopBrushes(), ClipSidesIntoTree(), ClusterMerge(), CountLightmaps(), CreateSurfaceLights(), EndModel(), FaceBSP(), FillOutside(), FilterDetailBrushesIntoTree(), FilterDrawsurfsIntoTree(), FilterStructuralBrushesIntoTree(), FixTjuncs(), FixTJunctions(), FloodAreas(), FloodEntities(), FogDrawSurfs(), GlobUsage(), HL_CreateBrushes_r(), HL_CreateBrushesFromBSP(), HL_CreateMapBrushes(), HL_LoadMapFromBSP(), HL_MergeBrushes(), HL_PrintBSPFileSizes(), HL_TextureBrushes(), IncreaseNodeCounter(), LeakFile(), LightWorld(), LoadMapFile(), LoadShaderInfo(), MakeFaces(), MakeTreePortals(), MakeTreePortals_r(), MergeBrushes(), MergeSides(), NumberClusters(), PatchMapDrawSurfs(), PortalFlow(), ProcessModels(), Q1_CreateBrushes_r(), Q1_CreateBrushesFromBSP(), Q1_CreateMapBrushes(), Q1_LoadMapFromBSP(), Q1_MergeBrushes(), Q1_TextureBrushes(), Q3_FindVisibleBrushSides(), SetBrushContents(), SetQdirFromPath(), SetupGrid(), SplitBrush(), SplitMeshByPlane(), SubdivideDrawSurfs(), TH_TetrahedralDecomposition(), VL_TestLightLeafs(), VS_TestLightLeafs(), WriteBrushList(), WriteBSP(), and WritePortalFile().

00160                                         {
00161     va_list argptr;
00162 
00163     if (!verbose)
00164         return;
00165 
00166     va_start (argptr,format);
00167     vprintf (format,argptr);
00168     va_end (argptr);
00169 
00170 }

Here is the call graph for this function:

FILE* SafeOpenRead const char *  filename  ) 
 

Definition at line 647 of file cmdlib.c.

References errno, Error(), f, fopen(), and strerror().

Referenced by LoadFile(), LoadFileBlock(), LoadQuakeFile(), and ReadQuakeFile().

00648 {
00649     FILE    *f;
00650 
00651     f = fopen(filename, "rb");
00652 
00653     if (!f)
00654         Error ("Error opening %s: %s",filename,strerror(errno));
00655 
00656     return f;
00657 }

Here is the call graph for this function:

FILE* SafeOpenWrite const char *  filename  ) 
 

Definition at line 635 of file cmdlib.c.

References errno, Error(), f, fopen(), and strerror().

Referenced by FS_FOpenFileWrite(), HL_WriteBSPFile(), Q1_WriteBSPFile(), Q2_WriteBSPFile(), Q3_WriteBSPFile(), SaveFile(), Sin_WriteBSPFile(), WriteBrushList(), and WriteBSPFile().

00636 {
00637     FILE    *f;
00638 
00639     f = fopen(filename, "wb");
00640 
00641     if (!f)
00642         Error ("Error opening %s: %s",filename,strerror(errno));
00643 
00644     return f;
00645 }

Here is the call graph for this function:

void SafeRead FILE f,
void *  buffer,
int  count
 

Definition at line 654 of file l_cmd.c.

References buffer, count, Error(), f, and fread().

Referenced by LoadFile(), LoadFileBlock(), LoadFileNoCrash(), LoadQuakeFile(), ReadQuakeFile(), and TryLoadFile().

00655 {
00656     if ( fread (buffer, 1, count, f) != (size_t)count)
00657         Error ("File read failure");
00658 }

Here is the call graph for this function:

void SafeWrite FILE f,
const void *  buffer,
int  count
 

Definition at line 667 of file cmdlib.c.

References buffer, count, Error(), f, and fwrite().

Referenced by AddLump(), FS_Write(), HL_AddLump(), HL_WriteBSPFile(), Q1_AddLump(), Q1_WriteBSPFile(), Q2_AddLump(), Q2_WriteBSPFile(), Q3_AddLump(), Q3_WriteBSPFile(), SaveFile(), Sin_AddLump(), Sin_WriteBSPFile(), and WriteBSPFile().

00668 {
00669     if (fwrite (buffer, 1, count, f) != (size_t)count)
00670         Error ("File write failure");
00671 }

Here is the call graph for this function:

void SaveFile const char *  filename,
const void *  buffer,
int  count
 

Definition at line 778 of file cmdlib.c.

References buffer, count, f, fclose(), SafeOpenWrite(), and SafeWrite().

Referenced by QCopyFile(), WriteLBMfile(), and WritePCXfile().

00779 {
00780     FILE    *f;
00781 
00782     f = SafeOpenWrite (filename);
00783     SafeWrite (f, buffer, count);
00784     fclose (f);
00785 }

Here is the call graph for this function:

void SetQdirFromPath const char *  path  ) 
 

Definition at line 220 of file cmdlib.c.

References BASEDIRNAME, c, count, Error(), gamedir, i, Q_getwd(), Q_strncasecmp(), qdir, qprintf(), strcat(), strcpy(), strlen(), strncpy(), and writedir.

Referenced by LightMain(), main(), VisMain(), VLightMain(), and VSoundMain().

00221 {
00222     char    temp[1024];
00223     const char  *c;
00224   const char *sep;
00225     int     len, count;
00226 
00227     if (!(path[0] == '/' || path[0] == '\\' || path[1] == ':'))
00228     {   // path is partial
00229         Q_getwd (temp);
00230         strcat (temp, path);
00231         path = temp;
00232     }
00233 
00234     // search for "quake2" in path
00235 
00236     len = strlen(BASEDIRNAME);
00237     for (c=path+strlen(path)-1 ; c != path ; c--)
00238     {
00239         int i;
00240 
00241         if (!Q_strncasecmp (c, BASEDIRNAME, len))
00242         {
00243       //
00244             //strncpy (qdir, path, c+len+2-path);
00245       // the +2 assumes a 2 or 3 following quake which is not the
00246       // case with a retail install
00247       // so we need to add up how much to the next separator
00248       sep = c + len;
00249       count = 1;
00250       while (*sep && *sep != '/' && *sep != '\\')
00251       {
00252         sep++;
00253         count++;
00254       }
00255             strncpy (qdir, path, c+len+count-path);
00256             qprintf ("qdir: %s\n", qdir);
00257             for ( i = 0; i < strlen( qdir ); i++ )
00258             {
00259                 if ( qdir[i] == '\\' ) 
00260                     qdir[i] = '/';
00261             }
00262 
00263             c += len+count;
00264             while (*c)
00265             {
00266                 if (*c == '/' || *c == '\\')
00267                 {
00268                     strncpy (gamedir, path, c+1-path);
00269 
00270                     for ( i = 0; i < strlen( gamedir ); i++ )
00271                     {
00272                         if ( gamedir[i] == '\\' ) 
00273                             gamedir[i] = '/';
00274                     }
00275 
00276                     qprintf ("gamedir: %s\n", gamedir);
00277 
00278                     if ( !writedir[0] )
00279                         strcpy( writedir, gamedir );
00280                     else if ( writedir[strlen( writedir )-1] != '/' )
00281                     {
00282                         writedir[strlen( writedir )] = '/';
00283                         writedir[strlen( writedir )+1] = 0;
00284                     }
00285 
00286                     return;
00287                 }
00288                 c++;
00289             }
00290             Error ("No gamedir in %s", path);
00291             return;
00292         }
00293     }
00294     Error ("SetQdirFromPath: no '%s' in %s", BASEDIRNAME, path);
00295 }

Here is the call graph for this function:

void StripExtension char *  path  ) 
 

Definition at line 794 of file l_cmd.c.

References length(), and strlen().

Referenced by AAS_Create(), DemandLoadShaderTexture(), LightMain(), main(), Map_SaveFile(), Pointfile_Check(), Pointfile_Delete(), RunBsp(), SetNameShaderInfo(), ShaderInfoForShader(), Texture_ForName(), Texture_ForNamePath(), Texture_LoadTGATexture(), Texture_ShowDirectory(), VisMain(), VLightMain(), and VSoundMain().

00795 {
00796     int             length;
00797 
00798     length = strlen(path)-1;
00799     while (length > 0 && path[length] != '.')
00800     {
00801         length--;
00802         if (path[length] == '/')
00803             return;     // no extension
00804     }
00805     if (length)
00806         path[length] = 0;
00807 }

Here is the call graph for this function:

void StripFilename char *  path  ) 
 

Definition at line 784 of file l_cmd.c.

References length(), and strlen().

00785 {
00786     int             length;
00787 
00788     length = strlen(path)-1;
00789     while (length > 0 && path[length] != PATHSEPERATOR)
00790         length--;
00791     path[length] = 0;
00792 }

Here is the call graph for this function:

char* strlower char *  in  ) 
 

Definition at line 565 of file l_cmd.c.

References in, and tolower().

00566 {
00567     char    *in;
00568     in = start;
00569     while (*in)
00570     {
00571         *in = tolower(*in); 
00572         in++;
00573     }
00574     return start;
00575 }

Here is the call graph for this function:

char* strupr char *  in  ) 
 

Definition at line 553 of file l_cmd.c.

References in, and toupper().

00554 {
00555     char    *in;
00556     in = start;
00557     while (*in)
00558     {
00559         *in = toupper(*in);
00560         in++;
00561     }
00562     return start;
00563 }

Here is the call graph for this function:

int TryLoadFile const char *  filename,
void **  bufferptr
 

Definition at line 751 of file cmdlib.c.

References buffer, f, fclose(), fopen(), length(), malloc(), Q_filelength(), and SafeRead().

Referenced by FindMiptex(), and R_LoadMD3().

00752 {
00753     FILE    *f;
00754     int    length;
00755     void    *buffer;
00756 
00757     *bufferptr = NULL;
00758 
00759     f = fopen (filename, "rb");
00760     if (!f)
00761         return -1;
00762     length = Q_filelength (f);
00763     buffer = malloc (length+1);
00764     ((char *)buffer)[length] = 0;
00765     SafeRead (f, buffer, length);
00766     fclose (f);
00767 
00768     *bufferptr = buffer;
00769     return length;
00770 }

Here is the call graph for this function:


Variable Documentation

qboolean archive
 

Definition at line 55 of file l_cmd.c.

char archivedir[1024]
 

Definition at line 56 of file l_cmd.c.

qboolean com_eof
 

Definition at line 53 of file l_cmd.c.

char com_token[1024]
 

Definition at line 52 of file l_cmd.c.

char gamedir[1024]
 

Definition at line 266 of file l_cmd.c.

int myargc
 

Definition at line 49 of file l_cmd.c.

char** myargv
 

Definition at line 50 of file l_cmd.c.

char qdir[1024]
 

Definition at line 265 of file l_cmd.c.

qboolean verbose
 

Definition at line 210 of file l_cmd.c.

char writedir[1024]
 

Definition at line 218 of file cmdlib.c.


Generated on Thu Aug 25 15:46:00 2005 for Quake III Arena by  doxygen 1.3.9.1