From d37b22f7dbf93089b206284e56f6420265d6e734 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Thu, 30 Jul 2020 20:22:54 -0300 Subject: [PATCH] Fixing small bugs on windows. --- client/src/session/remote/wait.cc | 9 +++++---- client/src/session/remote/windows/session.cc | 5 ++++- server/src/core/windows/gobject.h | 6 +++--- server/src/core/windows/inout.c | 18 +++++++++++++++++- server/src/core/windows/pipesource.c | 22 ++++++++++++++-------- server/src/core/windows/start.c | 2 +- server/src/testprogram/testprogram.c | 2 +- 7 files changed, 45 insertions(+), 19 deletions(-) diff --git a/client/src/session/remote/wait.cc b/client/src/session/remote/wait.cc index a3462fe..caead33 100644 --- a/client/src/session/remote/wait.cc +++ b/client/src/session/remote/wait.cc @@ -57,16 +57,17 @@ rc = worker(); - debug("rc=",rc); + debug("rc=",rc," (",strerror(rc),")"); if(rc == 0) return; - else if(rc != ETIMEDOUT) + + if(rc != ETIMEDOUT) chkResponse(rc); } - chkResponse(ETIMEDOUT); + throw runtime_error("Timeout"); } @@ -196,7 +197,7 @@ .call() .pop(rc); - debug("rc=",rc); + debug("waitForStringAt rc=",rc); return rc; }); diff --git a/client/src/session/remote/windows/session.cc b/client/src/session/remote/windows/session.cc index ebb2047..70f405a 100644 --- a/client/src/session/remote/windows/session.cc +++ b/client/src/session/remote/windows/session.cc @@ -77,7 +77,10 @@ ); if (hPipe == INVALID_HANDLE_VALUE) { - throw std::runtime_error("Can't open IPC Channel"); + string msg = "Can't open IPC Channel \""; + msg += pipename; + msg += "\""; + throw std::runtime_error(msg); } // The pipe connected; change to message-read mode. diff --git a/server/src/core/windows/gobject.h b/server/src/core/windows/gobject.h index 8df335f..dfc559a 100644 --- a/server/src/core/windows/gobject.h +++ b/server/src/core/windows/gobject.h @@ -90,10 +90,10 @@ GObjectClass parent; }; - G_GNUC_INTERNAL GSourceFuncs ipc3270_source_funcs; + G_GNUC_INTERNAL GSourceFuncs * ipc3270_get_source_funcs(); - G_GNUC_INTERNAL void ipc3270_release_object(ipc3270 *object); - G_GNUC_INTERNAL void ipc3270_wait_for_client(IPC3270_PIPE_SOURCE *source); + G_GNUC_INTERNAL void ipc3270_release_object(ipc3270 *object); + G_GNUC_INTERNAL void ipc3270_wait_for_client(IPC3270_PIPE_SOURCE *source); G_END_DECLS diff --git a/server/src/core/windows/inout.c b/server/src/core/windows/inout.c index 4eb77be..1002bb3 100644 --- a/server/src/core/windows/inout.c +++ b/server/src/core/windows/inout.c @@ -46,6 +46,8 @@ unsigned char * ipc3270_pack_error(const GError *error, size_t * szPacket) { static const char * error_response = "error"; + debug("%s(%d,%s)",__FUNCTION__,(int) error_response,error->message); + *szPacket = strlen(error_response) + 1 + (sizeof(guint16) * 2) + strlen(error->message); // Allocate buffer @@ -94,40 +96,54 @@ unsigned char * pack_value(unsigned char *txtptr, GVariant *value) { strcpy((char *) txtptr,g_variant_get_string(value,NULL)); txtptr += (strlen((char *) txtptr)+1); + debug("%s(%s)",__FUNCTION__,g_variant_get_string(value,NULL)); + } else if(g_variant_type_equal(type,G_VARIANT_TYPE_BOOLEAN)) { *(txtptr++) = 'b'; *(txtptr++) = g_variant_get_boolean(value) ? 1 : 0; + debug("%s(%s)",__FUNCTION__,g_variant_get_boolean(value) ? "True" : "False"); + } else if(g_variant_type_equal(type,G_VARIANT_TYPE_BYTE)) { *(txtptr++) = 'y'; *(txtptr++) = g_variant_get_byte(value); + debug("%s(%d)",__FUNCTION__,(int) g_variant_get_byte(value)); + } else if(g_variant_type_equal(type,G_VARIANT_TYPE_INT16)) { *(txtptr++) = 'n'; *((gint16 *) txtptr) = g_variant_get_int16(value); txtptr += sizeof(gint16); + debug("%s(%d)",__FUNCTION__,(int) g_variant_get_int16(value)); + } else if(g_variant_type_equal(type,G_VARIANT_TYPE_UINT16)) { *(txtptr++) = 'q'; *((guint16 *) txtptr) = g_variant_get_uint16(value); txtptr += sizeof(guint16); + debug("%s(%d)",__FUNCTION__,(int) g_variant_get_uint16(value)); + } else if(g_variant_type_is_subtype_of(type,G_VARIANT_TYPE_INT32)) { *(txtptr++) = 'i'; *((gint32 *) txtptr) = g_variant_get_int32(value); txtptr += sizeof(gint32); + debug("%s(%d)",__FUNCTION__,(int) g_variant_get_int32(value)); + } else if(g_variant_type_equal(type,G_VARIANT_TYPE_UINT32)) { *(txtptr++) = 'u'; *((guint32 *) txtptr) = g_variant_get_uint32(value); txtptr += sizeof(guint32); + debug("%s(%d)",__FUNCTION__,(int) g_variant_get_uint32(value)); + } else if(g_variant_type_equal(type,G_VARIANT_TYPE_INT64)) { *(txtptr++) = 'x'; @@ -294,7 +310,7 @@ GVariant * ipc3270_unpack(const unsigned char *packet, int *id) { break; default: - g_message("Unexpected format for argument %d: \"%c\"",ix,descrs[ix+1]); + g_message("Unexpected format for argument %d: \"%c\"",(int) ix,descrs[ix+1]); errno = EINVAL; return NULL; } diff --git a/server/src/core/windows/pipesource.c b/server/src/core/windows/pipesource.c index 92834a3..1f78aa3 100644 --- a/server/src/core/windows/pipesource.c +++ b/server/src/core/windows/pipesource.c @@ -290,11 +290,17 @@ static void IO_finalize(GSource *source) { } -GSourceFuncs ipc3270_source_funcs = { - IO_prepare, - IO_check, - IO_dispatch, - IO_finalize, - IO_closure, - NULL -}; +GSourceFuncs * ipc3270_get_source_funcs() { + + static GSourceFuncs source_funcs = { + IO_prepare, + IO_check, + IO_dispatch, + IO_finalize, + IO_closure, + NULL + }; + + return &source_funcs; +} + diff --git a/server/src/core/windows/start.c b/server/src/core/windows/start.c index 33bbd3b..036706b 100644 --- a/server/src/core/windows/start.c +++ b/server/src/core/windows/start.c @@ -68,7 +68,7 @@ void ipc3270_export_object(GObject *object, const char *name, GError G_GNUC_UNUS if(hPipe != INVALID_HANDLE_VALUE) { - ipc->source = (IPC3270_PIPE_SOURCE *) g_source_new(&ipc3270_source_funcs,sizeof(IPC3270_PIPE_SOURCE)); + ipc->source = (IPC3270_PIPE_SOURCE *) g_source_new(ipc3270_get_source_funcs(),sizeof(IPC3270_PIPE_SOURCE)); g_message("Got session \"%c\"",id); diff --git a/server/src/testprogram/testprogram.c b/server/src/testprogram/testprogram.c index ea5c7c6..96a71d2 100644 --- a/server/src/testprogram/testprogram.c +++ b/server/src/testprogram/testprogram.c @@ -111,7 +111,7 @@ #ifdef _WIN32 { // Setup font name - v3270_set_font_family(terminal,"Droid Sans Mono"); + //v3270_set_font_family(terminal,"Droid Sans Mono"); // WIN32 path settings. static const char * sep = "\\/."; -- libgit2 0.21.2