Commit 2ef5a0e87e1817346e2ebec3231336237203ee14

Authored by perry.werneck@gmail.com
1 parent 24c5f876

Incluindo tabela de actions no processador de macros

Showing 1 changed file with 40 additions and 1 deletions   Show diff stats
src/lib3270/macros.c
@@ -33,12 +33,12 @@ @@ -33,12 +33,12 @@
33 #include <errno.h> 33 #include <errno.h>
34 #include <string.h> 34 #include <string.h>
35 #include <stdio.h> 35 #include <stdio.h>
36 -// #include <malloc.h>  
37 #include <lib3270.h> 36 #include <lib3270.h>
38 #include <lib3270/macros.h> 37 #include <lib3270/macros.h>
39 #include <stdlib.h> 38 #include <stdlib.h>
40 #include <strings.h> 39 #include <strings.h>
41 #include "globals.h" 40 #include "globals.h"
  41 + #include "utilc.h"
42 #include "api.h" 42 #include "api.h"
43 43
44 /*--[ Structs & Defines ]----------------------------------------------------------------------------*/ 44 /*--[ Structs & Defines ]----------------------------------------------------------------------------*/
@@ -328,6 +328,31 @@ @@ -328,6 +328,31 @@
328 {NULL, NULL} 328 {NULL, NULL}
329 }; 329 };
330 330
  331 + #undef DECLARE_LIB3270_ACTION
  332 + #undef DECLARE_LIB3270_CLEAR_SELECTION_ACTION
  333 + #undef DECLARE_LIB3270_KEY_ACTION
  334 + #undef DECLARE_LIB3270_CURSOR_ACTION
  335 + #undef DECLARE_LIB3270_FKEY_ACTION
  336 +
  337 + static const struct _action
  338 + {
  339 + const char *name;
  340 + int (*exec)(H3270 *session);
  341 + }
  342 + action[] =
  343 + {
  344 + #define DECLARE_LIB3270_ACTION( name ) { #name, lib3270_ ## name },
  345 + #define DECLARE_LIB3270_CLEAR_SELECTION_ACTION( name ) { #name, lib3270_ ## name },
  346 + #define DECLARE_LIB3270_KEY_ACTION( name ) { #name, lib3270_ ## name },
  347 + #define DECLARE_LIB3270_CURSOR_ACTION( name ) { #name, lib3270_cursor_ ## name },
  348 + #define DECLARE_LIB3270_FKEY_ACTION( name ) /* */
  349 +
  350 + #include <lib3270/action_table.h>
  351 +
  352 + {NULL, NULL}
  353 + };
  354 +
  355 +
331 int argc; 356 int argc;
332 int f; 357 int f;
333 358
@@ -343,6 +368,20 @@ @@ -343,6 +368,20 @@
343 return cmd[f].exec(session,argc,argv); 368 return cmd[f].exec(session,argc,argv);
344 } 369 }
345 370
  371 + if(argc == 1)
  372 + {
  373 + // Search for action
  374 + for(f=0;action[f].name;f++)
  375 + {
  376 + if(!strcasecmp(action[f].name,argv[0]))
  377 + {
  378 + int rc = action[f].exec(session);
  379 + return xs_buffer("%d",rc);
  380 + }
  381 + }
  382 +
  383 + }
  384 +
346 // Not found, return NULL 385 // Not found, return NULL
347 return NULL; 386 return NULL;
348 } 387 }