Commit 088fbe3cff6755d06386b28374b1c28bceddd280
1 parent
70cc9160
Exists in
master
and in
3 other branches
Moving keyboard and ssl properties do their own sources.
Showing
6 changed files
with
261 additions
and
176 deletions
Show diff stats
lib3270.cbp
... | ... | @@ -92,6 +92,9 @@ |
92 | 92 | <Unit filename="src/core/keyboard/kybd.c"> |
93 | 93 | <Option compilerVar="CC" /> |
94 | 94 | </Unit> |
95 | + <Unit filename="src/core/keyboard/properties.c"> | |
96 | + <Option compilerVar="CC" /> | |
97 | + </Unit> | |
95 | 98 | <Unit filename="src/core/linux/connect.c"> |
96 | 99 | <Option compilerVar="CC" /> |
97 | 100 | </Unit> |
... | ... | @@ -265,6 +268,9 @@ |
265 | 268 | <Unit filename="src/ssl/negotiate.c"> |
266 | 269 | <Option compilerVar="CC" /> |
267 | 270 | </Unit> |
271 | + <Unit filename="src/ssl/properties.c"> | |
272 | + <Option compilerVar="CC" /> | |
273 | + </Unit> | |
268 | 274 | <Unit filename="src/ssl/state.c"> |
269 | 275 | <Option compilerVar="CC" /> |
270 | 276 | </Unit> | ... | ... |
src/core/keyboard/kybd.c
... | ... | @@ -2230,14 +2230,6 @@ int kybd_prime(H3270 *hSession) |
2230 | 2230 | } |
2231 | 2231 | #endif /*]*/ |
2232 | 2232 | |
2233 | -LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_get_keyboard_lock_state(H3270 *hSession) | |
2234 | -{ | |
2235 | - if(check_online_session(hSession)) | |
2236 | - return LIB3270_KL_NOT_CONNECTED; | |
2237 | - | |
2238 | - return (LIB3270_KEYBOARD_LOCK_STATE) hSession->kybdlock; | |
2239 | -} | |
2240 | - | |
2241 | 2233 | LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_wait_for_keyboard_unlock(H3270 *hSession, int seconds) |
2242 | 2234 | { |
2243 | 2235 | time_t end = time(0)+seconds; |
... | ... | @@ -2260,7 +2252,3 @@ LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_wait_for_keyboard_unlock(H327 |
2260 | 2252 | return (LIB3270_KEYBOARD_LOCK_STATE) hSession->kybdlock; |
2261 | 2253 | } |
2262 | 2254 | |
2263 | -LIB3270_EXPORT void lib3270_set_lock_on_operator_error(H3270 *hSession, int enable) | |
2264 | -{ | |
2265 | - hSession->oerr_lock = (enable ? 1 : 0); | |
2266 | -} | ... | ... |
... | ... | @@ -0,0 +1,64 @@ |
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 - e possui - 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 | + * | |
28 | + */ | |
29 | + | |
30 | +#include <lib3270-internals.h> | |
31 | +#include <lib3270/keyboard.h> | |
32 | +#include <lib3270/properties.h> | |
33 | + | |
34 | +LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_get_keyboard_lock_state(H3270 *hSession) | |
35 | +{ | |
36 | + if(check_online_session(hSession)) | |
37 | + return LIB3270_KL_NOT_CONNECTED; | |
38 | + | |
39 | + return (LIB3270_KEYBOARD_LOCK_STATE) hSession->kybdlock; | |
40 | +} | |
41 | + | |
42 | +LIB3270_EXPORT int lib3270_set_lock_on_operator_error(H3270 *hSession, int enable) | |
43 | +{ | |
44 | + hSession->oerr_lock = (enable ? 1 : 0); | |
45 | + return 0; | |
46 | +} | |
47 | + | |
48 | +int lib3270_get_lock_on_operator_error(H3270 *hSession) | |
49 | +{ | |
50 | + return (int) hSession->oerr_lock; | |
51 | +} | |
52 | + | |
53 | +LIB3270_EXPORT int lib3270_set_unlock_delay(H3270 *hSession, unsigned int delay) | |
54 | +{ | |
55 | + hSession->unlock_delay = (delay == 0 ? 0 : 1); | |
56 | + hSession->unlock_delay_ms = (unsigned short) delay; | |
57 | + return 0; | |
58 | +} | |
59 | + | |
60 | +LIB3270_EXPORT unsigned int lib3270_get_unlock_delay(H3270 *hSession) | |
61 | +{ | |
62 | + return (unsigned int) hSession->unlock_delay_ms; | |
63 | +} | |
64 | + | ... | ... |
src/core/properties.c
... | ... | @@ -38,10 +38,6 @@ |
38 | 38 | #include <lib3270/properties.h> |
39 | 39 | #include <lib3270/keyboard.h> |
40 | 40 | |
41 | -#if defined(HAVE_LIBSSL) | |
42 | - #include <openssl/ssl.h> | |
43 | -#endif | |
44 | - | |
45 | 41 | static int lib3270_get_connection_state_as_int(H3270 *hSession) |
46 | 42 | { |
47 | 43 | return (int) lib3270_get_connection_state(hSession); |
... | ... | @@ -178,6 +174,13 @@ |
178 | 174 | NULL // Set value. |
179 | 175 | }, |
180 | 176 | |
177 | + { | |
178 | + "oerrlock", // Property name. | |
179 | + N_( "Lock keyboard on operator error" ), // Property description. | |
180 | + lib3270_get_lock_on_operator_error, // Get value. | |
181 | + lib3270_set_lock_on_operator_error // Set value. | |
182 | + }, | |
183 | + | |
181 | 184 | /* |
182 | 185 | { |
183 | 186 | "", // Property name. |
... | ... | @@ -342,64 +345,6 @@ |
342 | 345 | return lib3270_get_revision(); |
343 | 346 | } |
344 | 347 | |
345 | - #pragma GCC diagnostic push | |
346 | - #pragma GCC diagnostic ignored "-Wunused-parameter" | |
347 | - const char * lib3270_get_crl_url(H3270 *hSession) | |
348 | - { | |
349 | -#ifdef SSL_ENABLE_CRL_CHECK | |
350 | - if(hSession->ssl.crl.url) | |
351 | - return hSession->ssl.crl.url; | |
352 | - | |
353 | -#ifdef SSL_DEFAULT_CRL_URL | |
354 | - return SSL_DEFAULT_CRL_URL; | |
355 | -#else | |
356 | - return getenv("LIB3270_DEFAULT_CRL"); | |
357 | -#endif // SSL_DEFAULT_CRL_URL | |
358 | - | |
359 | -#else | |
360 | - errno = ENOTSUP; | |
361 | - return ""; | |
362 | -#endif | |
363 | - } | |
364 | - #pragma GCC diagnostic pop | |
365 | - | |
366 | - #pragma GCC diagnostic push | |
367 | - #pragma GCC diagnostic ignored "-Wunused-parameter" | |
368 | - int lib3270_set_crl_url(H3270 *hSession, const char *crl) | |
369 | - { | |
370 | - | |
371 | - FAIL_IF_ONLINE(hSession); | |
372 | - | |
373 | -#ifdef SSL_ENABLE_CRL_CHECK | |
374 | - | |
375 | - if(hSession->ssl.crl.url) | |
376 | - { | |
377 | - free(hSession->ssl.crl.url); | |
378 | - hSession->ssl.crl.url = NULL; | |
379 | - } | |
380 | - | |
381 | - if(hSession->ssl.crl.cert) | |
382 | - { | |
383 | - X509_CRL_free(hSession->ssl.crl.cert); | |
384 | - hSession->ssl.crl.cert = NULL; | |
385 | - } | |
386 | - | |
387 | - if(crl) | |
388 | - { | |
389 | - hSession->ssl.crl.url = strdup(crl); | |
390 | - } | |
391 | - | |
392 | - return 0; | |
393 | - | |
394 | -#else | |
395 | - | |
396 | - return errno = ENOTSUP; | |
397 | - | |
398 | -#endif // SSL_ENABLE_CRL_CHECK | |
399 | - | |
400 | - } | |
401 | - #pragma GCC diagnostic pop | |
402 | - | |
403 | 348 | LIB3270_EXPORT const LIB3270_STRING_PROPERTY * lib3270_get_string_properties_list(void) |
404 | 349 | { |
405 | 350 | static const LIB3270_STRING_PROPERTY properties[] = { |
... | ... | @@ -649,104 +594,3 @@ int lib3270_set_string_property(H3270 *hSession, const char *name, const char * |
649 | 594 | |
650 | 595 | } |
651 | 596 | |
652 | -/** | |
653 | - * @brief Get SSL host option. | |
654 | - * | |
655 | - * @return Non zero if the host URL has SSL scheme. | |
656 | - * | |
657 | - */ | |
658 | -LIB3270_EXPORT int lib3270_get_secure_host(H3270 *hSession) | |
659 | -{ | |
660 | - CHECK_SESSION_HANDLE(hSession); | |
661 | - | |
662 | - // TODO: Find a better way! | |
663 | - if(!hSession->host.current) | |
664 | - lib3270_set_url(hSession,NULL); | |
665 | - | |
666 | -#ifdef HAVE_LIBSSL | |
667 | - return hSession->ssl.enabled ? 1 : 0; | |
668 | -#else | |
669 | - return 0; | |
670 | -#endif // HAVE_LIBSSL | |
671 | - | |
672 | -} | |
673 | - | |
674 | -#ifdef SSL_ENABLE_CRL_CHECK | |
675 | -LIB3270_EXPORT char * lib3270_get_ssl_crl_text(H3270 *hSession) | |
676 | -{ | |
677 | - | |
678 | - if(hSession->ssl.crl.cert) | |
679 | - { | |
680 | - | |
681 | - BIO * out = BIO_new(BIO_s_mem()); | |
682 | - unsigned char * data; | |
683 | - unsigned char * text; | |
684 | - int n; | |
685 | - | |
686 | - X509_CRL_print(out,hSession->ssl.crl.cert); | |
687 | - | |
688 | - n = BIO_get_mem_data(out, &data); | |
689 | - text = (unsigned char *) lib3270_malloc(n+1); | |
690 | - text[n] ='\0'; | |
691 | - | |
692 | - memcpy(text,data,n); | |
693 | - BIO_free(out); | |
694 | - | |
695 | - return (char *) text; | |
696 | - | |
697 | - } | |
698 | - | |
699 | - return NULL; | |
700 | - | |
701 | -} | |
702 | -#else | |
703 | -LIB3270_EXPORT char * lib3270_get_ssl_crl_text(H3270 GNUC_UNUSED(*hSession)) | |
704 | -{ | |
705 | - return NULL; | |
706 | -} | |
707 | -#endif // SSL_ENABLE_CRL_CHECK | |
708 | - | |
709 | - | |
710 | -LIB3270_EXPORT char * lib3270_get_ssl_peer_certificate_text(H3270 *hSession) | |
711 | -{ | |
712 | -#ifdef HAVE_LIBSSL | |
713 | - if(hSession->ssl.con) | |
714 | - { | |
715 | - X509 * peer = SSL_get_peer_certificate(hSession->ssl.con); | |
716 | - if(peer) | |
717 | - { | |
718 | - BIO * out = BIO_new(BIO_s_mem()); | |
719 | - unsigned char * data; | |
720 | - unsigned char * text; | |
721 | - int n; | |
722 | - | |
723 | - X509_print(out,peer); | |
724 | - | |
725 | - n = BIO_get_mem_data(out, &data); | |
726 | - text = (unsigned char *) lib3270_malloc(n+1); | |
727 | - text[n] ='\0'; | |
728 | - memcpy(text,data,n); | |
729 | - BIO_free(out); | |
730 | - | |
731 | - return (char *) text; | |
732 | - } | |
733 | - } | |
734 | -#endif // HAVE_LIBSSL | |
735 | - | |
736 | - return NULL; | |
737 | -} | |
738 | - | |
739 | -LIB3270_EXPORT int lib3270_set_unlock_delay(H3270 *hSession, unsigned int delay) | |
740 | -{ | |
741 | - CHECK_SESSION_HANDLE(hSession); | |
742 | - hSession->unlock_delay = (delay == 0 ? 0 : 1); | |
743 | - hSession->unlock_delay_ms = (unsigned short) delay; | |
744 | - return 0; | |
745 | -} | |
746 | - | |
747 | -LIB3270_EXPORT unsigned int lib3270_get_unlock_delay(H3270 *hSession) | |
748 | -{ | |
749 | - CHECK_SESSION_HANDLE(hSession); | |
750 | - return (unsigned int) hSession->unlock_delay_ms; | |
751 | -} | |
752 | - | ... | ... |
src/include/lib3270/keyboard.h
... | ... | @@ -82,7 +82,8 @@ |
82 | 82 | * @param enable Non zero to enable operator lock, zero to disable. |
83 | 83 | * |
84 | 84 | */ |
85 | - LIB3270_EXPORT void lib3270_set_lock_on_operator_error(H3270 *hSession, int enable); | |
85 | + LIB3270_EXPORT int lib3270_set_lock_on_operator_error(H3270 *hSession, int enable); | |
86 | + LIB3270_EXPORT int lib3270_get_lock_on_operator_error(H3270 *hSession); | |
86 | 87 | |
87 | 88 | #ifdef __cplusplus |
88 | 89 | } | ... | ... |
... | ... | @@ -0,0 +1,182 @@ |
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 - e possui - 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 | + * | |
28 | + */ | |
29 | + | |
30 | +#include <lib3270-internals.h> | |
31 | +#include <lib3270/properties.h> | |
32 | + | |
33 | +#if defined(HAVE_LIBSSL) | |
34 | + #include <openssl/ssl.h> | |
35 | +#endif | |
36 | + | |
37 | + | |
38 | +/** | |
39 | + * @brief Get SSL host option. | |
40 | + * | |
41 | + * @return Non zero if the host URL has SSL scheme. | |
42 | + * | |
43 | + */ | |
44 | +LIB3270_EXPORT int lib3270_get_secure_host(H3270 *hSession) | |
45 | +{ | |
46 | + CHECK_SESSION_HANDLE(hSession); | |
47 | + | |
48 | + // TODO: Find a better way! | |
49 | + if(!hSession->host.current) | |
50 | + lib3270_set_url(hSession,NULL); | |
51 | + | |
52 | +#ifdef HAVE_LIBSSL | |
53 | + return hSession->ssl.enabled ? 1 : 0; | |
54 | +#else | |
55 | + return 0; | |
56 | +#endif // HAVE_LIBSSL | |
57 | + | |
58 | +} | |
59 | + | |
60 | +#ifdef SSL_ENABLE_CRL_CHECK | |
61 | +LIB3270_EXPORT char * lib3270_get_ssl_crl_text(H3270 *hSession) | |
62 | +{ | |
63 | + | |
64 | + if(hSession->ssl.crl.cert) | |
65 | + { | |
66 | + | |
67 | + BIO * out = BIO_new(BIO_s_mem()); | |
68 | + unsigned char * data; | |
69 | + unsigned char * text; | |
70 | + int n; | |
71 | + | |
72 | + X509_CRL_print(out,hSession->ssl.crl.cert); | |
73 | + | |
74 | + n = BIO_get_mem_data(out, &data); | |
75 | + text = (unsigned char *) lib3270_malloc(n+1); | |
76 | + text[n] ='\0'; | |
77 | + | |
78 | + memcpy(text,data,n); | |
79 | + BIO_free(out); | |
80 | + | |
81 | + return (char *) text; | |
82 | + | |
83 | + } | |
84 | + | |
85 | + return NULL; | |
86 | + | |
87 | +} | |
88 | +#else | |
89 | +LIB3270_EXPORT char * lib3270_get_ssl_crl_text(H3270 GNUC_UNUSED(*hSession)) | |
90 | +{ | |
91 | + return NULL; | |
92 | +} | |
93 | +#endif // SSL_ENABLE_CRL_CHECK | |
94 | + | |
95 | + | |
96 | +LIB3270_EXPORT char * lib3270_get_ssl_peer_certificate_text(H3270 *hSession) | |
97 | +{ | |
98 | +#ifdef HAVE_LIBSSL | |
99 | + if(hSession->ssl.con) | |
100 | + { | |
101 | + X509 * peer = SSL_get_peer_certificate(hSession->ssl.con); | |
102 | + if(peer) | |
103 | + { | |
104 | + BIO * out = BIO_new(BIO_s_mem()); | |
105 | + unsigned char * data; | |
106 | + unsigned char * text; | |
107 | + int n; | |
108 | + | |
109 | + X509_print(out,peer); | |
110 | + | |
111 | + n = BIO_get_mem_data(out, &data); | |
112 | + text = (unsigned char *) lib3270_malloc(n+1); | |
113 | + text[n] ='\0'; | |
114 | + memcpy(text,data,n); | |
115 | + BIO_free(out); | |
116 | + | |
117 | + return (char *) text; | |
118 | + } | |
119 | + } | |
120 | +#endif // HAVE_LIBSSL | |
121 | + | |
122 | + return NULL; | |
123 | +} | |
124 | + | |
125 | + #pragma GCC diagnostic push | |
126 | + #pragma GCC diagnostic ignored "-Wunused-parameter" | |
127 | + const char * lib3270_get_crl_url(H3270 *hSession) | |
128 | + { | |
129 | +#ifdef SSL_ENABLE_CRL_CHECK | |
130 | + if(hSession->ssl.crl.url) | |
131 | + return hSession->ssl.crl.url; | |
132 | + | |
133 | +#ifdef SSL_DEFAULT_CRL_URL | |
134 | + return SSL_DEFAULT_CRL_URL; | |
135 | +#else | |
136 | + return getenv("LIB3270_DEFAULT_CRL"); | |
137 | +#endif // SSL_DEFAULT_CRL_URL | |
138 | + | |
139 | +#else | |
140 | + errno = ENOTSUP; | |
141 | + return ""; | |
142 | +#endif | |
143 | + } | |
144 | + #pragma GCC diagnostic pop | |
145 | + | |
146 | + #pragma GCC diagnostic push | |
147 | + #pragma GCC diagnostic ignored "-Wunused-parameter" | |
148 | + int lib3270_set_crl_url(H3270 *hSession, const char *crl) | |
149 | + { | |
150 | + | |
151 | + FAIL_IF_ONLINE(hSession); | |
152 | + | |
153 | +#ifdef SSL_ENABLE_CRL_CHECK | |
154 | + | |
155 | + if(hSession->ssl.crl.url) | |
156 | + { | |
157 | + free(hSession->ssl.crl.url); | |
158 | + hSession->ssl.crl.url = NULL; | |
159 | + } | |
160 | + | |
161 | + if(hSession->ssl.crl.cert) | |
162 | + { | |
163 | + X509_CRL_free(hSession->ssl.crl.cert); | |
164 | + hSession->ssl.crl.cert = NULL; | |
165 | + } | |
166 | + | |
167 | + if(crl) | |
168 | + { | |
169 | + hSession->ssl.crl.url = strdup(crl); | |
170 | + } | |
171 | + | |
172 | + return 0; | |
173 | + | |
174 | +#else | |
175 | + | |
176 | + return errno = ENOTSUP; | |
177 | + | |
178 | +#endif // SSL_ENABLE_CRL_CHECK | |
179 | + | |
180 | + } | |
181 | + #pragma GCC diagnostic pop | |
182 | + | ... | ... |