gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r34758 - in libmicrohttpd/src: include platform


From: gnunet
Subject: [GNUnet-SVN] r34758 - in libmicrohttpd/src: include platform
Date: Mon, 22 Dec 2014 20:42:09 +0100

Author: Karlson2k
Date: 2014-12-22 20:42:08 +0100 (Mon, 22 Dec 2014)
New Revision: 34758

Modified:
   libmicrohttpd/src/include/w32functions.h
   libmicrohttpd/src/platform/w32functions.c
Log:
[w32] Add W32 emulation for snprintf()

Modified: libmicrohttpd/src/include/w32functions.h
===================================================================
--- libmicrohttpd/src/include/w32functions.h    2014-12-22 19:42:00 UTC (rev 
34757)
+++ libmicrohttpd/src/include/w32functions.h    2014-12-22 19:42:08 UTC (rev 
34758)
@@ -191,6 +191,9 @@
  */
 int MHD_W32_random_(void);
 
+/* Emulate snprintf function on W32 */
+int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, 
...);
+
 #ifdef __cplusplus
 }
 #endif

Modified: libmicrohttpd/src/platform/w32functions.c
===================================================================
--- libmicrohttpd/src/platform/w32functions.c   2014-12-22 19:42:00 UTC (rev 
34757)
+++ libmicrohttpd/src/platform/w32functions.c   2014-12-22 19:42:08 UTC (rev 
34758)
@@ -29,6 +29,8 @@
 #include <string.h>
 #include <stdint.h>
 #include <time.h>
+#include <stdio.h>
+#include <stdarg.h>
 
 
 /**
@@ -640,3 +642,27 @@
                & 0x7fffffff;
   return (int)rnd_val;
 }
+
+/* Emulate snprintf function on W32 */
+int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, 
...)
+{
+  int ret;
+  va_list args;
+  if (0 != n && NULL != s )
+  {
+    va_start(args, format);
+    ret = _vsnprintf(s, n, format, args);
+    va_end(args);
+    if (n == ret)
+      s[n - 1] = 0;
+    if (ret >= 0)
+      return ret;
+  }
+  va_start(args, format);
+  ret = _vscprintf(format, args);
+  va_end(args);
+  if (0 <= ret && 0 != n && NULL == s)
+    return -1;
+
+  return ret;
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]