aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/w32functions.h3
-rw-r--r--src/platform/w32functions.c26
2 files changed, 29 insertions, 0 deletions
diff --git a/src/include/w32functions.h b/src/include/w32functions.h
index c7a885a6..e68b90d6 100644
--- a/src/include/w32functions.h
+++ b/src/include/w32functions.h
@@ -191,6 +191,9 @@ int MHD_W32_pair_of_sockets_(SOCKET sockets_pair[2]);
191 */ 191 */
192int MHD_W32_random_(void); 192int MHD_W32_random_(void);
193 193
194/* Emulate snprintf function on W32 */
195int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, ...);
196
194#ifdef __cplusplus 197#ifdef __cplusplus
195} 198}
196#endif 199#endif
diff --git a/src/platform/w32functions.c b/src/platform/w32functions.c
index 7a0686e8..e4f93db0 100644
--- a/src/platform/w32functions.c
+++ b/src/platform/w32functions.c
@@ -29,6 +29,8 @@
29#include <string.h> 29#include <string.h>
30#include <stdint.h> 30#include <stdint.h>
31#include <time.h> 31#include <time.h>
32#include <stdio.h>
33#include <stdarg.h>
32 34
33 35
34/** 36/**
@@ -640,3 +642,27 @@ int MHD_W32_random_(void)
640 & 0x7fffffff; 642 & 0x7fffffff;
641 return (int)rnd_val; 643 return (int)rnd_val;
642} 644}
645
646/* Emulate snprintf function on W32 */
647int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, ...)
648{
649 int ret;
650 va_list args;
651 if (0 != n && NULL != s )
652 {
653 va_start(args, format);
654 ret = _vsnprintf(s, n, format, args);
655 va_end(args);
656 if (n == ret)
657 s[n - 1] = 0;
658 if (ret >= 0)
659 return ret;
660 }
661 va_start(args, format);
662 ret = _vscprintf(format, args);
663 va_end(args);
664 if (0 <= ret && 0 != n && NULL == s)
665 return -1;
666
667 return ret;
668}