summaryrefslogtreecommitdiffstats
path: root/debian/uncrustify-trinity/uncrustify-trinity-0.74.0/src/compat_win32.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'debian/uncrustify-trinity/uncrustify-trinity-0.74.0/src/compat_win32.cpp')
-rw-r--r--debian/uncrustify-trinity/uncrustify-trinity-0.74.0/src/compat_win32.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.74.0/src/compat_win32.cpp b/debian/uncrustify-trinity/uncrustify-trinity-0.74.0/src/compat_win32.cpp
new file mode 100644
index 00000000..d7292466
--- /dev/null
+++ b/debian/uncrustify-trinity/uncrustify-trinity-0.74.0/src/compat_win32.cpp
@@ -0,0 +1,82 @@
+/**
+ * @file compat_win32.cpp
+ * Compatibility functions for win32
+ *
+ * @author Ben Gardner
+ * @license GPL v2+
+ */
+
+#if defined (_WIN32) \
+ && !defined (__CYGWIN__)
+
+#include "windows_compat.h"
+
+#include <cstdio>
+#include <string>
+
+
+bool unc_getenv(const char *name, std::string &str)
+{
+ DWORD len = GetEnvironmentVariableA(name, NULL, 0);
+ char *buf;
+
+ if (len == 0)
+ {
+ if (GetLastError() == ERROR_ENVVAR_NOT_FOUND)
+ {
+ return(false);
+ }
+ }
+ buf = (char *)malloc(len);
+
+ if (buf)
+ {
+ len = GetEnvironmentVariableA(name, buf, len);
+ }
+ buf[len] = 0;
+
+ str = buf;
+ //printf("%s: name=%s len=%d value=%s\n", __func__, name, (int)len, str.c_str());
+ free(buf);
+
+ return(true);
+}
+
+
+bool unc_homedir(std::string &home)
+{
+ if (unc_getenv("HOME", home))
+ {
+ return(true);
+ }
+
+ if (unc_getenv("USERPROFILE", home))
+ {
+ return(true);
+ }
+ std::string hd, hp;
+
+ if ( unc_getenv("HOMEDRIVE", hd)
+ && unc_getenv("HOMEPATH", hp))
+ {
+ home = hd + hp;
+ return(true);
+ }
+ return(false);
+}
+
+
+void convert_log_zu2lu(char *fmt)
+{
+ for (size_t i = 0; i < strlen(fmt); i++)
+ {
+ if ( (fmt[i] == '%')
+ && (fmt[i + 1] == 'z')
+ && (fmt[i + 2] == 'u'))
+ {
+ fmt[i + 1] = 'l';
+ }
+ }
+}
+
+#endif /* if defined(_WIN32) && !defined(__CYGWIN__) */