diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-07-21 13:26:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-07-21 13:26:28 +0400 |
commit | 0ebf23c0b8de670ea856757f6950c515efd87a71 (patch) | |
tree | 12b1b3127bbcdd831d7a68e985992f488113c8b3 /source/blender/blenlib | |
parent | ca466dc8d825e06255e4b76507dbb5e052ede693 (diff) |
BLI_setenv, use instead of copying ifdefs about for setting env vars.
set PYTHONHOME as well as PYTHONPATH, quiets some warnings.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_util.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/util.c | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_util.h b/source/blender/blenlib/BLI_util.h index d323f701ba5..f9a84e071e7 100644 --- a/source/blender/blenlib/BLI_util.h +++ b/source/blender/blenlib/BLI_util.h @@ -43,6 +43,7 @@ struct direntry; char *BLI_gethome(void); char *BLI_gethome_folder(char *folder_name); +void BLI_setenv(const char *env, const char *val); void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file); void BLI_make_exist(char *dir); diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index 8eeca6900a1..3c441a81d6b 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -951,6 +951,24 @@ char *BLI_gethome_folder(char *folder_name) return NULL; } +void BLI_setenv(const char *env, const char*val) +{ + /* SGI or free windows */ +#if (defined(__sgi) || ((defined(WIN32) || defined(WIN64)) && defined(FREE_WINDOWS))) + char *envstr= malloc(sizeof(char) * (strlen(env) + strlen(val) + 2)); /* one for = another for \0 */ + + sprintf(envstr, "%s=%s", env, val); + putenv(envstr); + free(envstr); + + /* non-free windows */ +#elif (defined(WIN32) || defined(WIN64)) /* not free windows */ + _putenv_s(env, val); +#else + /* linux/osx/bsd */ + setenv(env, val, 1); +#endif +} void BLI_clean(char *path) { |