aboutsummaryrefslogtreecommitdiff
path: root/tools/plink
diff options
context:
space:
mode:
Diffstat (limited to 'tools/plink')
-rw-r--r--tools/plink/makefile15
-rw-r--r--tools/plink/winplink.c53
2 files changed, 68 insertions, 0 deletions
diff --git a/tools/plink/makefile b/tools/plink/makefile
new file mode 100644
index 000000000..2dd5fb89c
--- /dev/null
+++ b/tools/plink/makefile
@@ -0,0 +1,15 @@
+ifeq ($(MAKESERVER),1)
+$(error Please do not specify MAKESERVER=1 on the command line or as environment variable)
+endif
+
+DEFINES += SECURITY_WIN32
+
+CSRCS = winplink.c winhandl.c misc.c settings.c winstore.c windefs.c winmisc.c wincons.c \
+ logging.c winnet.c tree234.c winnoise.c sshrand.c cmdline.c sshsha.c timing.c \
+ be_all.c rlogin.c proxy.c winproxy.c cproxy.c sshmd5.c time.c version.c ssh.c \
+ sshdh.c sshzlib.c sshbn.c sshrsa.c sshcrcda.c sshpubk.c sshdes.c wingss.c \
+ sshblowf.c sshsh512.c sshsh256.c sshaes.c pinger.c ssharcf.c x11fwd.c winpgntc.c \
+ winx11.c portfwd.c sshcrc.c wildcard.c ldisc.c sshdss.c raw.c telnet.c sshgssc.c \
+ pgssapi.c
+
+WINAPP=plink
diff --git a/tools/plink/winplink.c b/tools/plink/winplink.c
index 7af9e1b4f..d1539e441 100644
--- a/tools/plink/winplink.c
+++ b/tools/plink/winplink.c
@@ -3,6 +3,7 @@
*/
#include <stdio.h>
+#include <fcntl.h>
#include <stdlib.h>
#include <assert.h>
#include <stdarg.h>
@@ -723,3 +724,55 @@ int main(int argc, char **argv)
cleanup_exit(exitcode);
return 0; /* placate compiler warning */
}
+
+#ifdef _MSC_VER
+#pragma warning(disable:4273)
+#endif
+
+_Check_return_opt_ int __cdecl printf(_In_z_ _Printf_format_string_ const char * pFmt, ...)
+{
+ static int ConsoleCreated=0;
+ va_list arglist;
+ if (!ConsoleCreated)
+ {
+ int hConHandle;
+ long lStdHandle;
+ CONSOLE_SCREEN_BUFFER_INFO coninfo;
+
+ FILE *fp;
+ const unsigned int MAX_CONSOLE_LINES = 500;
+ ConsoleCreated=1;
+ if (!AttachConsole(ATTACH_PARENT_PROCESS))
+ AllocConsole();
+
+ // set the screen buffer to be big enough to let us scroll text
+ GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
+ coninfo.dwSize.Y = MAX_CONSOLE_LINES;
+ SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
+
+ // redirect unbuffered STDOUT to the console
+ lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen( hConHandle, "w" );
+ *stdout = *fp;
+ setvbuf( stdout, NULL, _IONBF, 0 );
+
+ // redirect unbuffered STDIN to the console
+ lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen( hConHandle, "r" );
+ *stdin = *fp;
+ setvbuf( stdin, NULL, _IONBF, 0 );
+
+ // redirect unbuffered STDERR to the console
+ lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen( hConHandle, "w" );
+ *stderr = *fp;
+ setvbuf( stderr, NULL, _IONBF, 0 );
+
+ }
+
+ va_start(arglist, pFmt );
+ return vfprintf(stderr, pFmt, arglist);
+}