diff --git a/lib3270.cbp b/lib3270.cbp index 1616244..f530e80 100644 --- a/lib3270.cbp +++ b/lib3270.cbp @@ -122,9 +122,6 @@ - - diff --git a/src/core/init.c b/src/core/init.c index 7cff532..31a31c0 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -137,14 +137,12 @@ int lib3270_unloaded(void) BOOL WINAPI DllMain(HANDLE GNUC_UNUSED(hinst), DWORD dwcallpurpose, LPVOID GNUC_UNUSED(lpvResvd)) { -// Trace("%s - Library %s",__FUNCTION__,(dwcallpurpose == DLL_PROCESS_ATTACH) ? "Loaded" : "Unloaded"); - switch(dwcallpurpose) { case DLL_PROCESS_ATTACH: + hEventLog = RegisterEventSource(NULL, LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME)); get_version_info(); lib3270_loaded(); - hEventLog = RegisterEventSource(NULL, LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME)); break; case DLL_PROCESS_DETACH: diff --git a/src/core/resolver.c b/src/core/resolver.c deleted file mode 100644 index b684a75..0000000 --- a/src/core/resolver.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * "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. 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 resolver.c e possui 254 linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) - * - */ - -/* - * resolver.c - * Hostname resolution. - */ - -#ifdef WIN32 - - // Compiling for WinXP or later: Expose getaddrinfo()/freeaddrinfo(). - #undef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - - #include - #include - #include - - #include - -#else - - #include - - #include - #include - #include - -#endif /*]*/ - -#include -#include -// #include "api.h" - -#include "resolverc.h" -#include "statusc.h" -#include "w3miscc.h" - -#pragma pack(1) -struct parms -{ - unsigned short sz; - const char *host; - char *portname; - unsigned short *pport; - struct sockaddr *sa; - socklen_t *sa_len; - char *errmsg; - int em_len; -}; -#pragma pack() - -/* - * Resolve a hostname and port. - * Returns 0 for success, -1 for fatal error (name resolution impossible), - * -2 for simple error (cannot resolve the name). - */ /* -static int cresolve_host_and_port(H3270 *h, struct parms *p) -{ -#if defined( HAVE_GETADDRINFO ) || defined(WIN32) - - struct addrinfo hints, *res; - int rc; - - // Use getaddrinfo() to resolve the hostname and port together. - (void) memset(&hints, '\0', sizeof(struct addrinfo)); - hints.ai_flags = 0; - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; - rc = getaddrinfo(p->host, p->portname, &hints, &res); - - if (rc) - { -#ifdef WIN32 - #warning gai_strerror on windows is returning message in local_charset, need to set it to utf-8! - snprintf(p->errmsg, p->em_len, _( "Error %d resolving %s" ) , rc, p->host); -#else - snprintf(p->errmsg, p->em_len, _( "Error resolving %s: %s" ), p->host, gai_strerror(rc)); -#endif // WIN32 - return -2; - } - - switch (res->ai_family) - { - case AF_INET: - *p->pport = ntohs(((struct sockaddr_in *)res->ai_addr)->sin_port); - break; - case AF_INET6: - *p->pport = ntohs(((struct sockaddr_in6 *)res->ai_addr)->sin6_port); - break; - default: - snprintf(p->errmsg, p->em_len, _( "%s: unknown family %d" ), p->host,res->ai_family); - freeaddrinfo(res); - return -1; - } - - (void) memcpy(p->sa, res->ai_addr, res->ai_addrlen); - *p->sa_len = res->ai_addrlen; - - freeaddrinfo(res); - -#else - - struct hostent *hp; - struct servent *sp; - unsigned short port; - unsigned long lport; - char *ptr; - struct sockaddr_in *sin = (struct sockaddr_in *) p->sa; - - // Get the port number. - lport = strtoul(p->portname, &ptr, 0); - if (ptr == p->portname || *ptr != '\0' || lport == 0L || lport & ~0xffff) - { - if (!(sp = getservbyname(p->portname, "tcp"))) - { - snprintf(p->errmsg, p->em_len,_( "Unknown port number or service: %s" ),p->portname); - return -1; - } - port = sp->s_port; - } - else - { - port = htons((unsigned short)lport); - } - *p->pport = ntohs(port); - - // Use gethostbyname() to resolve the hostname. - hp = gethostbyname(p->host); - if (hp == (struct hostent *) 0) - { - sin->sin_family = AF_INET; - sin->sin_addr.s_addr = inet_addr(p->host); - if (sin->sin_addr.s_addr == (unsigned long)-1) - { - snprintf(p->errmsg, p->em_len, _( "Unknown host:\n%s" ), p->host); - return -2; - } - } - else - { - sin->sin_family = hp->h_addrtype; - (void) memmove(&sin->sin_addr, hp->h_addr, hp->h_length); - } - sin->sin_port = port; - *p->sa_len = sizeof(struct sockaddr_in); - -#endif // HAVE_GETADDRINFO - - return 0; -} */ - diff --git a/src/core/session.c b/src/core/session.c index 0877175..e1773c6 100644 --- a/src/core/session.c +++ b/src/core/session.c @@ -207,7 +207,6 @@ static int print(H3270 *session, LIB3270_CONTENT_OPTION GNUC_UNUSED(mode)) { lib3270_write_log(session, "print", "%s", "Printing is unavailable"); lib3270_popup_dialog(session, LIB3270_NOTIFY_WARNING, _( "Can't print" ), _( "Unable to print" ), "%s", strerror(ENOTSUP)); - return errno = ENOTSUP; } @@ -218,6 +217,13 @@ static int save(H3270 *session, LIB3270_CONTENT_OPTION GNUC_UNUSED(mode), const return errno = ENOTSUP; } +static int load(H3270 *session, const char GNUC_UNUSED(*filename)) +{ + lib3270_write_log(session, "load", "%s", "Loading from file is unavailable"); + lib3270_popup_dialog(session, LIB3270_NOTIFY_WARNING, _( "Can't load" ), _( "Unable to load from file" ), "%s", strerror(ENOTSUP)); + return errno = ENOTSUP; +} + static void message(H3270 *session, LIB3270_NOTIFY GNUC_UNUSED(id), const char *title, const char *msg, const char *text) { #ifdef ANDROID @@ -289,7 +295,6 @@ static void set_peer_certificate)(const void GNUC_UNUSED(*cert)) static void default_update_luname(H3270 GNUC_UNUSED(*session), const char GNUC_UNUSED(*name)) { - } void lib3270_reset_callbacks(H3270 *hSession) @@ -322,9 +327,9 @@ void lib3270_reset_callbacks(H3270 *hSession) hSession->cbk.set_timer = set_timer; hSession->cbk.print = print; hSession->cbk.save = save; + hSession->cbk.load = load; hSession->cbk.set_peer_certificate = set_peer_certificate; hSession->cbk.update_luname = default_update_luname; - } static void lib3270_session_init(H3270 *hSession, const char *model, const char *charset) diff --git a/src/core/util.c b/src/core/util.c index c109860..b93848f 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -628,6 +628,14 @@ LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession) return hSession->cbk.print(hSession,LIB3270_CONTENT_COPY); } +LIB3270_EXPORT int lib3270_load(H3270 *hSession, const char *filename) +{ + if(check_online_session(hSession)) + return errno = ENOTCONN; + + return hSession->cbk.load(hSession, filename); +} + LIB3270_EXPORT int lib3270_save(H3270 *hSession, LIB3270_CONTENT_OPTION mode, const char *filename) { return hSession->cbk.save(hSession, mode, filename); @@ -635,6 +643,9 @@ LIB3270_EXPORT int lib3270_save(H3270 *hSession, LIB3270_CONTENT_OPTION mode, co LIB3270_EXPORT int lib3270_save_all(H3270 *hSession, const char *filename) { + if(check_online_session(hSession)) + return errno = ENOTCONN; + return lib3270_save(hSession,LIB3270_CONTENT_ALL,filename); } @@ -642,6 +653,7 @@ LIB3270_EXPORT int lib3270_save_selected(H3270 *hSession, const char *filename) { if(lib3270_has_selection(hSession)) return lib3270_save(hSession,LIB3270_CONTENT_SELECTED,filename); + return errno = ENODATA; } @@ -650,7 +662,6 @@ LIB3270_EXPORT int lib3270_save_copy(H3270 *hSession, const char *filename) return lib3270_save(hSession,LIB3270_CONTENT_COPY,filename); } - LIB3270_EXPORT LIB3270_POINTER lib3270_get_pointer(H3270 *hSession, int baddr) { static const struct _ptr { diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 1d8cab1..5702957 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -838,6 +838,16 @@ LIB3270_EXPORT int lib3270_save_copy(H3270 *hSession, const char *filename); /** + * @brief Paste from file. + * + * @param hSession Session Handle. + * @param filename File name. + * + * @return 0 if ok, error code if not. + */ + LIB3270_EXPORT int lib3270_load(H3270 *hSession, const char *filename); + + /** * @brief Get buffer contents. * * @param h Session handle. diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h index 29e5245..bc4c4b2 100644 --- a/src/include/lib3270/session.h +++ b/src/include/lib3270/session.h @@ -74,8 +74,10 @@ void (*set_selection)(H3270 *session, unsigned char on); void (*ctlr_done)(H3270 *session); void (*autostart)(H3270 *session); + int (*print)(H3270 *session, LIB3270_CONTENT_OPTION mode); int (*save)(H3270 *session, LIB3270_CONTENT_OPTION mode, const char *filename); + int (*load)(H3270 *hSession, const char *filename); void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); void (*popup)(H3270 *session, LIB3270_NOTIFY id, const char *title, const char *msg, const char *fmt, va_list); diff --git a/src/ssl/negotiate.c b/src/ssl/negotiate.c index fae2f91..b9dbd9b 100644 --- a/src/ssl/negotiate.c +++ b/src/ssl/negotiate.c @@ -313,7 +313,6 @@ int ssl_negotiate(H3270 *hSession) else lib3270_popup_dialog(hSession, LIB3270_NOTIFY_ERROR, msg.title, msg.text, "%s", ERR_reason_error_string(msg.error)); - return rc; } -- libgit2 0.21.2