diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 1b977fd..6332905 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -883,9 +883,33 @@ */ LIB3270_EXPORT char * lib3270_get_resource_string(H3270 *hSession, const char *first_element, ...); + /** + * Get library version. + * + * @return Version of active library as string. + * + */ LIB3270_EXPORT const char * lib3270_get_version(void); + + /** + * Get source code revision. + * + * @return SVN revision of the current source code. + * + */ LIB3270_EXPORT const char * lib3270_get_revision(void); + /** + * Pop up an error dialog, based on an error number. + * + * @param hSession Session handle + * @param errn Error number (errno). + * @param fmt Message format + * @param ... Arguments for message + */ + LIB3270_EXPORT void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...); + + LIB3270_EXPORT char * lib3270_vsprintf(const char *fmt, va_list args); LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession); diff --git a/src/lib3270/api.h b/src/lib3270/api.h index 056dc5e..26aeea5 100644 --- a/src/lib3270/api.h +++ b/src/lib3270/api.h @@ -18,7 +18,7 @@ * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin * St, Fifth Floor, Boston, MA 02110-1301 USA * - * Este programa está nomeado como api.h e possui 444 linhas de código. + * Este programa está nomeado como api.h e possui - linhas de código. * * Contatos: * @@ -322,10 +322,6 @@ LOCAL_EXTERN const struct lib3270_option * get_3270_option_table(int sz); - /* Popups */ - LOCAL_EXTERN void Error(H3270 *session, const char *fmt, ...); - LOCAL_EXTERN void Warning(H3270 *session, const char *fmt, ...); - LOCAL_EXTERN void show_3270_popup_dialog(H3270 *session, PW3270_DIALOG type, const char *title, const char *msg, const char *fmt, ...); /* Set/Get screen contents */ #define find_field_attribute(s,a) lib3270_field_addr(s,a) @@ -347,9 +343,6 @@ // LOCAL_EXTERN int Get3270Socket(void); /* Misc calls */ - LOCAL_EXTERN void popup_an_error(H3270 *session, const char *fmt, ...); - LOCAL_EXTERN void popup_system_error(H3270 *session, const char *title, const char *message, const char *fmt, ...); - LOCAL_EXTERN void popup_a_sockerr(H3270 *session, char *fmt, ...); #define query_3270_terminal_status(void) lib3270_get_program_message(NULL) diff --git a/src/lib3270/iocalls.c b/src/lib3270/iocalls.c index 749bcf7..6f41a04 100644 --- a/src/lib3270/iocalls.c +++ b/src/lib3270/iocalls.c @@ -447,7 +447,7 @@ static int internal_event_dispatcher(H3270 *hSession, int block) if (ns < 0) { if (errno != EINTR) - Warning(NULL, "process_events: select() failed" ); + lib3270_popup_an_errno(hSession,errno,"%s",_( "select() failed when dispatching events")); #endif return processed_any; } diff --git a/src/lib3270/popupsc.h b/src/lib3270/popupsc.h index f5a8fce..f4886d2 100644 --- a/src/lib3270/popupsc.h +++ b/src/lib3270/popupsc.h @@ -1,18 +1,41 @@ /* - * Copyright 1999, 2000 by Paul Mattes. - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation. - * - * c3270, s3270 and tcl3270 are distributed in the hope that they will - * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file LICENSE - * for more details. + * "Software PW3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como popupsc.h e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) + * licinio@bb.com.br (Licínio Luis Branco) + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) + * */ -/* Non-display version of popupsc.h */ + /* Popup calls */ + + #define popup_an_errno(hSession, errn, fmt, ...) lib3270_popup_an_errno(hSession, errn, fmt, __VA_ARGS__) + + LOCAL_EXTERN void popup_an_error(H3270 *session, const char *fmt, ...) printflike(2,3); + LOCAL_EXTERN void popup_system_error(H3270 *session, const char *title, const char *message, const char *fmt, ...) printflike(4,5); + LOCAL_EXTERN void popup_a_sockerr(H3270 *session, char *fmt, ...) printflike(2,3); -LIB3270_INTERNAL void popup_an_errno(H3270 *session, int errn, const char *fmt, ...); -// LIB3270_INTERNAL void action_output(const char *fmt, ...); + LOCAL_EXTERN void Error(H3270 *session, const char *fmt, ...); + LOCAL_EXTERN void Warning(H3270 *session, const char *fmt, ...); diff --git a/src/lib3270/screen.c b/src/lib3270/screen.c index 7ef6e9c..40a354c 100644 --- a/src/lib3270/screen.c +++ b/src/lib3270/screen.c @@ -612,22 +612,6 @@ void status_untiming(H3270 *session) session->set_timer(session,0); } -void show_3270_popup_dialog(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, ...) -{ - CHECK_SESSION_HANDLE(session); - - trace("%s: title=%s msg=%s",__FUNCTION__,title,msg); - - if(!fmt) - fmt = ""; - - va_list arg_ptr; - va_start(arg_ptr, fmt); - popup_handler(session,session->widget,type,title,msg,fmt,arg_ptr); - va_end(arg_ptr); - -} - static int logpopup(H3270 *session, void *widget, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg) { #ifdef ANDROID diff --git a/src/lib3270/session.c b/src/lib3270/session.c index 742a0d9..1ba726f 100644 --- a/src/lib3270/session.c +++ b/src/lib3270/session.c @@ -45,6 +45,7 @@ #include "kybdc.h" #include "3270ds.h" #include "tablesc.h" +#include "popupsc.h" /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ diff --git a/src/lib3270/telnet.c b/src/lib3270/telnet.c index 799c76d..0a022e6 100644 --- a/src/lib3270/telnet.c +++ b/src/lib3270/telnet.c @@ -413,7 +413,7 @@ static union { } haddr; socklen_t ha_len = sizeof(haddr); -void popup_a_sockerr(H3270 *session, char *fmt, ...) +void popup_a_sockerr(H3270 *hSession, char *fmt, ...) { #if defined(_WIN32) const char *msg = win32_strerror(socket_errno()); @@ -421,14 +421,17 @@ void popup_a_sockerr(H3270 *session, char *fmt, ...) const char *msg = strerror(errno); #endif // WIN32 va_list args; - char buffer[4096]; + char *text; va_start(args, fmt); - vsnprintf(buffer, 4095, fmt, args); + text = lib3270_vsprintf(fmt, args); va_end(args); - popup_system_error(session, N_( "Network error" ), buffer, "%s", msg); + lib3270_write_log(hSession, "3270", "Network error:\n%s\n%s",text,msg); + lib3270_popup_dialog(hSession, LIB3270_NOTIFY_ERROR, _( "Network error" ), text, "%s", msg); + + lib3270_free(text); } #pragma pack(1) @@ -3031,7 +3034,7 @@ static int non_blocking(H3270 *session, Boolean on) if (SOCK_IOCTL(session->sock, FIONBIO, (int *) &i) < 0) { - popup_a_sockerr(session,N_( "ioctl(%s)" ), "FIONBIO"); + popup_a_sockerr(session,N_( "Error in ioctl(%s) when setting no blocking mode" ), "FIONBIO"); return -1; } @@ -3041,7 +3044,7 @@ static int non_blocking(H3270 *session, Boolean on) if ((f = fcntl(session->sock, F_GETFL, 0)) == -1) { - popup_an_errno(session,errno, N_( "fcntl(%s)" ), "F_GETFL" ); + popup_an_errno(session,errno, _( "Error in fcntl(%s) when setting non blocking mode" ), "F_GETFL" ); return -1; } @@ -3052,7 +3055,7 @@ static int non_blocking(H3270 *session, Boolean on) if (fcntl(session->sock, F_SETFL, f) < 0) { - popup_an_errno(session,errno, N_( "fcntl(%s)" ), "F_GETFL"); + popup_an_errno(session,errno, _( "Error in fcntl(%s) when setting non blocking mode" ), "F_SETFL"); return -1; } @@ -3174,7 +3177,7 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret) trace_dsn(hSession,"SSL Connect error in %s\nState: %s\nAlert: %s\n",err_buf,SSL_state_string_long(s),SSL_alert_type_string_long(ret)); - show_3270_popup_dialog( hSession, // H3270 *session, + lib3270_popup_dialog( hSession, // H3270 *session, PW3270_DIALOG_CRITICAL, // PW3270_DIALOG type, _( "SSL Connect error" ), // Title err_buf, // Message diff --git a/src/lib3270/util.c b/src/lib3270/util.c index 3392cb0..8d033ab 100644 --- a/src/lib3270/util.c +++ b/src/lib3270/util.c @@ -980,8 +980,7 @@ LIB3270_EXPORT const char * lib3270_get_revision(void) return build_rpq_revision; } -/* Pop up an error dialog, based on an error number. */ -void popup_an_errno(H3270 *session, int errn, const char *fmt, ...) +void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...) { va_list args; char * text; @@ -990,11 +989,12 @@ void popup_an_errno(H3270 *session, int errn, const char *fmt, ...) text = lib3270_vsprintf(fmt, args); va_end(args); - lib3270_write_log(session, "3270", "Error Popup:\n%s\nrc=%d (%s)",text,errn,strerror(errn)); + lib3270_write_log(hSession, "3270", "Error Popup:\n%s\nrc=%d (%s)",text,errn,strerror(errn)); - Error(session,text); + lib3270_popup_dialog(hSession, LIB3270_NOTIFY_ERROR, _( "Error" ), text, "%s (rc=%d)", errn, strerror(errn)); lib3270_free(text); + } #if defined(_WIN32) -- libgit2 0.21.2