|
@@ -50,6 +50,9 @@ extern char **environ;
|
|
static char **environ;
|
|
static char **environ;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_FREEBSD)
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+#endif
|
|
|
|
|
|
struct SDL_Environment
|
|
struct SDL_Environment
|
|
{
|
|
{
|
|
@@ -149,6 +152,9 @@ SDL_Environment *SDL_CreateEnvironment(bool populated)
|
|
|
|
|
|
const char *SDL_GetEnvironmentVariable(SDL_Environment *env, const char *name)
|
|
const char *SDL_GetEnvironmentVariable(SDL_Environment *env, const char *name)
|
|
{
|
|
{
|
|
|
|
+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_FREEBSD)
|
|
|
|
+ return getenv(name);
|
|
|
|
+#else
|
|
const char *result = NULL;
|
|
const char *result = NULL;
|
|
|
|
|
|
if (!env) {
|
|
if (!env) {
|
|
@@ -168,6 +174,7 @@ const char *SDL_GetEnvironmentVariable(SDL_Environment *env, const char *name)
|
|
SDL_UnlockMutex(env->lock);
|
|
SDL_UnlockMutex(env->lock);
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
|
|
typedef struct CountEnvStringsData
|
|
typedef struct CountEnvStringsData
|
|
@@ -246,6 +253,9 @@ char **SDL_GetEnvironmentVariables(SDL_Environment *env)
|
|
|
|
|
|
bool SDL_SetEnvironmentVariable(SDL_Environment *env, const char *name, const char *value, bool overwrite)
|
|
bool SDL_SetEnvironmentVariable(SDL_Environment *env, const char *name, const char *value, bool overwrite)
|
|
{
|
|
{
|
|
|
|
+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_FREEBSD)
|
|
|
|
+ return setenv(name, value, overwrite);
|
|
|
|
+#else
|
|
bool result = false;
|
|
bool result = false;
|
|
|
|
|
|
if (!env) {
|
|
if (!env) {
|
|
@@ -281,10 +291,14 @@ bool SDL_SetEnvironmentVariable(SDL_Environment *env, const char *name, const ch
|
|
SDL_UnlockMutex(env->lock);
|
|
SDL_UnlockMutex(env->lock);
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
|
|
bool SDL_UnsetEnvironmentVariable(SDL_Environment *env, const char *name)
|
|
bool SDL_UnsetEnvironmentVariable(SDL_Environment *env, const char *name)
|
|
{
|
|
{
|
|
|
|
+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_FREEBSD)
|
|
|
|
+ return unsetenv(name);
|
|
|
|
+#else
|
|
bool result = false;
|
|
bool result = false;
|
|
|
|
|
|
if (!env) {
|
|
if (!env) {
|
|
@@ -305,6 +319,7 @@ bool SDL_UnsetEnvironmentVariable(SDL_Environment *env, const char *name)
|
|
SDL_UnlockMutex(env->lock);
|
|
SDL_UnlockMutex(env->lock);
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
|
|
void SDL_DestroyEnvironment(SDL_Environment *env)
|
|
void SDL_DestroyEnvironment(SDL_Environment *env)
|