Commit 522fe180f1b126ed4e69e79a2aaaea091f380c6d
1 parent
f1d41d3d
Exists in
master
and in
1 other branch
Implementando macros no widget do emulador
Showing
1 changed file
with
43 additions
and
0 deletions
Show diff stats
widget.c
... | ... | @@ -33,6 +33,7 @@ |
33 | 33 | #include <lib3270/session.h> |
34 | 34 | #include <lib3270/actions.h> |
35 | 35 | #include <lib3270/log.h> |
36 | + #include <lib3270/macros.h> | |
36 | 37 | #include <errno.h> |
37 | 38 | |
38 | 39 | #ifdef HAVE_MALLOC_H |
... | ... | @@ -1542,3 +1543,45 @@ gboolean v3270_is_connected(GtkWidget *widget) |
1542 | 1543 | g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); |
1543 | 1544 | return lib3270_connected(GTK_V3270(widget)->host) ? TRUE : FALSE; |
1544 | 1545 | } |
1546 | + | |
1547 | +int v3270_run_script(GtkWidget *widget, const gchar *script) | |
1548 | +{ | |
1549 | + gchar **ln; | |
1550 | + int f; | |
1551 | + H3270 * hSession; | |
1552 | + | |
1553 | + if(!script) | |
1554 | + return 0; | |
1555 | + | |
1556 | + g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL); | |
1557 | + | |
1558 | + hSession = v3270_get_session(widget); | |
1559 | + ln = g_strsplit(script,"\n",-1); | |
1560 | + | |
1561 | + for(f=0;ln[f];f++) | |
1562 | + { | |
1563 | + GError * error = NULL; | |
1564 | + gint argc = 0; | |
1565 | + gchar **argv = NULL; | |
1566 | + | |
1567 | + if(g_shell_parse_argv(g_strstrip(ln[f]),&argc,&argv,&error)) | |
1568 | + { | |
1569 | + gchar *rsp = lib3270_run_macro(hSession,(const gchar **) argv); | |
1570 | + if(rsp) | |
1571 | + g_free(rsp); | |
1572 | + } | |
1573 | + else | |
1574 | + { | |
1575 | + g_warning("Error parsing \"%s\": %s",g_strstrip(ln[f]),error->message); | |
1576 | + g_error_free(error); | |
1577 | + } | |
1578 | + | |
1579 | + if(argv) | |
1580 | + g_strfreev(argv); | |
1581 | + | |
1582 | + } | |
1583 | + | |
1584 | + g_strfreev(ln); | |
1585 | + | |
1586 | + return 0; | |
1587 | +} | ... | ... |