( *pp )->texInfo.m_texdef.scale[0], ( *pp )->texInfo.m_texdef.scale[0],
( *pp )->texInfo.m_texdef.rotate );
- fprintf( pFile, buffer );
+ fprintf( pFile, "%s", buffer );
}
fprintf( pFile, "}\n" );
const idVec3 *idSplineList::getPosition( long t ) {
static idVec3 interpolatedPos;
- static long lastTime = -1;
int count = splineTime.Num();
if ( count == 0 ) {
void idCameraDef::buildCamera() {
int i;
- int lastSwitch = 0;
idList<float> waits;
idList<int> targets;
// we have a base time layout for the path and the target path
// now we need to layer on any wait or speed changes
for ( i = 0; i < events.Num(); i++ ) {
- idCameraEvent *ev = events[i];
events[i]->setTriggered( false );
switch ( events[i]->getType() ) {
case idCameraEvent::EVENT_TARGET: {
bool idCameraDef::load( const char *filename ) {
char *buf;
const char *buf_p;
- int length = FS_ReadFile( filename, (void **)&buf );
+
+ FS_ReadFile( filename, (void **)&buf );
if ( !buf ) {
return false;
}
}
void idCameraDef::addTarget( const char *name, idCameraPosition::positionType type ) {
- const char *text = ( name == NULL ) ? va( "target0%d", numTargets() + 1 ) : name;
idCameraPosition *pos = newFromType( type );
if ( pos ) {
pos->setName( name );
i = a.length(); // i == 0
i = c.length(); // i == 4
- const char *s1 = a.c_str(); // s1 == "\0"
- const char *s2 = c.c_str(); // s2 == "test\0"
-
t = new idStr(); // t->len == 0, t->data == "\0"
delete t; // t == ?
char *ExpandPath( const char *path ){
static char full[1024];
- if ( !*qdir || path[0] == '/' || path[0] == '\\' || path[1] == ':' ) {
+ if ( !qdir ) {
+ Error( "ExpandPath called without qdir set" );
+ }
+ if ( path[0] == '/' || path[0] == '\\' || path[1] == ':' ) {
strcpy( full, path );
return full;
}
char *ExpandGamePath( const char *path ){
static char full[1024];
- if ( !*gamedir ) {
+ if ( !gamedir[0] ) {
Error( "ExpandGamePath called without gamedir set" );
}
if ( path[0] == '/' || path[0] == '\\' || path[1] == ':' ) {
#ifdef PATH_MAX
#define MAX_OS_PATH PATH_MAX
#else
-#define MAX_OS_PATH 1024
+#define MAX_OS_PATH 4096
#endif
#define MEM_BLOCKSIZE 4096
#include "libxml/tree.h"
// utf8 conversion
+#include <glib.h>
#include <glib/gconvert.h>
#include <glib/gmem.h>
}
+char *Q_strncpyz( char *dst, const char *src, size_t len ) {
+ if ( len == 0 ) {
+ abort();
+ }
+
+ strncpy( dst, src, len );
+ dst[ len - 1 ] = '\0';
+ return dst;
+}
+
+
+char *Q_strcat( char *dst, size_t dlen, const char *src ) {
+ size_t n = strlen( dst );
+
+ if ( n > dlen ) {
+ abort(); /* buffer overflow */
+ }
+
+ return Q_strncpyz( dst + n, src, dlen - n );
+}
+
+
+char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen ) {
+ size_t n = strlen( dst );
+
+ if ( n > dlen ) {
+ abort(); /* buffer overflow */
+ }
+
+ return Q_strncpyz( dst + n, src, MIN( slen, dlen - n ) );
+}
+
/*
ExitQ3Map()
#ifndef Q_UNIX
return NULL;
#else
+ static char buf[ 4096 ];
+ struct passwd pw, *pwp;
char *home;
- uid_t id;
- struct passwd *pwd;
static char homeBuf[MAX_OS_PATH];
/* get the home environment variable */
home = getenv( "HOME" );
- if ( home == NULL ) {
- /* do some more digging */
- id = getuid();
- setpwent();
- while ( ( pwd = getpwent() ) != NULL )
- {
- if ( pwd->pw_uid == id ) {
- home = pwd->pw_dir;
- break;
- }
+
+ /* look up home dir in password database */
+ if(!home)
+ {
+ if ( getpwuid_r( getuid(), &pw, buf, sizeof( buf ), &pwp ) == 0 ) {
+ return pw.pw_dir;
}
- endpwent();
}
snprintf( homeBuf, sizeof( homeBuf ), "%s/.", home );
qboolean found;
+ path = getenv( "PATH" );
+
/* do some path divining */
- strcpy( temp, argv0 );
- if ( strrchr( argv0, '/' ) ) {
+ Q_strncpyz( temp, argv0, sizeof( temp ) );
+ if ( strrchr( temp, '/' ) ) {
argv0 = strrchr( argv0, '/' ) + 1;
}
- else
- {
- /* get path environment variable */
- path = getenv( "PATH" );
-
- /* minor setup */
- last = last0;
- last[ 0 ] = path[ 0 ];
- last[ 1 ] = '\0';
+ else if ( path ) {
found = qfalse;
+ last = path;
/* go through each : segment of path */
while ( last[ 0 ] != '\0' && found == qfalse )
/* found home dir candidate */
if ( *path == '~' ) {
- strcpy( temp, home );
+ Q_strncpyz( temp, home, sizeof( temp ) );
path++;
}
/* concatenate */
if ( last > ( path + 1 ) ) {
- strncat( temp, path, ( last - path ) );
- strcat( temp, "/" );
+ Q_strncat( temp, sizeof( temp ), path, ( last - path ) );
+ Q_strcat( temp, sizeof( temp ), "/" );
}
- strcat( temp, "./" );
- strcat( temp, argv0 );
+ Q_strcat( temp, sizeof( temp ), "./" );
+ Q_strcat( temp, sizeof( temp ), argv0 );
/* verify the path */
if ( access( temp, X_OK ) == 0 ) {
#include "md4.h"
#include <stdlib.h>
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
/* -------------------------------------------------------------------------------
/* main.c */
vec_t Random( void );
+char *Q_strncpyz( char *dst, const char *src, size_t len );
+char *Q_strcat( char *dst, size_t dlen, const char *src );
+char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen );
int BSPInfo( int count, char **fileNames );
int ScaleBSPMain( int argc, char **argv );
int ConvertMain( int argc, char **argv );