Some fixes, enhancements for environment handling.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1424 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -37,7 +37,8 @@ uqm_requirements()
|
|||||||
have_library vorbisfile || exit 1
|
have_library vorbisfile || exit 1
|
||||||
|
|
||||||
|
|
||||||
# Add defines for HAVE_STRUPR and STRICMP
|
# Add defines for HAVE_SETENV, HAVE_STRUPR and HAVE_STRICMP
|
||||||
|
define_have_symbol setenv
|
||||||
define_have_symbol strupr
|
define_have_symbol strupr
|
||||||
define_have_symbol stricmp
|
define_have_symbol stricmp
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,17 @@
|
|||||||
#define CONFIGDIR USERDIR
|
#define CONFIGDIR USERDIR
|
||||||
|
|
||||||
/* Directory where supermelee teams will be stored */
|
/* Directory where supermelee teams will be stored */
|
||||||
#define MELEEDIR "${UQM_CONFIG_DIR}/teams/"
|
#define MELEEDIR "${UQM_CONFIG_DIR}teams/"
|
||||||
|
|
||||||
/* Directory where save games will be stored */
|
/* Directory where save games will be stored */
|
||||||
#define SAVEDIR "${UQM_CONFIG_DIR}/save/"
|
#define SAVEDIR "${UQM_CONFIG_DIR}save/"
|
||||||
|
|
||||||
/* Defined if words are stored with the most significant byte first */
|
/* Defined if words are stored with the most significant byte first */
|
||||||
@WORDS_BIGENDIAN@
|
@WORDS_BIGENDIAN@
|
||||||
|
|
||||||
|
/* Defined if your system has setenv of its own */
|
||||||
|
@HAVE_SETENV@
|
||||||
|
|
||||||
/* Defined if your system has strupr of its own */
|
/* Defined if your system has strupr of its own */
|
||||||
@HAVE_STRUPR@
|
@HAVE_STRUPR@
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#define _CONFIG_H
|
#define _CONFIG_H
|
||||||
|
|
||||||
/* Directory where the UQM game data is located */
|
/* Directory where the UQM game data is located */
|
||||||
#define CONTENTDIR "../content"
|
#define CONTENTDIR "../content/"
|
||||||
|
|
||||||
/* Directory where game data will be stored */
|
/* Directory where game data will be stored */
|
||||||
//#define USERDIR "../userdata/"
|
//#define USERDIR "../userdata/"
|
||||||
@@ -19,14 +19,17 @@
|
|||||||
#define CONFIGDIR USERDIR
|
#define CONFIGDIR USERDIR
|
||||||
|
|
||||||
/* Directory where supermelee teams will be stored */
|
/* Directory where supermelee teams will be stored */
|
||||||
#define MELEEDIR "%UQM_CONFIG_DIR%/teams/"
|
#define MELEEDIR "%UQM_CONFIG_DIR%teams/"
|
||||||
|
|
||||||
/* Directory where save games will be stored */
|
/* Directory where save games will be stored */
|
||||||
#define SAVEDIR "%UQM_CONFIG_DIR%/save/"
|
#define SAVEDIR "%UQM_CONFIG_DIR%save/"
|
||||||
|
|
||||||
/* Define if words are stored with the most significant byte first */
|
/* Define if words are stored with the most significant byte first */
|
||||||
#undef WORDS_BIGENDIAN
|
#undef WORDS_BIGENDIAN
|
||||||
|
|
||||||
|
/* Defined if your system has setenv of its own */
|
||||||
|
#define HAVE_SETENV
|
||||||
|
|
||||||
/* Defined if your system has strupr of its own */
|
/* Defined if your system has strupr of its own */
|
||||||
#define HAVE_STRUPR
|
#define HAVE_STRUPR
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
|
|
||||||
#ifndef HAVE_STRUPR
|
#ifndef HAVE_STRUPR
|
||||||
@@ -40,3 +41,41 @@ strupr (char *str)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_SETENV
|
||||||
|
int
|
||||||
|
setenv (const char *name, const char *value, int overwrite)
|
||||||
|
{
|
||||||
|
char *string, *ptr;
|
||||||
|
size_t nameLen, valueLen;
|
||||||
|
|
||||||
|
if (!overwrite)
|
||||||
|
{
|
||||||
|
char *old;
|
||||||
|
|
||||||
|
old = getenv (name);
|
||||||
|
if (old != NULL)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nameLen = strlen (name);
|
||||||
|
valueLen = strlen (value);
|
||||||
|
|
||||||
|
string = malloc (nameLen + valueLen + 2);
|
||||||
|
// "NAME=VALUE\0"
|
||||||
|
// putenv() does NOT make a copy, but uses the string passed.
|
||||||
|
|
||||||
|
ptr = string;
|
||||||
|
|
||||||
|
strcpy (string, name);
|
||||||
|
ptr += nameLen;
|
||||||
|
|
||||||
|
*ptr = '=';
|
||||||
|
ptr++;
|
||||||
|
|
||||||
|
strcpy (ptr, value);
|
||||||
|
|
||||||
|
return putenv (string);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -98,5 +98,11 @@ typedef unsigned short mode_t;
|
|||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// setenv()
|
||||||
|
#ifndef HAVE_SETENV
|
||||||
|
int setenv (const char *name, const char *value, int overwrite);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _PORT_H */
|
#endif /* _PORT_H */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -335,10 +335,14 @@ expandPath (char *dest, size_t len, const char *src, int what)
|
|||||||
envVar = getenv (envName);
|
envVar = getenv (envName);
|
||||||
HFree (envName);
|
HFree (envName);
|
||||||
|
|
||||||
|
if (envVar != NULL)
|
||||||
|
{
|
||||||
envVarLen = strlen (envVar);
|
envVarLen = strlen (envVar);
|
||||||
CHECKLEN (buf, envVarLen);
|
CHECKLEN (buf, envVarLen);
|
||||||
memcpy (bufptr, envVar, envVarLen);
|
memcpy (bufptr, envVar, envVarLen);
|
||||||
bufptr += envVarLen;
|
bufptr += envVarLen;
|
||||||
|
}
|
||||||
|
|
||||||
src = end;
|
src = end;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user