22 #if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS) 23 #define SDL_DISABLE_ANALYZE_MACROS 1 26 #include "../SDL_internal.h" 28 #if defined(__WIN32__) 29 #include "../core/windows/SDL_windows.h" 32 #if defined(__ANDROID__) 33 #include "../core/android/SDL_android.h" 38 #if defined(__WIN32__) && (!defined(HAVE_SETENV) || !defined(HAVE_GETENV)) 40 static char *SDL_envmem =
NULL;
41 static size_t SDL_envmemlen = 0;
46 #if defined(HAVE_SETENV) 55 return setenv(name, value, overwrite);
57 #elif defined(__WIN32__) 59 SDL_setenv(
const char *name,
const char *value,
int overwrite)
67 if (GetEnvironmentVariableA(name,
NULL, 0) > 0) {
71 if (!SetEnvironmentVariableA(name, *value ? value :
NULL)) {
77 #elif (defined(HAVE_GETENV) && defined(HAVE_PUTENV) && !defined(HAVE_SETENV)) 79 SDL_setenv(
const char *name,
const char *value,
int overwrite)
89 if (getenv(name) !=
NULL) {
105 return putenv(new_variable);
110 SDL_setenv(
const char *name,
const char *value,
int overwrite)
143 len = (value -
name);
144 for (; SDL_env[
i]; ++
i) {
152 SDL_env[
i] = new_variable;
159 new_env =
SDL_realloc(SDL_env, (i + 2) *
sizeof(
char *));
162 SDL_env[i++] = new_variable;
163 SDL_env[i++] = (
char *) 0;
169 return (added ? 0 : -1);
174 #if defined(HAVE_GETENV) 178 #if defined(__ANDROID__) 184 if (!name || !*name) {
190 #elif defined(__WIN32__) 202 GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen);
203 if (bufferlen == 0) {
206 if (bufferlen > SDL_envmemlen) {
207 char *newmem = (
char *)
SDL_realloc(SDL_envmem, bufferlen);
208 if (newmem ==
NULL) {
212 SDL_envmemlen = bufferlen;
213 GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen);
232 for (i = 0; SDL_env[
i] && !
value; ++
i) {
234 (SDL_env[i][len] ==
'=')) {
235 value = &SDL_env[
i][len + 1];
248 main(
int argc,
char *argv[])
252 printf(
"Checking for non-existent variable... ");
259 printf(
"Setting FIRST=VALUE1 in the environment... ");
266 printf(
"Getting FIRST from the environment... ");
269 if (value && (
SDL_strcmp(value,
"VALUE1") == 0)) {
274 printf(
"Setting SECOND=VALUE2 in the environment... ");
281 printf(
"Getting SECOND from the environment... ");
284 if (value && (
SDL_strcmp(value,
"VALUE2") == 0)) {
289 printf(
"Setting FIRST=NOVALUE in the environment... ");
296 printf(
"Getting FIRST from the environment... ");
299 if (value && (
SDL_strcmp(value,
"NOVALUE") == 0)) {
304 printf(
"Checking for non-existent variable... ");
char * SDL_getenv(const char *name)
GLuint const GLchar * name
int SDL_setenv(const char *name, const char *value, int overwrite)
GLsizei const GLfloat * value
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
void Android_JNI_GetManifestEnvironmentVariables(void)