Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #27 from egtra/msvc2015
Browse files Browse the repository at this point in the history
Fix to compile with Visual C++ 2015
  • Loading branch information
Sean Middleditch authored Aug 21, 2017
2 parents 9b31ab2 + 66013f7 commit 2b645e9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions libtelnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ extern "C" {
# define TELNET_GNU_SENTINEL /*!< internal helper */
#endif

/* Disable environ macro for Visual C++ 2015. */
#undef environ

/*! Telnet state tracker object type. */
typedef struct telnet_t telnet_t;

Expand Down
3 changes: 3 additions & 0 deletions util/telnet-chatd.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
# include <winsock2.h>
# include <ws2tcpip.h>

#ifndef _UCRT
# define snprintf _snprintf
#endif

# define poll WSAPoll
# define close closesocket
# define strdup _strdup
Expand Down
4 changes: 3 additions & 1 deletion util/telnet-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ static void _event_handler(telnet_t *telnet, telnet_event_t *ev,
switch (ev->type) {
/* data received */
case TELNET_EV_DATA:
printf("%.*s", (int)ev->data.size, ev->data.buffer);
if (ev->data.size && fwrite(ev->data.buffer, 1, ev->data.size, stdout) != ev->data.size) {
fprintf(stderr, "ERROR: Could not write complete buffer to stdout");
}
fflush(stdout);
break;
/* data must be sent */
Expand Down
8 changes: 5 additions & 3 deletions util/telnet-proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@
# include <winsock2.h>
# include <ws2tcpip.h>

#ifndef _UCRT
# define snprintf _snprintf
#endif

# define poll WSAPoll
# define close closesocket

#if !defined(_MSC_VER) || _MSC_VER < 1600 // VC 9 and prior do not define this macro
# undef gai_strerror
# define gai_strerror gai_strerrorA
# define ECONNRESET WSAECONNRESET
#endif
#endif

#include <errno.h>
#include <stdio.h>
Expand Down

0 comments on commit 2b645e9

Please sign in to comment.