Commit 7a080aaac7efb9d7c8c1f9c3bc80e91604d4f035
1 parent
a2a4a18c
Exists in
master
and in
3 other branches
Removing unused files
Small adjustments in windows logging Adding bindings for the "load from file" method.
Showing
8 changed files
with
33 additions
and
193 deletions
Show diff stats
lib3270.cbp
@@ -122,9 +122,6 @@ | @@ -122,9 +122,6 @@ | ||
122 | <Unit filename="src/core/properties.c"> | 122 | <Unit filename="src/core/properties.c"> |
123 | <Option compilerVar="CC" /> | 123 | <Option compilerVar="CC" /> |
124 | </Unit> | 124 | </Unit> |
125 | - <Unit filename="src/core/resolver.c"> | ||
126 | - <Option compilerVar="CC" /> | ||
127 | - </Unit> | ||
128 | <Unit filename="src/core/resources.c"> | 125 | <Unit filename="src/core/resources.c"> |
129 | <Option compilerVar="CC" /> | 126 | <Option compilerVar="CC" /> |
130 | </Unit> | 127 | </Unit> |
src/core/init.c
@@ -137,14 +137,12 @@ int lib3270_unloaded(void) | @@ -137,14 +137,12 @@ int lib3270_unloaded(void) | ||
137 | 137 | ||
138 | BOOL WINAPI DllMain(HANDLE GNUC_UNUSED(hinst), DWORD dwcallpurpose, LPVOID GNUC_UNUSED(lpvResvd)) | 138 | BOOL WINAPI DllMain(HANDLE GNUC_UNUSED(hinst), DWORD dwcallpurpose, LPVOID GNUC_UNUSED(lpvResvd)) |
139 | { | 139 | { |
140 | -// Trace("%s - Library %s",__FUNCTION__,(dwcallpurpose == DLL_PROCESS_ATTACH) ? "Loaded" : "Unloaded"); | ||
141 | - | ||
142 | switch(dwcallpurpose) | 140 | switch(dwcallpurpose) |
143 | { | 141 | { |
144 | case DLL_PROCESS_ATTACH: | 142 | case DLL_PROCESS_ATTACH: |
143 | + hEventLog = RegisterEventSource(NULL, LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME)); | ||
145 | get_version_info(); | 144 | get_version_info(); |
146 | lib3270_loaded(); | 145 | lib3270_loaded(); |
147 | - hEventLog = RegisterEventSource(NULL, LIB3270_STRINGIZE_VALUE_OF(LIB3270_NAME)); | ||
148 | break; | 146 | break; |
149 | 147 | ||
150 | case DLL_PROCESS_DETACH: | 148 | case DLL_PROCESS_DETACH: |
src/core/resolver.c
@@ -1,182 +0,0 @@ | @@ -1,182 +0,0 @@ | ||
1 | -/* | ||
2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. | ||
5 | - * | ||
6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
7 | - * | ||
8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
10 | - * Free Software Foundation. | ||
11 | - * | ||
12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
15 | - * obter mais detalhes. | ||
16 | - * | ||
17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | - * | ||
21 | - * Este programa está nomeado como resolver.c e possui 254 linhas de código. | ||
22 | - * | ||
23 | - * Contatos: | ||
24 | - * | ||
25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
27 | - * licinio@bb.com.br (Licínio Luis Branco) | ||
28 | - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | ||
29 | - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) | ||
30 | - * | ||
31 | - */ | ||
32 | - | ||
33 | -/* | ||
34 | - * resolver.c | ||
35 | - * Hostname resolution. | ||
36 | - */ | ||
37 | - | ||
38 | -#ifdef WIN32 | ||
39 | - | ||
40 | - // Compiling for WinXP or later: Expose getaddrinfo()/freeaddrinfo(). | ||
41 | - #undef _WIN32_WINNT | ||
42 | - #define _WIN32_WINNT 0x0501 | ||
43 | - | ||
44 | - #include <winsock2.h> | ||
45 | - #include <windows.h> | ||
46 | - #include <ws2tcpip.h> | ||
47 | - | ||
48 | - #include <lib3270-internals.h> | ||
49 | - | ||
50 | -#else | ||
51 | - | ||
52 | - #include <lib3270-internals.h> | ||
53 | - | ||
54 | - #include <sys/socket.h> | ||
55 | - #include <netinet/in.h> | ||
56 | - #include <netdb.h> | ||
57 | - | ||
58 | -#endif /*]*/ | ||
59 | - | ||
60 | -#include <stdio.h> | ||
61 | -#include <string.h> | ||
62 | -// #include "api.h" | ||
63 | - | ||
64 | -#include "resolverc.h" | ||
65 | -#include "statusc.h" | ||
66 | -#include "w3miscc.h" | ||
67 | - | ||
68 | -#pragma pack(1) | ||
69 | -struct parms | ||
70 | -{ | ||
71 | - unsigned short sz; | ||
72 | - const char *host; | ||
73 | - char *portname; | ||
74 | - unsigned short *pport; | ||
75 | - struct sockaddr *sa; | ||
76 | - socklen_t *sa_len; | ||
77 | - char *errmsg; | ||
78 | - int em_len; | ||
79 | -}; | ||
80 | -#pragma pack() | ||
81 | - | ||
82 | -/* | ||
83 | - * Resolve a hostname and port. | ||
84 | - * Returns 0 for success, -1 for fatal error (name resolution impossible), | ||
85 | - * -2 for simple error (cannot resolve the name). | ||
86 | - */ /* | ||
87 | -static int cresolve_host_and_port(H3270 *h, struct parms *p) | ||
88 | -{ | ||
89 | -#if defined( HAVE_GETADDRINFO ) || defined(WIN32) | ||
90 | - | ||
91 | - struct addrinfo hints, *res; | ||
92 | - int rc; | ||
93 | - | ||
94 | - // Use getaddrinfo() to resolve the hostname and port together. | ||
95 | - (void) memset(&hints, '\0', sizeof(struct addrinfo)); | ||
96 | - hints.ai_flags = 0; | ||
97 | - hints.ai_family = PF_UNSPEC; | ||
98 | - hints.ai_socktype = SOCK_STREAM; | ||
99 | - hints.ai_protocol = IPPROTO_TCP; | ||
100 | - rc = getaddrinfo(p->host, p->portname, &hints, &res); | ||
101 | - | ||
102 | - if (rc) | ||
103 | - { | ||
104 | -#ifdef WIN32 | ||
105 | - #warning gai_strerror on windows is returning message in local_charset, need to set it to utf-8! | ||
106 | - snprintf(p->errmsg, p->em_len, _( "Error %d resolving %s" ) , rc, p->host); | ||
107 | -#else | ||
108 | - snprintf(p->errmsg, p->em_len, _( "Error resolving %s: %s" ), p->host, gai_strerror(rc)); | ||
109 | -#endif // WIN32 | ||
110 | - return -2; | ||
111 | - } | ||
112 | - | ||
113 | - switch (res->ai_family) | ||
114 | - { | ||
115 | - case AF_INET: | ||
116 | - *p->pport = ntohs(((struct sockaddr_in *)res->ai_addr)->sin_port); | ||
117 | - break; | ||
118 | - case AF_INET6: | ||
119 | - *p->pport = ntohs(((struct sockaddr_in6 *)res->ai_addr)->sin6_port); | ||
120 | - break; | ||
121 | - default: | ||
122 | - snprintf(p->errmsg, p->em_len, _( "%s: unknown family %d" ), p->host,res->ai_family); | ||
123 | - freeaddrinfo(res); | ||
124 | - return -1; | ||
125 | - } | ||
126 | - | ||
127 | - (void) memcpy(p->sa, res->ai_addr, res->ai_addrlen); | ||
128 | - *p->sa_len = res->ai_addrlen; | ||
129 | - | ||
130 | - freeaddrinfo(res); | ||
131 | - | ||
132 | -#else | ||
133 | - | ||
134 | - struct hostent *hp; | ||
135 | - struct servent *sp; | ||
136 | - unsigned short port; | ||
137 | - unsigned long lport; | ||
138 | - char *ptr; | ||
139 | - struct sockaddr_in *sin = (struct sockaddr_in *) p->sa; | ||
140 | - | ||
141 | - // Get the port number. | ||
142 | - lport = strtoul(p->portname, &ptr, 0); | ||
143 | - if (ptr == p->portname || *ptr != '\0' || lport == 0L || lport & ~0xffff) | ||
144 | - { | ||
145 | - if (!(sp = getservbyname(p->portname, "tcp"))) | ||
146 | - { | ||
147 | - snprintf(p->errmsg, p->em_len,_( "Unknown port number or service: %s" ),p->portname); | ||
148 | - return -1; | ||
149 | - } | ||
150 | - port = sp->s_port; | ||
151 | - } | ||
152 | - else | ||
153 | - { | ||
154 | - port = htons((unsigned short)lport); | ||
155 | - } | ||
156 | - *p->pport = ntohs(port); | ||
157 | - | ||
158 | - // Use gethostbyname() to resolve the hostname. | ||
159 | - hp = gethostbyname(p->host); | ||
160 | - if (hp == (struct hostent *) 0) | ||
161 | - { | ||
162 | - sin->sin_family = AF_INET; | ||
163 | - sin->sin_addr.s_addr = inet_addr(p->host); | ||
164 | - if (sin->sin_addr.s_addr == (unsigned long)-1) | ||
165 | - { | ||
166 | - snprintf(p->errmsg, p->em_len, _( "Unknown host:\n%s" ), p->host); | ||
167 | - return -2; | ||
168 | - } | ||
169 | - } | ||
170 | - else | ||
171 | - { | ||
172 | - sin->sin_family = hp->h_addrtype; | ||
173 | - (void) memmove(&sin->sin_addr, hp->h_addr, hp->h_length); | ||
174 | - } | ||
175 | - sin->sin_port = port; | ||
176 | - *p->sa_len = sizeof(struct sockaddr_in); | ||
177 | - | ||
178 | -#endif // HAVE_GETADDRINFO | ||
179 | - | ||
180 | - return 0; | ||
181 | -} */ | ||
182 | - |
src/core/session.c
@@ -207,7 +207,6 @@ static int print(H3270 *session, LIB3270_CONTENT_OPTION GNUC_UNUSED(mode)) | @@ -207,7 +207,6 @@ static int print(H3270 *session, LIB3270_CONTENT_OPTION GNUC_UNUSED(mode)) | ||
207 | { | 207 | { |
208 | lib3270_write_log(session, "print", "%s", "Printing is unavailable"); | 208 | lib3270_write_log(session, "print", "%s", "Printing is unavailable"); |
209 | lib3270_popup_dialog(session, LIB3270_NOTIFY_WARNING, _( "Can't print" ), _( "Unable to print" ), "%s", strerror(ENOTSUP)); | 209 | lib3270_popup_dialog(session, LIB3270_NOTIFY_WARNING, _( "Can't print" ), _( "Unable to print" ), "%s", strerror(ENOTSUP)); |
210 | - | ||
211 | return errno = ENOTSUP; | 210 | return errno = ENOTSUP; |
212 | } | 211 | } |
213 | 212 | ||
@@ -218,6 +217,13 @@ static int save(H3270 *session, LIB3270_CONTENT_OPTION GNUC_UNUSED(mode), const | @@ -218,6 +217,13 @@ static int save(H3270 *session, LIB3270_CONTENT_OPTION GNUC_UNUSED(mode), const | ||
218 | return errno = ENOTSUP; | 217 | return errno = ENOTSUP; |
219 | } | 218 | } |
220 | 219 | ||
220 | +static int load(H3270 *session, const char GNUC_UNUSED(*filename)) | ||
221 | +{ | ||
222 | + lib3270_write_log(session, "load", "%s", "Loading from file is unavailable"); | ||
223 | + lib3270_popup_dialog(session, LIB3270_NOTIFY_WARNING, _( "Can't load" ), _( "Unable to load from file" ), "%s", strerror(ENOTSUP)); | ||
224 | + return errno = ENOTSUP; | ||
225 | +} | ||
226 | + | ||
221 | static void message(H3270 *session, LIB3270_NOTIFY GNUC_UNUSED(id), const char *title, const char *msg, const char *text) | 227 | static void message(H3270 *session, LIB3270_NOTIFY GNUC_UNUSED(id), const char *title, const char *msg, const char *text) |
222 | { | 228 | { |
223 | #ifdef ANDROID | 229 | #ifdef ANDROID |
@@ -289,7 +295,6 @@ static void set_peer_certificate)(const void GNUC_UNUSED(*cert)) | @@ -289,7 +295,6 @@ static void set_peer_certificate)(const void GNUC_UNUSED(*cert)) | ||
289 | 295 | ||
290 | static void default_update_luname(H3270 GNUC_UNUSED(*session), const char GNUC_UNUSED(*name)) | 296 | static void default_update_luname(H3270 GNUC_UNUSED(*session), const char GNUC_UNUSED(*name)) |
291 | { | 297 | { |
292 | - | ||
293 | } | 298 | } |
294 | 299 | ||
295 | void lib3270_reset_callbacks(H3270 *hSession) | 300 | void lib3270_reset_callbacks(H3270 *hSession) |
@@ -322,9 +327,9 @@ void lib3270_reset_callbacks(H3270 *hSession) | @@ -322,9 +327,9 @@ void lib3270_reset_callbacks(H3270 *hSession) | ||
322 | hSession->cbk.set_timer = set_timer; | 327 | hSession->cbk.set_timer = set_timer; |
323 | hSession->cbk.print = print; | 328 | hSession->cbk.print = print; |
324 | hSession->cbk.save = save; | 329 | hSession->cbk.save = save; |
330 | + hSession->cbk.load = load; | ||
325 | hSession->cbk.set_peer_certificate = set_peer_certificate; | 331 | hSession->cbk.set_peer_certificate = set_peer_certificate; |
326 | hSession->cbk.update_luname = default_update_luname; | 332 | hSession->cbk.update_luname = default_update_luname; |
327 | - | ||
328 | } | 333 | } |
329 | 334 | ||
330 | static void lib3270_session_init(H3270 *hSession, const char *model, const char *charset) | 335 | static void lib3270_session_init(H3270 *hSession, const char *model, const char *charset) |
src/core/util.c
@@ -628,6 +628,14 @@ LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession) | @@ -628,6 +628,14 @@ LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession) | ||
628 | return hSession->cbk.print(hSession,LIB3270_CONTENT_COPY); | 628 | return hSession->cbk.print(hSession,LIB3270_CONTENT_COPY); |
629 | } | 629 | } |
630 | 630 | ||
631 | +LIB3270_EXPORT int lib3270_load(H3270 *hSession, const char *filename) | ||
632 | +{ | ||
633 | + if(check_online_session(hSession)) | ||
634 | + return errno = ENOTCONN; | ||
635 | + | ||
636 | + return hSession->cbk.load(hSession, filename); | ||
637 | +} | ||
638 | + | ||
631 | LIB3270_EXPORT int lib3270_save(H3270 *hSession, LIB3270_CONTENT_OPTION mode, const char *filename) | 639 | LIB3270_EXPORT int lib3270_save(H3270 *hSession, LIB3270_CONTENT_OPTION mode, const char *filename) |
632 | { | 640 | { |
633 | return hSession->cbk.save(hSession, mode, filename); | 641 | return hSession->cbk.save(hSession, mode, filename); |
@@ -635,6 +643,9 @@ LIB3270_EXPORT int lib3270_save(H3270 *hSession, LIB3270_CONTENT_OPTION mode, co | @@ -635,6 +643,9 @@ LIB3270_EXPORT int lib3270_save(H3270 *hSession, LIB3270_CONTENT_OPTION mode, co | ||
635 | 643 | ||
636 | LIB3270_EXPORT int lib3270_save_all(H3270 *hSession, const char *filename) | 644 | LIB3270_EXPORT int lib3270_save_all(H3270 *hSession, const char *filename) |
637 | { | 645 | { |
646 | + if(check_online_session(hSession)) | ||
647 | + return errno = ENOTCONN; | ||
648 | + | ||
638 | return lib3270_save(hSession,LIB3270_CONTENT_ALL,filename); | 649 | return lib3270_save(hSession,LIB3270_CONTENT_ALL,filename); |
639 | } | 650 | } |
640 | 651 | ||
@@ -642,6 +653,7 @@ LIB3270_EXPORT int lib3270_save_selected(H3270 *hSession, const char *filename) | @@ -642,6 +653,7 @@ LIB3270_EXPORT int lib3270_save_selected(H3270 *hSession, const char *filename) | ||
642 | { | 653 | { |
643 | if(lib3270_has_selection(hSession)) | 654 | if(lib3270_has_selection(hSession)) |
644 | return lib3270_save(hSession,LIB3270_CONTENT_SELECTED,filename); | 655 | return lib3270_save(hSession,LIB3270_CONTENT_SELECTED,filename); |
656 | + | ||
645 | return errno = ENODATA; | 657 | return errno = ENODATA; |
646 | } | 658 | } |
647 | 659 | ||
@@ -650,7 +662,6 @@ LIB3270_EXPORT int lib3270_save_copy(H3270 *hSession, const char *filename) | @@ -650,7 +662,6 @@ LIB3270_EXPORT int lib3270_save_copy(H3270 *hSession, const char *filename) | ||
650 | return lib3270_save(hSession,LIB3270_CONTENT_COPY,filename); | 662 | return lib3270_save(hSession,LIB3270_CONTENT_COPY,filename); |
651 | } | 663 | } |
652 | 664 | ||
653 | - | ||
654 | LIB3270_EXPORT LIB3270_POINTER lib3270_get_pointer(H3270 *hSession, int baddr) | 665 | LIB3270_EXPORT LIB3270_POINTER lib3270_get_pointer(H3270 *hSession, int baddr) |
655 | { | 666 | { |
656 | static const struct _ptr { | 667 | static const struct _ptr { |
src/include/lib3270.h
@@ -838,6 +838,16 @@ | @@ -838,6 +838,16 @@ | ||
838 | LIB3270_EXPORT int lib3270_save_copy(H3270 *hSession, const char *filename); | 838 | LIB3270_EXPORT int lib3270_save_copy(H3270 *hSession, const char *filename); |
839 | 839 | ||
840 | /** | 840 | /** |
841 | + * @brief Paste from file. | ||
842 | + * | ||
843 | + * @param hSession Session Handle. | ||
844 | + * @param filename File name. | ||
845 | + * | ||
846 | + * @return 0 if ok, error code if not. | ||
847 | + */ | ||
848 | + LIB3270_EXPORT int lib3270_load(H3270 *hSession, const char *filename); | ||
849 | + | ||
850 | + /** | ||
841 | * @brief Get buffer contents. | 851 | * @brief Get buffer contents. |
842 | * | 852 | * |
843 | * @param h Session handle. | 853 | * @param h Session handle. |
src/include/lib3270/session.h
@@ -74,8 +74,10 @@ | @@ -74,8 +74,10 @@ | ||
74 | void (*set_selection)(H3270 *session, unsigned char on); | 74 | void (*set_selection)(H3270 *session, unsigned char on); |
75 | void (*ctlr_done)(H3270 *session); | 75 | void (*ctlr_done)(H3270 *session); |
76 | void (*autostart)(H3270 *session); | 76 | void (*autostart)(H3270 *session); |
77 | + | ||
77 | int (*print)(H3270 *session, LIB3270_CONTENT_OPTION mode); | 78 | int (*print)(H3270 *session, LIB3270_CONTENT_OPTION mode); |
78 | int (*save)(H3270 *session, LIB3270_CONTENT_OPTION mode, const char *filename); | 79 | int (*save)(H3270 *session, LIB3270_CONTENT_OPTION mode, const char *filename); |
80 | + int (*load)(H3270 *hSession, const char *filename); | ||
79 | 81 | ||
80 | void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); | 82 | void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); |
81 | void (*popup)(H3270 *session, LIB3270_NOTIFY id, const char *title, const char *msg, const char *fmt, va_list); | 83 | void (*popup)(H3270 *session, LIB3270_NOTIFY id, const char *title, const char *msg, const char *fmt, va_list); |
src/ssl/negotiate.c
@@ -313,7 +313,6 @@ int ssl_negotiate(H3270 *hSession) | @@ -313,7 +313,6 @@ int ssl_negotiate(H3270 *hSession) | ||
313 | else | 313 | else |
314 | lib3270_popup_dialog(hSession, LIB3270_NOTIFY_ERROR, msg.title, msg.text, "%s", ERR_reason_error_string(msg.error)); | 314 | lib3270_popup_dialog(hSession, LIB3270_NOTIFY_ERROR, msg.title, msg.text, "%s", ERR_reason_error_string(msg.error)); |
315 | 315 | ||
316 | - | ||
317 | return rc; | 316 | return rc; |
318 | 317 | ||
319 | } | 318 | } |