summaryrefslogtreecommitdiffstats
path: root/libqpdf/QUtil.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2013-11-30 04:08:25 +0100
committerJay Berkenbilt <ejb@ql.org>2013-11-30 21:58:32 +0100
commit478c05fcab6cb4137b9cbaf55fdcdb6ff74107c0 (patch)
treeb3861bf4962f0509a7ccf2ec58f794d7a54b23f2 /libqpdf/QUtil.cc
parent88c29873e56e69c83aa0d0798188cd792368059b (diff)
downloadqpdf-478c05fcab6cb4137b9cbaf55fdcdb6ff74107c0.tar.zst
Allow -DNO_GET_ENVIRONMENT to avoid GetEnvironmentVariable
If NO_GET_ENVIRONMENT is #defined at compile time on Windows, do not call GetEnvironmentVariable. QUtil::get_env will always return false. This option is not available through configure. This was added to support a specific user's requirements to avoid calling GetEnvironmentVariable from the Windows API. Nothing in qpdf outside the test coverage system in qtest relies on QUtil::get_env.
Diffstat (limited to 'libqpdf/QUtil.cc')
-rw-r--r--libqpdf/QUtil.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc
index cf455061..01e0b6e7 100644
--- a/libqpdf/QUtil.cc
+++ b/libqpdf/QUtil.cc
@@ -7,6 +7,7 @@
#include <cmath>
#include <iomanip>
#include <sstream>
+#include <stdexcept>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
@@ -262,6 +263,9 @@ QUtil::get_env(std::string const& var, std::string* value)
{
// This was basically ripped out of wxWindows.
#ifdef _WIN32
+# ifdef NO_GET_ENVIRONMENT
+ return false;
+# else
// first get the size of the buffer
DWORD len = ::GetEnvironmentVariable(var.c_str(), NULL, 0);
if (len == 0)
@@ -279,6 +283,7 @@ QUtil::get_env(std::string const& var, std::string* value)
}
return true;
+# endif
#else
char* p = getenv(var.c_str());
if (p == 0)