From 64e9837c9b518147a2d9068897add872f79f3c66 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 24 Dec 2018 12:04:39 -0200 Subject: [PATCH] + Creating static tables for methods (easy to keep the windows and linux code in sync). --- Makefile.in | 1 + pw3270-plugin-ipc.cbp | 3 +++ src/constants.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/include/lib3270/ipc.h | 7 +++++++ src/linux/methods.c | 10 ++-------- 5 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 src/constants.c diff --git a/Makefile.in b/Makefile.in index 61996f7..6e7d795 100644 --- a/Makefile.in +++ b/Makefile.in @@ -29,6 +29,7 @@ MODULE_NAME=ipc3270 SOURCES= \ + $(wildcard src/*.c) \ $(wildcard src/plugin/*.c) \ $(wildcard src/@OSNAME@/*.c) \ $(wildcard src/@OSNAME@/*.rc) diff --git a/pw3270-plugin-ipc.cbp b/pw3270-plugin-ipc.cbp index deabc18..024eaf9 100644 --- a/pw3270-plugin-ipc.cbp +++ b/pw3270-plugin-ipc.cbp @@ -38,6 +38,9 @@ + + diff --git a/src/constants.c b/src/constants.c new file mode 100644 index 0000000..070f60a --- /dev/null +++ b/src/constants.c @@ -0,0 +1,51 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como main.c e possui - linhas de código. + * + * Referências: + * + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +#include +#include +#include + +const IPC_METHOD_INT_ARG * ipc3270_get_int_arg_methods() { + + static const IPC_METHOD_INT_ARG int_arg_methods[] = { + { "pfkey", lib3270_pfkey }, + { "pakey", lib3270_pakey }, + { NULL, NULL } + }; + + return int_arg_methods; + +} + + diff --git a/src/include/lib3270/ipc.h b/src/include/lib3270/ipc.h index 6819e99..e1923bc 100644 --- a/src/include/lib3270/ipc.h +++ b/src/include/lib3270/ipc.h @@ -64,4 +64,11 @@ #define debug(...) /* __VA_ARGS */ #endif + typedef struct _ipc_method_int_arg { + const gchar *name; + int (*call)(H3270 *hSession, int keycode); + } IPC_METHOD_INT_ARG; + + const IPC_METHOD_INT_ARG * ipc3270_get_int_arg_methods(); + #endif // PW3270_IPC_H_INCLUDED diff --git a/src/linux/methods.c b/src/linux/methods.c index 21f85a2..e790633 100644 --- a/src/linux/methods.c +++ b/src/linux/methods.c @@ -50,14 +50,6 @@ ipc3270_method_call (GDBusConnection *connection, gpointer user_data) { - static const struct - { - const gchar *name; - int (*call)(H3270 *hSession, int keycode); - } int_methods[] = { - { "pfkey", lib3270_pfkey }, - { "pakey", lib3270_pakey } - }; size_t ix; g_autoptr (GError) error = NULL; @@ -87,6 +79,8 @@ ipc3270_method_call (GDBusConnection *connection, } // Check int methods + const IPC_METHOD_INT_ARG * int_methods = ipc3270_get_int_arg_methods(); + for(ix = 0; ix < G_N_ELEMENTS(int_methods); ix++) { if(!g_ascii_strcasecmp(int_methods[ix].name,method_name)) { -- libgit2 0.21.2