Moved getenv usage across to safer osg::getEnvVar() usage

This commit is contained in:
Robert Osfield
2017-11-01 17:38:33 +00:00
parent 0e7e06349e
commit 338b0e2b7b
6 changed files with 39 additions and 24 deletions

View File

@@ -17,6 +17,7 @@
#include <osg/Config>
#ifdef OSG_ENVVAR_SUPPORTED
#include <stdlib.h>
#include <sstream>
#endif
@@ -29,6 +30,15 @@ inline unsigned int getClampedLength(const char* str, unsigned int maxNumChars=4
return i;
}
inline std::string getEnvVar(const char* name)
{
std::string value;
const char* ptr = getenv(name);
if (ptr) value.assign(ptr, getClampedLength(ptr));
return value;
}
template<typename T>
inline bool getEnvVar(const char* name, T& value)
{