aboutsummaryrefslogtreecommitdiff
path: root/tools/plink/errsock.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-04-14 23:58:38 +0200
committermarha <marha@users.sourceforge.net>2014-04-14 23:58:38 +0200
commit19cb1eafd187f29751460f04ce65e293c54a5ba4 (patch)
treef3be82a68d4d04e4262cc5fddd22df530ca2b4f0 /tools/plink/errsock.c
parent64e01951590b2856a10dd0cadd14de2b855daad0 (diff)
downloadvcxsrv-19cb1eafd187f29751460f04ce65e293c54a5ba4.tar.gz
vcxsrv-19cb1eafd187f29751460f04ce65e293c54a5ba4.tar.bz2
vcxsrv-19cb1eafd187f29751460f04ce65e293c54a5ba4.zip
Added pmink errsock.c winshare.c
Diffstat (limited to 'tools/plink/errsock.c')
-rw-r--r--tools/plink/errsock.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/tools/plink/errsock.c b/tools/plink/errsock.c
new file mode 100644
index 000000000..1b3a88a25
--- /dev/null
+++ b/tools/plink/errsock.c
@@ -0,0 +1,67 @@
+/*
+ * A dummy Socket implementation which just holds an error message.
+ */
+
+#include <stdio.h>
+#include <assert.h>
+
+#define DEFINE_PLUG_METHOD_MACROS
+#include "tree234.h"
+#include "putty.h"
+#include "network.h"
+
+typedef struct Socket_error_tag *Error_Socket;
+
+struct Socket_error_tag {
+ const struct socket_function_table *fn;
+ /* the above variable absolutely *must* be the first in this structure */
+
+ char *error;
+ Plug plug;
+};
+
+static Plug sk_error_plug(Socket s, Plug p)
+{
+ Error_Socket ps = (Error_Socket) s;
+ Plug ret = ps->plug;
+ if (p)
+ ps->plug = p;
+ return ret;
+}
+
+static void sk_error_close(Socket s)
+{
+ Error_Socket ps = (Error_Socket) s;
+
+ sfree(ps->error);
+ sfree(ps);
+}
+
+static const char *sk_error_socket_error(Socket s)
+{
+ Error_Socket ps = (Error_Socket) s;
+ return ps->error;
+}
+
+Socket new_error_socket(const char *errmsg, Plug plug)
+{
+ static const struct socket_function_table socket_fn_table = {
+ sk_error_plug,
+ sk_error_close,
+ NULL /* write */,
+ NULL /* write_oob */,
+ NULL /* write_eof */,
+ NULL /* flush */,
+ NULL /* set_frozen */,
+ sk_error_socket_error
+ };
+
+ Error_Socket ret;
+
+ ret = snew(struct Socket_error_tag);
+ ret->fn = &socket_fn_table;
+ ret->plug = plug;
+ ret->error = dupstr(errmsg);
+
+ return (Socket) ret;
+}