...
 
Commits (4)
......@@ -1013,7 +1013,7 @@ int ansi_initciolib(long inmode)
void ansi_suspend(void)
{
#if defined _WIN32
#if defined _MSC_VER
// Prevents the wait for a key press when exit() is called and the stdin stream is flushed
_unlock_file(stdin);
#endif
......
/*
* The RIPper... interposes on the connection and handles RIP sequences
*/
#include <arpa/inet.h>
#include <sys/stat.h>
#include <math.h>
......@@ -16,6 +15,8 @@
#include <dirwrap.h>
#include <gen_defs.h>
#include <genwrap.h>
#include <sockwrap.h>
#include <strwrap.h>
#include <unistd.h>
#include <vidmodes.h>
#include <xpbeep.h>
......
......@@ -877,7 +877,7 @@ char* safe_strerror(int errnum, char *buf, size_t buflen)
#if defined(_MSC_VER)
strerror_s(buf, buflen, errnum);
#elif defined(__BORLANDC__)
#elif defined(_WIN32)
strncpy(buf, strerror(errnum), buflen);
buf[buflen - 1] = 0;
#elif defined(_GNU_SOURCE)
......
......@@ -38,5 +38,36 @@ char* ltoa(long val, char* str, int radix)
}
return(str);
}
#endif
#ifdef _WIN32
/* From FreeBSD */
size_t
strnlen(const char *s, size_t maxlen)
{
size_t len;
for (len = 0; len < maxlen; len++, s++) {
if (!*s)
break;
}
return (len);
}
/* From FreeBSD */
char *
strndup(const char *str, size_t maxlen)
{
char *copy;
size_t len;
len = strnlen(str, maxlen);
copy = malloc(len + 1);
if (copy != NULL) {
(void)memcpy(copy, str, len);
copy[len] = '\0';
}
return copy;
}
#endif
......@@ -18,4 +18,17 @@ char* ltoa(long val, char* str, int radix);
#endif
#ifdef _MSVC
#if defined(__cplusplus)
extern "C" {
#endif
char *strndup(const char *str, size_t maxlen);
size_t strnlen(const char *s, size_t maxlen);
#if defined(__cplusplus)
}
#endif
#endif
#endif