summaryrefslogtreecommitdiff
path: root/src/tools.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools.cc')
-rw-r--r--src/tools.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/tools.cc b/src/tools.cc
new file mode 100644
index 0000000..24c3757
--- /dev/null
+++ b/src/tools.cc
@@ -0,0 +1,44 @@
+/** --------------------------------------------------------------------
+ * @file tools.cc
+ * @brief Implementation of miscellaneous tools.
+ * @author Andreas Aardal Hanssen
+ * @date 2002-2005
+ * ------------------------------------------------------------------ **/
+#include <errno.h>
+#include <cstring>
+
+#include "tools.h"
+
+using namespace ::std;
+using namespace Binc;
+
+//------------------------------------------------------------------------
+Tools::Tools(void)
+{
+}
+
+//------------------------------------------------------------------------
+Tools &Tools::getInstance(void)
+{
+ static Tools tools;
+ return tools;
+}
+
+//------------------------------------------------------------------------
+void Tools::setenv(const string &key, const string &value) const
+{
+ char *c = strdup((key + "=" + value).c_str());
+ putenv(c);
+}
+
+//------------------------------------------------------------------------
+string Tools::getenv(const string &key) const
+{
+ static const string NIL = "";
+
+ const char *c = ::getenv((char *)key.c_str());
+ if (c == 0)
+ return NIL;
+ else
+ return string(c);
+}