From 2ef5a0e87e1817346e2ebec3231336237203ee14 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 28 May 2012 10:51:37 +0000 Subject: [PATCH] Incluindo tabela de actions no processador de macros --- src/lib3270/macros.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/lib3270/macros.c b/src/lib3270/macros.c index 54c1616..5efbc95 100644 --- a/src/lib3270/macros.c +++ b/src/lib3270/macros.c @@ -33,12 +33,12 @@ #include #include #include -// #include #include #include #include #include #include "globals.h" + #include "utilc.h" #include "api.h" /*--[ Structs & Defines ]----------------------------------------------------------------------------*/ @@ -328,6 +328,31 @@ {NULL, NULL} }; + #undef DECLARE_LIB3270_ACTION + #undef DECLARE_LIB3270_CLEAR_SELECTION_ACTION + #undef DECLARE_LIB3270_KEY_ACTION + #undef DECLARE_LIB3270_CURSOR_ACTION + #undef DECLARE_LIB3270_FKEY_ACTION + + static const struct _action + { + const char *name; + int (*exec)(H3270 *session); + } + action[] = + { + #define DECLARE_LIB3270_ACTION( name ) { #name, lib3270_ ## name }, + #define DECLARE_LIB3270_CLEAR_SELECTION_ACTION( name ) { #name, lib3270_ ## name }, + #define DECLARE_LIB3270_KEY_ACTION( name ) { #name, lib3270_ ## name }, + #define DECLARE_LIB3270_CURSOR_ACTION( name ) { #name, lib3270_cursor_ ## name }, + #define DECLARE_LIB3270_FKEY_ACTION( name ) /* */ + + #include + + {NULL, NULL} + }; + + int argc; int f; @@ -343,6 +368,20 @@ return cmd[f].exec(session,argc,argv); } + if(argc == 1) + { + // Search for action + for(f=0;action[f].name;f++) + { + if(!strcasecmp(action[f].name,argv[0])) + { + int rc = action[f].exec(session); + return xs_buffer("%d",rc); + } + } + + } + // Not found, return NULL return NULL; } -- libgit2 0.21.2