From 6a7be74c25e6312205c30c60026a1d4fd0654362 Mon Sep 17 00:00:00 2001
From: brands <brands>
Date: Thu, 17 Apr 2014 14:52:20 +0000
Subject: [PATCH] Slash Backslash converting for env vars

---
 winunixconv.c   | 78 +++++++++++++++++++++++++++++++++++++++++++++++++
 winunixconv.dbd |  1 +
 2 files changed, 79 insertions(+)
 create mode 100644 winunixconv.c
 create mode 100644 winunixconv.dbd

diff --git a/winunixconv.c b/winunixconv.c
new file mode 100644
index 00000000..d70495a2
--- /dev/null
+++ b/winunixconv.c
@@ -0,0 +1,78 @@
+/* winunixconv.c
+*
+*  convert backslashes into slashes
+*
+*  $Author: brands $
+*
+*  $Source: /cvs/G/DRV/misc/winunixconv.c,v $
+*
+*/
+
+#include <string.h>
+#include <stdlib.h>
+#include <dbScan.h>
+#include <dbStaticLib.h>
+#include <dbAccess.h>
+#include <epicsVersion.h>
+#ifdef BASE_VERSION
+#define EPICS_3_13
+extern DBBASE *pdbbase;
+#else
+#define EPICS_3_14
+#include <iocsh.h>
+#include <epicsExport.h>
+#endif
+
+
+int winunixconv (char* envvar)
+{
+   char *cp;
+   char *envstr = getenv(envvar);
+   int j = 0;
+
+
+    while (envstr[j] != '\0'){
+        if (envstr[j] == '\\') {
+            envstr[j] = '/';
+        }
+        j++;
+    }
+    cp = mallocMustSucceed (strlen (envvar) + strlen (envstr) + 2, "winunixconv");
+
+    strcpy (cp, envvar);
+	strcat (cp, "=");
+	strcat (cp, envstr);
+	if (putenv (cp) < 0) {
+		errPrintf(
+                -1L,
+                __FILE__,
+                __LINE__,
+                "Failed to set environment parameter \"%s\" to new value \"%s\": %s\n",
+                envvar,
+                envstr,
+                strerror (errno));
+        free (cp);
+	}
+
+    return 0;
+}
+
+#ifdef EPICS_3_14
+static const iocshArg winunixconvArg0 = { "envVar", iocshArgString };
+static const iocshArg * const winunixconvArgs[1] = { &winunixconvArg0 };
+static const iocshFuncDef winunixconvDef = { "winunixconv", 1, winunixconvArgs };
+static void winunixconvFunc (const iocshArgBuf *args)
+{
+    winunixconv(args[0].sval);
+}
+static void winunixconvRegister(void)
+{
+    static int winunixconvfirstTime = 1;
+    if (winunixconvfirstTime) {
+        iocshRegister (&winunixconvDef, winunixconvFunc);
+        winunixconvfirstTime = 0;
+    }
+}
+epicsExportRegistrar(winunixconvRegister);
+#endif
+
diff --git a/winunixconv.dbd b/winunixconv.dbd
new file mode 100644
index 00000000..28e0c61b
--- /dev/null
+++ b/winunixconv.dbd
@@ -0,0 +1 @@
+registrar(winunixconvRegister)
-- 
GitLab