]> source.dussan.org Git - tigervnc.git/commitdiff
Provide a setenv wrapper for platforms that doesn't have setenv, such
authorPeter Åstrand <astrand@cendio.se>
Thu, 17 Feb 2005 09:12:31 +0000 (09:12 +0000)
committerPeter Åstrand <astrand@cendio.se>
Thu, 17 Feb 2005 09:12:31 +0000 (09:12 +0000)
as Solaris.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@189 3789f03b-4d11-0410-bbf8-ca57d06f2519

vncviewer_unix/vncviewer.cxx

index a3d2fd317a8652d188d470ab5bdea45e6baeade6..8f2d444ceff13488c68abae80257bb3a206ea0f5 100644 (file)
@@ -216,6 +216,27 @@ interpretViaParam (char **gatewayHost, char **remoteHost,
   sprintf (*vncServerName, "localhost::%d", localPort);
 }
 
+#ifndef HAVE_SETENV
+int
+setenv(const char *envname, const char * envval, int overwrite)
+{
+  if (envname && envval) {
+    char * envp = NULL;
+    envp = (char*)malloc(strlen(envname) + strlen(envval) + 2);
+    if (envp) {
+      // The putenv API guarantees memory leaks when
+      // changing environment variables repeatedly.
+      sprintf(envp, "%s=%s", envname, envval);
+      
+      // Cannot free envp
+      putenv(envp);
+      return(0);
+    }
+  }
+  return(-1);
+}
+#endif
+
 static void
 createTunnel (const char *gatewayHost, const char *remoteHost,
              int remotePort, int localPort)