diff --git a/src/lib3270/ansi.c b/src/lib3270/ansi.c index 901389d..912db09 100644 --- a/src/lib3270/ansi.c +++ b/src/lib3270/ansi.c @@ -35,6 +35,7 @@ */ #pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wstringop-truncation" #include "private.h" @@ -44,8 +45,6 @@ #include #endif /*]*/ -//#include "appres.h" -// #include "ctlr.h" #if defined(X3270_DBCS) /*[*/ #include #endif /*]*/ @@ -54,8 +53,6 @@ #include "ctlrc.h" #include "hostc.h" #include "screenc.h" -// #include "scrollc.h" -// #include "tablesc.h" #include "telnetc.h" #include "trace_dsc.h" #include "utf8c.h" @@ -65,68 +62,67 @@ #define MB_MAX LIB3270_MB_MAX -#define SC 1 /* save cursor position */ -#define RC 2 /* restore cursor position */ -#define NL 3 /* new line */ -#define UP 4 /* cursor up */ -#define E2 5 /* second level of ESC processing */ -#define rS 6 /* reset */ -#define IC 7 /* insert chars */ -#define DN 8 /* cursor down */ -#define RT 9 /* cursor right */ -#define LT 10 /* cursor left */ -#define CM 11 /* cursor motion */ -#define ED 12 /* erase in display */ -#define EL 13 /* erase in line */ -#define IL 14 /* insert lines */ -#define DL 15 /* delete lines */ -#define DC 16 /* delete characters */ -#define SG 17 /* set graphic rendition */ -#define BL 18 /* ring bell */ -#define NP 19 /* new page */ -#define BS 20 /* backspace */ -#define CR 21 /* carriage return */ -#define LF 22 /* line feed */ -#define HT 23 /* horizontal tab */ -#define E1 24 /* first level of ESC processing */ -#define Xx 25 /* undefined control character (nop) */ -#define Pc 26 /* printing character */ -#define Sc 27 /* semicolon (after ESC [) */ -#define Dg 28 /* digit (after ESC [ or ESC [ ?) */ -#define RI 29 /* reverse index */ -#define DA 30 /* send device attributes */ -#define SM 31 /* set mode */ -#define RM 32 /* reset mode */ -#define DO 33 /* return terminal ID (obsolete) */ -#define SR 34 /* device status report */ -#define CS 35 /* character set designate */ -#define E3 36 /* third level of ESC processing */ -#define DS 37 /* DEC private set */ -#define DR 38 /* DEC private reset */ -#define DV 39 /* DEC private save */ -#define DT 40 /* DEC private restore */ -#define SS 41 /* set scrolling region */ -#define TM 42 /* text mode (ESC ]) */ -#define T2 43 /* semicolon (after ESC ]) */ -#define TX 44 /* text parameter (after ESC ] n ;) */ -#define TB 45 /* text parameter done (ESC ] n ; xxx BEL) */ -#define TS 46 /* tab set */ -#define TC 47 /* tab clear */ -#define C2 48 /* character set designate (finish) */ -#define G0 49 /* select G0 character set */ -#define G1 50 /* select G1 character set */ -#define G2 51 /* select G2 character set */ -#define G3 52 /* select G3 character set */ -#define S2 53 /* select G2 for next character */ -#define S3 54 /* select G3 for next character */ -#define MB 55 /* process multi-byte character */ +#define SC 1 /**< @brief save cursor position */ +#define RC 2 /**< @brief restore cursor position */ +#define NL 3 /**< @brief new line */ +#define UP 4 /**< @brief cursor up */ +#define E2 5 /**< @brief second level of ESC processing */ +#define rS 6 /**< @brief reset */ +#define IC 7 /**< @brief insert chars */ +#define DN 8 /**< @brief cursor down */ +#define RT 9 /**< @brief cursor right */ +#define LT 10 /**< @brief cursor left */ +#define CM 11 /**< @brief cursor motion */ +#define ED 12 /**< @brief erase in display */ +#define EL 13 /**< @brief erase in line */ +#define IL 14 /**< @brief insert lines */ +#define DL 15 /**< @brief delete lines */ +#define DC 16 /**< @brief delete characters */ +#define SG 17 /**< @brief set graphic rendition */ +#define BL 18 /**< @brief ring bell */ +#define NP 19 /**< @brief new page */ +#define BS 20 /**< @brief backspace */ +#define CR 21 /**< @brief carriage return */ +#define LF 22 /**< @brief line feed */ +#define HT 23 /**< @brief horizontal tab */ +#define E1 24 /**< @brief first level of ESC processing */ +#define Xx 25 /**< @brief undefined control character (nop) */ +#define Pc 26 /**< @brief printing character */ +#define Sc 27 /**< @brief semicolon (after ESC [) */ +#define Dg 28 /**< @brief digit (after ESC [ or ESC [ ?) */ +#define RI 29 /**< @brief reverse index */ +#define DA 30 /**< @brief send device attributes */ +#define SM 31 /**< @brief set mode */ +#define RM 32 /**< @brief reset mode */ +#define DO 33 /**< @brief return terminal ID (obsolete) */ +#define SR 34 /**< @brief device status report */ +#define CS 35 /**< @brief character set designate */ +#define E3 36 /**< @brief third level of ESC processing */ +#define DS 37 /**< @brief DEC private set */ +#define DR 38 /**< @brief DEC private reset */ +#define DV 39 /**< @brief DEC private save */ +#define DT 40 /**< @brief DEC private restore */ +#define SS 41 /**< @brief set scrolling region */ +#define TM 42 /**< @brief text mode (ESC ]) */ +#define T2 43 /**< @brief semicolon (after ESC ]) */ +#define TX 44 /**< @brief text parameter (after ESC ] n ;) */ +#define TB 45 /**< @brief text parameter done (ESC ] n ; xxx BEL) */ +#define TS 46 /**< @brief tab set */ +#define TC 47 /**< @brief tab clear */ +#define C2 48 /**< @brief character set designate (finish) */ +#define G0 49 /**< @brief select G0 character set */ +#define G1 50 /**< @brief select G1 character set */ +#define G2 51 /**< @brief select G2 character set */ +#define G3 52 /**< @brief select G3 character set */ +#define S2 53 /**< @brief select G2 for next character */ +#define S3 54 /**< @brief select G3 for next character */ +#define MB 55 /**< @brief process multi-byte character */ #define DATA LIB3270_ANSI_STATE_DATA #define ESC LIB3270_ANSI_STATE_ESC #define CSDES LIB3270_ANSI_STATE_CSDES #define N1 LIB3270_ANSI_STATE_N1 #define DECP LIB3270_ANSI_STATE_DECP -// #define TEXT LIB3270_ANSI_STATE_TEXT #define TEXT2 LIB3270_ANSI_STATE_TEXT2 #define MBPEND LIB3270_ANSI_STATE_MBPEND diff --git a/src/lib3270/glue.c b/src/lib3270/glue.c deleted file mode 100644 index 3aacd26..0000000 --- a/src/lib3270/glue.c +++ /dev/null @@ -1,172 +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 glue.c e possui - 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) - * - */ - - -/* - * glue.c - * A displayless 3270 Terminal Emulator - * Glue for missing parts. - */ - - - -#include "private.h" - -#if !defined(_WIN32) /*[*/ - #include -#else - #include -#endif /*]*/ - -#include -#include -#include - -#include "3270ds.h" -#include "resources.h" - -//#include "actionsc.h" -#include "ansic.h" -// #include "charsetc.h" -#include "ctlrc.h" -// #include "gluec.h" -#include "hostc.h" -// #include "keymapc.h" -#include "kybdc.h" -//#include "macrosc.h" -#include "popupsc.h" -#include "screenc.h" -// #include "selectc.h" -//#include "tablesc.h" -#include "telnetc.h" -#include "togglesc.h" -#include "trace_dsc.h" -#include "utilc.h" -// #include "idlec.h" -// #include "printerc.h" - -#if defined(X3270_FT) - #include "ftc.h" -#endif - -#if defined(_WIN32) /*[*/ -#include "winversc.h" -#endif /*]*/ - -// #include "session.h" - -#if defined WIN32 - BOOL WINAPI DllMain(HANDLE hinst, DWORD dwcallpurpose, LPVOID lpvResvd); -#else - int lib3270_loaded(void) __attribute__((constructor)); - int lib3270_unloaded(void) __attribute__((destructor)); -#endif - - #define LAST_ARG "--" - -/*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ - -/** - * @brief Parse an stty control-character specification; a cheap, non-complaining implementation. - */ -static char parse_ctlchar(char *s) -{ - if (!s || !*s) - return 0; - - if ((int) strlen(s) > 1) - { - if (*s != '^') - return 0; - else if (*(s+1) == '?') - return 0177; - else - return *(s+1) - '@'; - } else - return *s; -} - -int lib3270_loaded(void) -{ - trace("%s",__FUNCTION__); - - ansictl.vintr = parse_ctlchar("^C"); - ansictl.vquit = parse_ctlchar("^\\"); - ansictl.verase = parse_ctlchar("^H"); - ansictl.vkill = parse_ctlchar("^U"); - ansictl.veof = parse_ctlchar("^D"); - ansictl.vwerase = parse_ctlchar("^W"); - ansictl.vrprnt = parse_ctlchar("^R"); - ansictl.vlnext = parse_ctlchar("^V"); - - return 0; -} - -int lib3270_unloaded(void) -{ - trace("%s",__FUNCTION__); - return 0; -} - - -#if defined WIN32 - -BOOL WINAPI DllMain(HANDLE hinst unused, DWORD dwcallpurpose, LPVOID lpvResvd unused) -{ -// Trace("%s - Library %s",__FUNCTION__,(dwcallpurpose == DLL_PROCESS_ATTACH) ? "Loaded" : "Unloaded"); - - switch(dwcallpurpose) - { - case DLL_PROCESS_ATTACH: - get_version_info(); - lib3270_loaded(); - break; - - case DLL_PROCESS_DETACH: - lib3270_unloaded(); - break; - - } - - return TRUE; -} - -#endif - - -#ifdef DEBUG -extern void lib3270_initialize(void) -{ - lib3270_loaded(); -} -#endif - - diff --git a/src/lib3270/init.c b/src/lib3270/init.c new file mode 100644 index 0000000..24f0fea --- /dev/null +++ b/src/lib3270/init.c @@ -0,0 +1,141 @@ +/* + * "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 - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + +/** + * @brief Init/Deinit lib3270 internals. + */ + +#include + +#ifdef HAVE_LIBCURL + #include +#endif // HAVE_LIBCURL + +#include + +#ifdef _WIN32 + #include + #include + #include "winversc.h" +#endif // _WIN32 + +#include +#include "private.h" + +#if defined WIN32 + BOOL WINAPI DllMain(HANDLE hinst, DWORD dwcallpurpose, LPVOID lpvResvd); +#else + int lib3270_loaded(void) __attribute__((constructor)); + int lib3270_unloaded(void) __attribute__((destructor)); +#endif + +/*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ + +/** + * @brief Parse an stty control-character specification; a cheap, non-complaining implementation. + */ +static char parse_ctlchar(char *s) +{ + if (!s || !*s) + return 0; + + if ((int) strlen(s) > 1) + { + if (*s != '^') + return 0; + else if (*(s+1) == '?') + return 0177; + else + return *(s+1) - '@'; + } else + return *s; +} + +int lib3270_loaded(void) +{ + trace("%s",__FUNCTION__); + + ansictl.vintr = parse_ctlchar("^C"); + ansictl.vquit = parse_ctlchar("^\\"); + ansictl.verase = parse_ctlchar("^H"); + ansictl.vkill = parse_ctlchar("^U"); + ansictl.veof = parse_ctlchar("^D"); + ansictl.vwerase = parse_ctlchar("^W"); + ansictl.vrprnt = parse_ctlchar("^R"); + ansictl.vlnext = parse_ctlchar("^V"); + +#ifdef HAVE_LIBCURL + trace("%s.curl_global_init",__FUNCTION__); + curl_global_init(CURL_GLOBAL_DEFAULT); +#endif // HAVE_LIBCURL + + return 0; +} + +int lib3270_unloaded(void) +{ + trace("%s",__FUNCTION__); + +#ifdef HAVE_LIBCURL + trace("%s.curl_global_cleanup",__FUNCTION__); + curl_global_cleanup(); +#endif // HAVE_LIBCURL + + return 0; +} + + +#if defined WIN32 + +BOOL WINAPI DllMain(HANDLE hinst unused, DWORD dwcallpurpose, LPVOID lpvResvd unused) +{ +// Trace("%s - Library %s",__FUNCTION__,(dwcallpurpose == DLL_PROCESS_ATTACH) ? "Loaded" : "Unloaded"); + + switch(dwcallpurpose) + { + case DLL_PROCESS_ATTACH: + get_version_info(); + lib3270_loaded(); + break; + + case DLL_PROCESS_DETACH: + lib3270_unloaded(); + break; + + } + + return TRUE; +} + +#endif + + + + diff --git a/src/lib3270/private.h b/src/lib3270/private.h index 6a10643..ebd264e 100644 --- a/src/lib3270/private.h +++ b/src/lib3270/private.h @@ -634,7 +634,6 @@ struct _h3270 /* Library internal calls */ LIB3270_INTERNAL void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped); -LIB3270_INTERNAL void lib3270_initialize(void); LIB3270_INTERNAL int cursor_move(H3270 *session, int baddr); LIB3270_INTERNAL void toggle_rectselect(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE tt); diff --git a/src/lib3270/ssl/windows/getcrl.c b/src/lib3270/ssl/windows/getcrl.c index 725ece6..686c498 100644 --- a/src/lib3270/ssl/windows/getcrl.c +++ b/src/lib3270/ssl/windows/getcrl.c @@ -31,6 +31,8 @@ * http://www.openssl.org/docs/ssl/ * https://stackoverflow.com/questions/4389954/does-openssl-automatically-handle-crls-certificate-revocation-lists-now * + * https://www.codepool.biz/build-use-libcurl-vs2015-windows.html + * */ #define CRL_DATA_LENGTH 4096 @@ -66,8 +68,11 @@ static inline void lib3270_autoptr_cleanup_CURL(CURL **ptr) { debug("%s(%p)",__FUNCTION__,*ptr); if(*ptr) + { curl_easy_cleanup(*ptr); + } *ptr = NULL; + } typedef struct _curldata @@ -98,17 +103,26 @@ static size_t internal_curl_write_callback(void *contents, size_t size, size_t n CURLDATA * data = (CURLDATA *) userp; size_t realsize = size * nmemb; + size_t ix; + + debug("Received %u bytes (datablock is %p)", (unsigned int) realsize, data); + + unsigned char *ptr = (unsigned char *) contents; + + debug("\n------------------------------------\n%s\n", ptr); - if((size + data->length) > CRL_DATA_LENGTH) + for(ix = 0; ix < realsize; ix++) { - debug("CRL Data block is bigger than allocated block (%u bytes)",(unsigned int) size); - return 0; - } + if(data->length >= CRL_DATA_LENGTH) + { + lib3270_write_log(NULL,"ssl","CRL Data block is bigger than allocated block (%u)", (unsigned int) CRL_DATA_LENGTH); + return 0; + } - debug("Received %u bytes", (unsigned int) realsize); + data->contents[data->length++] = *(ptr++); + } - memcpy(&(data->contents[data->length]),contents,realsize); - data->length += realsize; + debug("\n%s\n-------------------------------------------", data->contents); return realsize; } @@ -158,11 +172,15 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) // Use CURL to download the CRL lib3270_autoptr(CURLDATA) crl_data = lib3270_malloc(sizeof(CURLDATA)); + + // Initialize curl and curl_easy lib3270_autoptr(CURL) hCurl = curl_easy_init(); memset(crl_data,0,sizeof(CURLDATA)); crl_data->message = message; + debug("datablock is %p",crl_data); + if(hCurl) { CURLcode res; -- libgit2 0.21.2