From c8800168aa381c51828a55f3405ea13af8cd4a96 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Wed, 2 May 2012 12:15:45 +0000 Subject: [PATCH] Ajustando tradução na tela de help, incluindo lista de argumentos aceitos no popup de argumento inválido para facilitar o uso em windows, removendo macros para chamadas de log --- configure.ac | 12 ++++++++++++ src/gtk/main.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++------------------------------------ src/lib3270/api.h | 6 +++--- src/lib3270/glue.c | 2 +- src/lib3270/host.c | 2 +- src/lib3270/selection.c | 3 --- src/lib3270/telnet.c | 4 +++- src/lib3270/util.c | 2 +- src/lib3270/w3miscc.h | 3 +-- 9 files changed, 69 insertions(+), 48 deletions(-) diff --git a/configure.ac b/configure.ac index 061d9cc..9bed9d1 100644 --- a/configure.ac +++ b/configure.ac @@ -243,6 +243,18 @@ AC_SEARCH_LIBS( [sin], [m], AC_DEFINE(HAVE_LIBM), AC_MSG_NOTICE([libm not presen AC_SUBST(SOCKET_LIBS) +#--[ Optional ]--------------------------------------------------------------------------------------------------------------------------------------------- + +AC_ARG_WITH([php-config], [AS_HELP_STRING([--with-php-config], [Path to php-config tool])], [ PHPCONFIG="$withval" ],[ AC_PATH_TOOL(PHPCONFIG, php-configX, , $PATH) ]) + +if test -z "${PHPCONFIG}"; then + AC_MSG_NOTICE([Program php-config not found. Use --with-php-config=path to specify absolute path to the php-config tool.]) +else + AC_DEFINE(HAVE_PHP) +fi + +AC_SUBST(PHPCONFIG) + #--[ Pre-reqs ]----------------------------------------------------------------------------------------------------------------------------------------------- AC_SUBST(LIB3270_REQUIRES) diff --git a/src/gtk/main.c b/src/gtk/main.c index c6ee6e5..fa6278c 100644 --- a/src/gtk/main.c +++ b/src/gtk/main.c @@ -103,42 +103,7 @@ int main(int argc, char *argv[]) static const gchar * host = NULL; int rc = 0; - // Process command-line options - { - static const GOptionEntry app_options[] = - { - { "appname", 'a', 0, G_OPTION_ARG_STRING, &appname, N_( "Application name" ), PACKAGE_NAME }, - { "host", 'h', 0, G_OPTION_ARG_STRING, &host, N_( "Host to connect"), NULL }, - { NULL } - }; - - GOptionContext * options = g_option_context_new (_("- 3270 Emulator for Gtk")); - GError * error = NULL; - - g_option_context_add_main_entries(options, app_options, NULL); - - gtk_init(&argc, &argv); - - if(!g_option_context_parse( options, &argc, &argv, &error )) - { - GtkWidget *dialog = gtk_message_dialog_new( NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CANCEL, - "%s", _( "Option parsing failed." )); - - gtk_window_set_title(GTK_WINDOW(dialog),_( "Parse error" )); - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", error->message); - - gtk_dialog_run(GTK_DIALOG (dialog)); - gtk_widget_destroy(dialog); - - g_error_free(error); - - return -1; - } - } - + // Setup locale #ifdef LC_ALL setlocale( LC_ALL, "" ); #endif @@ -172,6 +137,52 @@ int main(int argc, char *argv[]) bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"); textdomain(PACKAGE_NAME); + + // Process command-line options + { + static const GOptionEntry app_options[] = + { + { "appname", 'a', 0, G_OPTION_ARG_STRING, &appname, N_( "Application name" ), PACKAGE_NAME }, + { "host", 'h', 0, G_OPTION_ARG_STRING, &host, N_( "Host to connect"), NULL }, + { NULL } + }; + + GOptionContext * options = g_option_context_new (_("- 3270 Emulator for Gtk")); + GError * error = NULL; + + g_option_context_add_main_entries(options, app_options, NULL); + + gtk_init(&argc, &argv); + + if(!g_option_context_parse( options, &argc, &argv, &error )) + { + int f; + GString * str; + GtkWidget * dialog = gtk_message_dialog_new( NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CANCEL, + "%s", error->message); + + gtk_window_set_title(GTK_WINDOW(dialog),_( "Parse error" )); + + str = g_string_new( _( "Valid options:\n\n" ) ); + + for(f=0;app_options[f].description;f++) + g_string_append_printf(str,"--%-20s\t%s\n",app_options[f].long_name,gettext(app_options[f].description)); + + gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog), "%s", str->str); + + gtk_dialog_run(GTK_DIALOG (dialog)); + gtk_widget_destroy(dialog); + + g_error_free(error); + g_string_free(str,TRUE); + + return -1; + } + } + g_set_application_name(appname); rc = initialize(); diff --git a/src/lib3270/api.h b/src/lib3270/api.h index e0d98c9..02a43bf 100644 --- a/src/lib3270/api.h +++ b/src/lib3270/api.h @@ -99,8 +99,8 @@ #include - #define WriteLog(module,fmt, ...) lib3270_write_log(NULL,module,fmt,__VA_ARGS__) - #define WriteRCLog(module,rc,fmt, ...) lib3270_write_rc(NULL,module,fmt,__VA_ARGS__) +// #define WriteLog(module,fmt, ...) lib3270_write_log(NULL,module,fmt,__VA_ARGS__) +// #define WriteRCLog(module,rc,fmt, ...) lib3270_write_rc(NULL,module,fmt,__VA_ARGS__) #ifdef LIB3270_MODULE_NAME #define Log(fmt, ...) lib3270_write_log(NULL,LIB3270_MODULE_NAME,fmt,__VA_ARGS__) @@ -367,7 +367,7 @@ LOCAL_EXTERN int emulate_input(char *s, int len, int pasting); /* Network related calls */ - LOCAL_EXTERN int Get3270Socket(void); +// LOCAL_EXTERN int Get3270Socket(void); /* Misc calls */ LOCAL_EXTERN void popup_an_error(H3270 *session, const char *fmt, ...); diff --git a/src/lib3270/glue.c b/src/lib3270/glue.c index 98926d9..74fb602 100644 --- a/src/lib3270/glue.c +++ b/src/lib3270/glue.c @@ -819,7 +819,7 @@ void popup_an_errno(int errn, const char *fmt, ...) (void) vsprintf(vmsgbuf, fmt, args); va_end(args); - WriteLog("3270", "Error Popup:\n%s\nrc=%d (%s)",vmsgbuf,errn,strerror(errn)); + lib3270_write_log("3270", "Error Popup:\n%s\nrc=%d (%s)",vmsgbuf,errn,strerror(errn)); Error(NULL,vmsgbuf); } diff --git a/src/lib3270/host.c b/src/lib3270/host.c index 9c082ed..c4a6f6f 100644 --- a/src/lib3270/host.c +++ b/src/lib3270/host.c @@ -645,7 +645,7 @@ int lib3270_connect(H3270 *h, const char *n, int wait) */ static void try_reconnect(H3270 *session) { - WriteLog("3270","Starting auto-reconnect (Host: %s)",session->full_current_host ? session->full_current_host : "-"); + lib3270_write_log("3270","Starting auto-reconnect (Host: %s)",session->full_current_host ? session->full_current_host : "-"); session->auto_reconnect_inprogress = False; lib3270_reconnect(session,0); } diff --git a/src/lib3270/selection.c b/src/lib3270/selection.c index c57af9d..aaa0e98 100644 --- a/src/lib3270/selection.c +++ b/src/lib3270/selection.c @@ -448,9 +448,6 @@ LIB3270_EXPORT char * lib3270_get_region(H3270 *h, int start_pos, int end_pos, u return realloc(text,sz); } - - - LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len) { char * buffer; diff --git a/src/lib3270/telnet.c b/src/lib3270/telnet.c index 3babbf5..9b9814b 100644 --- a/src/lib3270/telnet.c +++ b/src/lib3270/telnet.c @@ -3277,7 +3277,7 @@ static void client_info_callback(INFO_CONST SSL *s, int where, int ret) if (ret == 0) { trace_dsn("SSL_connect: failed in %s\n",SSL_state_string_long(s)); - WriteLog("SSL","connect failed in %s (Alert: %s)",SSL_state_string_long(s),SSL_alert_type_string_long(ret)); + lib3270_write_log("SSL","connect failed in %s (Alert: %s)",SSL_state_string_long(s),SSL_alert_type_string_long(ret)); } else if (ret < 0) { @@ -3452,7 +3452,9 @@ LIB3270_EXPORT int lib3270_get_ssl_state(H3270 *h) #endif } +/* int Get3270Socket(void) { return h3270.sock; } +*/ diff --git a/src/lib3270/util.c b/src/lib3270/util.c index 042b3ac..d914ae8 100644 --- a/src/lib3270/util.c +++ b/src/lib3270/util.c @@ -76,7 +76,7 @@ int get_version_info(void) info.dwOSVersionInfoSize = sizeof(info); if(GetVersionEx(&info) == 0) { - WriteLog("lib3270","%s","Can't get Windows version"); + lib3270_write_log("lib3270","%s","Can't get Windows version"); return -1; } diff --git a/src/lib3270/w3miscc.h b/src/lib3270/w3miscc.h index b87daa3..a774a24 100644 --- a/src/lib3270/w3miscc.h +++ b/src/lib3270/w3miscc.h @@ -19,8 +19,7 @@ #if defined(_WIN32) /*[*/ #if defined(_WS2TCPIP_H) /*[*/ -LIB3270_INTERNAL const char *inet_ntop(int af, const void *src, char *dst, - socklen_t cnt); +LIB3270_INTERNAL const char *inet_ntop(int af, const void *src, char *dst,socklen_t cnt); #endif /*]*/ LIB3270_INTERNAL const char *win32_strerror(int e); -- libgit2 0.21.2