/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
// Nurail: Swiped from quake3/common
#include "cmdlib.h"
+#include "globaldefs.h"
#include "mathlib.h"
#include "inout.h"
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <direct.h>
#include <windows.h>
-#endif
-
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#elif GDEF_OS_NEXT
+#include <libc.h>
+#else // OTHER OSES
#include <unistd.h>
-#endif
+#endif // OTHER OSES
-#ifdef NeXT
-#include <libc.h>
-#endif
+#if !GDEF_OS_WINDOWS
+#define strlwr strlower
+#endif // !GDEF_OS_WINDOWS
#define BASEDIRNAME "h"
-#define PATHSEPERATOR '/'
+#define PATHSEPERATOR '/'
extern qboolean verbose;
return p;
}
-#endif
+#endif // !SAFE_MALLOC
void *SafeMalloc( size_t n, char *desc ){
void *p;
return p;
}
-#if defined ( __linux__ ) || defined ( __APPLE__ )
-void strlwr( char *conv_str ){
- int i;
-
- for ( i = 0; i < strlen( conv_str ); i++ )
- conv_str[i] = tolower( conv_str[i] );
-}
-#endif
-
-
// set these before calling CheckParm
int myargc;
char **myargv;
===================
*/
#define MAX_EX_ARGC 1024
+
int ex_argc;
char *ex_argv[MAX_EX_ARGC];
-#ifdef _WIN32
+
+#if GDEF_OS_WINDOWS
#include "io.h"
void ExpandWildcards( int *argc, char ***argv ){
struct _finddata_t fileinfo;
*argc = ex_argc;
*argv = ex_argv;
}
-#else
+#else // !GDEF_OS_WINDOWS
void ExpandWildcards( int *argc, char ***argv ){
}
-#endif
+#endif // !GDEF_OS_WINDOWS
/*
void Q_getwd( char *out ){
int i = 0;
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
_getcwd( out, 256 );
strcat( out, "\\" );
-#else
+#else // !GDEF_OS_WINDOWS
// Gef: Changed from getwd() to getcwd() to avoid potential buffer overflow
getcwd( out, 256 );
strcat( out, "/" );
-#endif
+#endif // !GDEF_OS_WINDOWS
while ( out[i] != 0 )
{
if ( out[i] == '\\' ) {
void Q_mkdir( const char *path ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
if ( _mkdir( path ) != -1 ) {
return;
}
-#else
+#else // !GDEF_OS_WINDOWS
if ( mkdir( path, 0777 ) != -1 ) {
return;
}
-#endif
+#endif // !GDEF_OS_WINDOWS
if ( errno != EEXIST ) {
Error( "mkdir %s: %s",path, strerror( errno ) );
}
Extract file parts
====================
*/
+
// FIXME: should include the slash, otherwise
// backing to an empty path will be wrong when appending a slash
void ExtractFilePath( const char *path, char *dest ){
============================================================================
*/
-#ifdef _SGI_SOURCE
-#define __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
short LittleShort( short l ){
byte b1,b2;
}
-#else
+#else // !GDEF_ARCH_ENDIAN_BIG
short BigShort( short l ){
return l;
}
-
-#endif
+#endif // ! GDEF_ARCH_ENDIAN_BIG
//=======================================================
char c;
char dir[1024];
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
int olddrive = -1;
if ( path[1] == ':' ) {
olddrive = _getdrive();
_chdrive( toupper( path[0] ) - 'A' + 1 );
}
-#endif
+#endif // !GDEF_OS_WINDOWS
if ( path[1] == ':' ) {
path += 2;
}
}
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
if ( olddrive != -1 ) {
_chdrive( olddrive );
}
-#endif
+#endif // !GDEF_OS_WINDOWS
}
}
void Sys_Sleep( int n ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
Sleep( n );
-#endif
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#else // !GDEF_OS_WINDOWS
usleep( n * 1000 );
-#endif
+#endif // !GDEF_OS_WINDOWS
}