version 1.4w10UCIb20
[polyglot.git] / util.cpp
index 3ec89b7..a7a733c 100644 (file)
--- a/util.cpp
+++ b/util.cpp
 #include "posix.h"\r
 #include "util.h"\r
 \r
+//\r
+\r
+const  int  ErrorBufferSize=4096;\r
+\r
 // variables\r
 \r
 static bool Error;\r
+static char ErrorBuffer[ErrorBufferSize];\r
 \r
 FILE * LogFile=NULL;\r
 \r
@@ -366,3 +371,22 @@ double my_timer_elapsed_real(const my_timer_t * timer) {
 \r
    return elapsed;\r
 }\r
+\r
+// my_timer()\r
+\r
+char * my_error(){\r
+#ifdef _WIN32\r
+    FormatMessage(\r
+        FORMAT_MESSAGE_FROM_SYSTEM,\r
+        NULL,\r
+        GetLastError(),\r
+        LANG_USER_DEFAULT,\r
+        ErrorBuffer,\r
+        ErrorBufferSize,\r
+        NULL);\r
+    return ErrorBuffer;\r
+#else\r
+    return strerror(errno);\r
+#endif\r
+}\r
+\r