Commit d0b858337543d62ff6a6abbf7fe1a69cd38b8e3c
1 parent
6e56dafb
Exists in
master
and in
3 other branches
Incluindo suporte à chamada de ações pelo nome (para uso em scripts)
Showing
2 changed files
with
45 additions
and
100 deletions
Show diff stats
actions.c
| @@ -18,122 +18,67 @@ | @@ -18,122 +18,67 @@ | ||
| 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple |
| 19 | * Place, Suite 330, Boston, MA, 02111-1307, USA | 19 | * Place, Suite 330, Boston, MA, 02111-1307, USA |
| 20 | * | 20 | * |
| 21 | - * Este programa está nomeado como actions.c e possui 877 linhas de código. | 21 | + * Este programa está nomeado como actions.c e possui - linhas de código. |
| 22 | * | 22 | * |
| 23 | * Contatos: | 23 | * Contatos: |
| 24 | * | 24 | * |
| 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) |
| 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
| 27 | - * licinio@bb.com.br (Licínio Luis Branco) | ||
| 28 | - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | ||
| 29 | - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) | ||
| 30 | * | 27 | * |
| 31 | */ | 28 | */ |
| 32 | 29 | ||
| 33 | -/* | ||
| 34 | - * actions.c | ||
| 35 | - * The X actions table and action debugging code. | ||
| 36 | - */ | ||
| 37 | - | ||
| 38 | #include "globals.h" | 30 | #include "globals.h" |
| 39 | -#include "appres.h" | 31 | +#include <lib3270/trace.h> |
| 40 | 32 | ||
| 41 | -#include "actionsc.h" | ||
| 42 | -#include "hostc.h" | ||
| 43 | -#include "kybdc.h" | ||
| 44 | -#include "popupsc.h" | ||
| 45 | -#include "printc.h" | ||
| 46 | -#include "resources.h" | ||
| 47 | -#include "togglesc.h" | ||
| 48 | -#include "trace_dsc.h" | ||
| 49 | -#include "utilc.h" | ||
| 50 | -#include "xioc.h" | 33 | +/*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ |
| 51 | 34 | ||
| 52 | -#if defined(X3270_FT) /*[*/ | ||
| 53 | -#include "ftc.h" | ||
| 54 | -#endif /*]*/ | ||
| 55 | -// #if defined(X3270_DISPLAY) | ||
| 56 | -// #include "keypadc.h" | ||
| 57 | -//#endif | ||
| 58 | -#if defined(X3270_DISPLAY) || defined(C3270) || defined(WC3270) /*[*/ | ||
| 59 | -#include "screenc.h" | ||
| 60 | -#endif /*]*/ | 35 | +/*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/ |
| 61 | 36 | ||
| 62 | -#error Deprecated | 37 | +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ |
| 63 | 38 | ||
| 64 | -/* | 39 | +/** |
| 40 | + * @brief Launch an action by name. | ||
| 41 | + * | ||
| 42 | + */ | ||
| 43 | +LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name) | ||
| 44 | +{ | ||
| 45 | + #undef DECLARE_LIB3270_ACTION | ||
| 46 | + #undef DECLARE_LIB3270_CLEAR_SELECTION_ACTION | ||
| 47 | + #undef DECLARE_LIB3270_KEY_ACTION | ||
| 48 | + #undef DECLARE_LIB3270_CURSOR_ACTION | ||
| 49 | + #undef DECLARE_LIB3270_FKEY_ACTION | ||
| 65 | 50 | ||
| 66 | -#if defined(X3270_DISPLAY) | ||
| 67 | -#include <X11/keysym.h> | 51 | + #define DECLARE_LIB3270_ACTION( name ) { #name, lib3270_ ## name }, |
| 52 | + #define DECLARE_LIB3270_CLEAR_SELECTION_ACTION( name ) { #name, lib3270_ ## name }, | ||
| 53 | + #define DECLARE_LIB3270_KEY_ACTION( name ) { #name, lib3270_ ## name }, | ||
| 54 | + #define DECLARE_LIB3270_CURSOR_ACTION( name ) { #name, lib3270_cursor_ ## name }, | ||
| 55 | + #define DECLARE_LIB3270_FKEY_ACTION( name ) // name | ||
| 68 | 56 | ||
| 69 | -#define MODMAP_SIZE 8 | ||
| 70 | -#define MAP_SIZE 13 | ||
| 71 | -#define MAX_MODS_PER 4 | ||
| 72 | -static struct { | ||
| 73 | - const char *name[MAX_MODS_PER]; | ||
| 74 | - unsigned int mask; | ||
| 75 | - Boolean is_meta; | ||
| 76 | -} skeymask[MAP_SIZE] = { | ||
| 77 | - { { "Shift" }, ShiftMask, False }, | ||
| 78 | - { { (char *)NULL } //, LockMask, False }, | ||
| 79 | - { { "Ctrl" }, ControlMask, False }, | ||
| 80 | - { { CN }, Mod1Mask, False }, | ||
| 81 | - { { CN }, Mod2Mask, False }, | ||
| 82 | - { { CN }, Mod3Mask, False }, | ||
| 83 | - { { CN }, Mod4Mask, False }, | ||
| 84 | - { { CN }, Mod5Mask, False }, | ||
| 85 | - { { "Button1" }, Button1Mask, False }, | ||
| 86 | - { { "Button2" }, Button2Mask, False }, | ||
| 87 | - { { "Button3" }, Button3Mask, False }, | ||
| 88 | - { { "Button4" }, Button4Mask, False }, | ||
| 89 | - { { "Button5" }, Button5Mask, False } | ||
| 90 | -}; | ||
| 91 | -static Boolean know_mods = False; | ||
| 92 | -#endif */ | 57 | + static const struct _action |
| 58 | + { | ||
| 59 | + const char * name; | ||
| 60 | + int (*call)(H3270 *h); | ||
| 61 | + } action[] = | ||
| 62 | + { | ||
| 63 | + #include <lib3270/action_table.h> | ||
| 64 | + }; | ||
| 93 | 65 | ||
| 94 | -/* Actions that are aliases for other actions. */ | ||
| 95 | -/* | ||
| 96 | -static char *aliased_actions[] = { | ||
| 97 | - "Close", "HardPrint", "Open", NULL | ||
| 98 | -}; | ||
| 99 | -*/ | 66 | + size_t f; |
| 100 | 67 | ||
| 101 | -/* | ||
| 102 | -enum iaction ia_cause; | ||
| 103 | -const char *ia_name[] = { | ||
| 104 | - "String", "Paste", "Screen redraw", "Keypad", "Default", "Key", | ||
| 105 | - "Macro", "Script", "Peek", "Typeahead", "File transfer", "Command", | ||
| 106 | - "Keymap", "Idle" | ||
| 107 | -}; | ||
| 108 | -*/ | 68 | + CHECK_SESSION_HANDLE(hSession); |
| 109 | 69 | ||
| 110 | -/* | ||
| 111 | - * Return a name for an action. | ||
| 112 | - */ /* | ||
| 113 | -const char * action_name(XtActionProc action) | ||
| 114 | -{ | ||
| 115 | - // TODO (perry#1#): Remove all calls to action_name; move all action processing to main program. | ||
| 116 | - return "Action"; | ||
| 117 | -} | ||
| 118 | -*/ | ||
| 119 | -/* | ||
| 120 | - * Check the number of argument to an action, and possibly pop up a usage | ||
| 121 | - * message. | ||
| 122 | - * | ||
| 123 | - * Returns 0 if the argument count is correct, -1 otherwise. | ||
| 124 | - */ /* | ||
| 125 | -int | ||
| 126 | -check_usage(XtActionProc action, Cardinal nargs, Cardinal nargs_min, | ||
| 127 | - Cardinal nargs_max) | ||
| 128 | -{ | ||
| 129 | - if (nargs >= nargs_min && nargs <= nargs_max) | ||
| 130 | - return 0; | ||
| 131 | - if (nargs_min == nargs_max) | ||
| 132 | - popup_an_error("Action requires %d argument%s",action, nargs_min, nargs_min == 1 ? "" : "s"); | ||
| 133 | - else | ||
| 134 | - popup_an_error("Action requires %d or %d arguments",nargs_min, nargs_max); | ||
| 135 | -// cancel_if_idle_command(); | ||
| 136 | - return -1; | ||
| 137 | -} */ | 70 | + for(f=0; f< (sizeof(action)/sizeof(action[0])); f++) |
| 71 | + { | ||
| 72 | + if(!strcasecmp(name,action[f].name)) | ||
| 73 | + { | ||
| 74 | + lib3270_trace_event(hSession,"Action %s activated\n",name); | ||
| 75 | + return action[f].call(hSession); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + } | ||
| 138 | 79 | ||
| 80 | + lib3270_trace_event(hSession,"Unknown action %s\n",name); | ||
| 81 | + errno = ENOENT; | ||
| 82 | + return -1; | ||
| 139 | 83 | ||
| 84 | +} |
sources.mak
| @@ -28,7 +28,7 @@ | @@ -28,7 +28,7 @@ | ||
| 28 | TERMINAL_SOURCES = bounds.c ctlr.c util.c toggles.c screen.c selection.c kybd.c telnet.c \ | 28 | TERMINAL_SOURCES = bounds.c ctlr.c util.c toggles.c screen.c selection.c kybd.c telnet.c \ |
| 29 | host.c sf.c ansi.c resolver.c charset.c \ | 29 | host.c sf.c ansi.c resolver.c charset.c \ |
| 30 | version.c session.c state.c html.c trace_ds.c see.c \ | 30 | version.c session.c state.c html.c trace_ds.c see.c \ |
| 31 | - paste.c ssl.c | 31 | + paste.c ssl.c actions.c |
| 32 | 32 | ||
| 33 | # tables.c utf8.c | 33 | # tables.c utf8.c |
| 34 | 34 |