Commit 64e9837c9b518147a2d9068897add872f79f3c66
1 parent
7e8147aa
Exists in
master
and in
1 other branch
+ Creating static tables for methods (easy to keep the windows and linux
code in sync).
Showing
5 changed files
with
64 additions
and
8 deletions
Show diff stats
Makefile.in
| @@ -29,6 +29,7 @@ | @@ -29,6 +29,7 @@ | ||
| 29 | MODULE_NAME=ipc3270 | 29 | MODULE_NAME=ipc3270 |
| 30 | 30 | ||
| 31 | SOURCES= \ | 31 | SOURCES= \ |
| 32 | + $(wildcard src/*.c) \ | ||
| 32 | $(wildcard src/plugin/*.c) \ | 33 | $(wildcard src/plugin/*.c) \ |
| 33 | $(wildcard src/@OSNAME@/*.c) \ | 34 | $(wildcard src/@OSNAME@/*.c) \ |
| 34 | $(wildcard src/@OSNAME@/*.rc) | 35 | $(wildcard src/@OSNAME@/*.rc) |
pw3270-plugin-ipc.cbp
| @@ -38,6 +38,9 @@ | @@ -38,6 +38,9 @@ | ||
| 38 | <Linker> | 38 | <Linker> |
| 39 | <Add option="`pkg-config --libs gtk+-3.0 lib3270 v3270 gio-2.0 dbus-1 dbus-glib-1`" /> | 39 | <Add option="`pkg-config --libs gtk+-3.0 lib3270 v3270 gio-2.0 dbus-1 dbus-glib-1`" /> |
| 40 | </Linker> | 40 | </Linker> |
| 41 | + <Unit filename="src/constants.c"> | ||
| 42 | + <Option compilerVar="CC" /> | ||
| 43 | + </Unit> | ||
| 41 | <Unit filename="src/include/config.h.in" /> | 44 | <Unit filename="src/include/config.h.in" /> |
| 42 | <Unit filename="src/include/lib3270/ipc.h" /> | 45 | <Unit filename="src/include/lib3270/ipc.h" /> |
| 43 | <Unit filename="src/linux/getproperties.c"> | 46 | <Unit filename="src/linux/getproperties.c"> |
| @@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
| 1 | +/* | ||
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como main.c e possui - linhas de código. | ||
| 22 | + * | ||
| 23 | + * Referências: | ||
| 24 | + * | ||
| 25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | ||
| 26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | ||
| 27 | + * | ||
| 28 | + * Contatos: | ||
| 29 | + * | ||
| 30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 32 | + * | ||
| 33 | + */ | ||
| 34 | + | ||
| 35 | +#include <lib3270.h> | ||
| 36 | +#include <lib3270/actions.h> | ||
| 37 | +#include <lib3270/ipc.h> | ||
| 38 | + | ||
| 39 | +const IPC_METHOD_INT_ARG * ipc3270_get_int_arg_methods() { | ||
| 40 | + | ||
| 41 | + static const IPC_METHOD_INT_ARG int_arg_methods[] = { | ||
| 42 | + { "pfkey", lib3270_pfkey }, | ||
| 43 | + { "pakey", lib3270_pakey }, | ||
| 44 | + { NULL, NULL } | ||
| 45 | + }; | ||
| 46 | + | ||
| 47 | + return int_arg_methods; | ||
| 48 | + | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | + |
src/include/lib3270/ipc.h
| @@ -64,4 +64,11 @@ | @@ -64,4 +64,11 @@ | ||
| 64 | #define debug(...) /* __VA_ARGS */ | 64 | #define debug(...) /* __VA_ARGS */ |
| 65 | #endif | 65 | #endif |
| 66 | 66 | ||
| 67 | + typedef struct _ipc_method_int_arg { | ||
| 68 | + const gchar *name; | ||
| 69 | + int (*call)(H3270 *hSession, int keycode); | ||
| 70 | + } IPC_METHOD_INT_ARG; | ||
| 71 | + | ||
| 72 | + const IPC_METHOD_INT_ARG * ipc3270_get_int_arg_methods(); | ||
| 73 | + | ||
| 67 | #endif // PW3270_IPC_H_INCLUDED | 74 | #endif // PW3270_IPC_H_INCLUDED |
src/linux/methods.c
| @@ -50,14 +50,6 @@ ipc3270_method_call (GDBusConnection *connection, | @@ -50,14 +50,6 @@ ipc3270_method_call (GDBusConnection *connection, | ||
| 50 | gpointer user_data) | 50 | gpointer user_data) |
| 51 | { | 51 | { |
| 52 | 52 | ||
| 53 | - static const struct | ||
| 54 | - { | ||
| 55 | - const gchar *name; | ||
| 56 | - int (*call)(H3270 *hSession, int keycode); | ||
| 57 | - } int_methods[] = { | ||
| 58 | - { "pfkey", lib3270_pfkey }, | ||
| 59 | - { "pakey", lib3270_pakey } | ||
| 60 | - }; | ||
| 61 | 53 | ||
| 62 | size_t ix; | 54 | size_t ix; |
| 63 | g_autoptr (GError) error = NULL; | 55 | g_autoptr (GError) error = NULL; |
| @@ -87,6 +79,8 @@ ipc3270_method_call (GDBusConnection *connection, | @@ -87,6 +79,8 @@ ipc3270_method_call (GDBusConnection *connection, | ||
| 87 | } | 79 | } |
| 88 | 80 | ||
| 89 | // Check int methods | 81 | // Check int methods |
| 82 | + const IPC_METHOD_INT_ARG * int_methods = ipc3270_get_int_arg_methods(); | ||
| 83 | + | ||
| 90 | for(ix = 0; ix < G_N_ELEMENTS(int_methods); ix++) | 84 | for(ix = 0; ix < G_N_ELEMENTS(int_methods); ix++) |
| 91 | { | 85 | { |
| 92 | if(!g_ascii_strcasecmp(int_methods[ix].name,method_name)) { | 86 | if(!g_ascii_strcasecmp(int_methods[ix].name,method_name)) { |