diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 8a77413..53af2fa 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -733,7 +733,6 @@ */ LIB3270_EXPORT int lib3270_move_cursor(H3270 *h, LIB3270_DIRECTION dir, unsigned char sel); - /** * @brief Print page * diff --git a/src/lib3270/Makefile.in b/src/lib3270/Makefile.in index 6c5f67d..95c6b55 100644 --- a/src/lib3270/Makefile.in +++ b/src/lib3270/Makefile.in @@ -354,6 +354,14 @@ else $(BINDBG)/$(LIBNAME)@EXEEXT@ endif +publish-debug: \ + $(BINDBG)/$(LIBNAME)@EXEEXT@ + + @rm -f ~/public-html/debug-$(LIBNAME)-@host_cpu@.zip + @zip \ + -9 -D \ + ~/public_html/debug-$(LIBNAME)-@host_cpu@.zip \ + $(BINDBG)/* $(BINDBG)/$(LIBNAME)@DLLEXT@: \ $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ diff --git a/src/lib3270/kybd.c b/src/lib3270/kybd.c index cad5ab2..22bb1b5 100644 --- a/src/lib3270/kybd.c +++ b/src/lib3270/kybd.c @@ -141,6 +141,7 @@ struct ta TA_TYPE_DEFAULT, TA_TYPE_KEY_AID, TA_TYPE_ACTION, + TA_TYPE_CURSOR_MOVE, TA_TYPE_USER } type; @@ -155,6 +156,13 @@ struct ta int (*action)(H3270 *); + struct + { + LIB3270_DIRECTION direction; + unsigned char sel; + int (*fn)(H3270 *, LIB3270_DIRECTION, unsigned char); + } move; + } args; }; @@ -165,17 +173,17 @@ static const char dxl[] = "0123456789abcdef"; /* * Check if the typeahead queue is available - */ + */ /* static int enq_chk(H3270 *hSession) { - /* If no connection, forget it. */ + // If no connection, forget it. if (!lib3270_connected(hSession)) { lib3270_trace_event(hSession," dropped (not connected)\n"); return -1; } - /* If operator error, complain and drop it. */ + // If operator error, complain and drop it. if (hSession->kybdlock & KL_OERR_MASK) { lib3270_ring_bell(hSession); @@ -183,7 +191,7 @@ static int enq_chk(H3270 *hSession) return -1; } - /* If scroll lock, complain and drop it. */ + // If scroll lock, complain and drop it. if (hSession->kybdlock & KL_SCROLLED) { lib3270_ring_bell(hSession); @@ -191,7 +199,7 @@ static int enq_chk(H3270 *hSession) return -1; } - /* If typeahead disabled, complain and drop it. */ + // If typeahead disabled, complain and drop it. if (!hSession->typeahead) { lib3270_trace_event(hSession," dropped (no typeahead)\n"); @@ -200,38 +208,87 @@ static int enq_chk(H3270 *hSession) return 0; } +*/ /** - * @brief Put a "Key-aid" on the typeahead queue + * @brief Create a new typeahead action. + * + * Check for typeahead availability and create a new TA structure. + * + * @return new typeahead struct or NULL if it's not available. */ - static void enq_key(H3270 *session, unsigned char aid_code) - { +static struct ta * new_ta(H3270 *hSession, enum _ta_type type) +{ struct ta *ta; - if(enq_chk(session)) - return; + // If no connection, forget it. + if (!lib3270_connected(hSession)) + { + lib3270_ring_bell(hSession); + lib3270_trace_event(hSession,"typeahead action dropped (not connected)\n"); + return NULL; + } - ta = (struct ta *) lib3270_malloc(sizeof(*ta)); - ta->next = (struct ta *) NULL; - ta->type = TA_TYPE_KEY_AID; - ta->args.aid_code = aid_code; + // If operator error, complain and drop it. + if (hSession->kybdlock & KL_OERR_MASK) + { + lib3270_ring_bell(hSession); + lib3270_trace_event(hSession,"typeahead action dropped (operator error)\n"); + return NULL; + } + + // If scroll lock, complain and drop it. + if (hSession->kybdlock & KL_SCROLLED) + { + lib3270_ring_bell(hSession); + lib3270_trace_event(hSession,"typeahead action dropped (scrolled)\n"); + return NULL; + } + + // If typeahead disabled, complain and drop it. + if (!hSession->typeahead) + { + lib3270_trace_event(hSession,"typeahead action dropped (no typeahead)\n"); + return NULL; + } - trace("Adding key %02x on queue",(int) aid_code); + ta = (struct ta *) lib3270_malloc(sizeof(*ta)); + ta->next = (struct ta *) NULL; + ta->type = type; - if (session->ta_head) + if(hSession->ta_head) { - session->ta_tail->next = ta; + hSession->ta_tail->next = ta; } else { - session->ta_head = ta; - status_typeahead(session,True); + hSession->ta_head = ta; + status_typeahead(hSession,True); } - session->ta_tail = ta; - lib3270_trace_event(session," Key-aid queued (kybdlock 0x%x)\n", session->kybdlock); - } + hSession->ta_tail = ta; + return ta; +} + + +/** + * @brief Put a "Key-aid" on the typeahead queue + * + * @param hSession TN3270 Session handle. + * @param aid_code Key-ad code to put on typeahead. + */ + static void enq_key(H3270 *hSession, unsigned char aid_code) + { + struct ta *ta = new_ta(hSession, TA_TYPE_KEY_AID); + + if(!ta) + return; + + ta->args.aid_code = aid_code; + + lib3270_trace_event(hSession,"typeahead action Key-aid queued (kybdlock 0x%x)\n", hSession->kybdlock); + } /** @@ -239,15 +296,12 @@ static int enq_chk(H3270 *hSession) */ static void enq_ta(H3270 *hSession, void (*fn)(H3270 *, const char *, const char *), const char *parm1, const char *parm2) { - struct ta *ta; + struct ta *ta = new_ta(hSession, TA_TYPE_DEFAULT); - if(enq_chk(hSession)) + if(!ta) return; - ta = (struct ta *) lib3270_malloc(sizeof(*ta)); - ta->next = (struct ta *) NULL; - ta->type = TA_TYPE_DEFAULT; - ta->args.def.fn = fn; + ta->args.def.fn = fn; if (parm1) ta->args.def.parm[0] = NewString(parm1); @@ -255,44 +309,17 @@ static void enq_ta(H3270 *hSession, void (*fn)(H3270 *, const char *, const char if (parm2) ta->args.def.parm[1] = NewString(parm2); - if(hSession->ta_head) - { - hSession->ta_tail->next = ta; - } - else - { - hSession->ta_head = ta; - status_typeahead(hSession,True); - } - hSession->ta_tail = ta; - lib3270_trace_event(hSession," action queued (kybdlock 0x%x)\n", hSession->kybdlock); + lib3270_trace_event(hSession,"typeahead action queued (kybdlock 0x%x)\n", hSession->kybdlock); } static void enq_action(H3270 *hSession, int (*fn)(H3270 *)) { - struct ta *ta; + struct ta *ta = new_ta(hSession, TA_TYPE_ACTION); - if(enq_chk(hSession)) - return; - - ta = (struct ta *) lib3270_malloc(sizeof(*ta)); - ta->next = (struct ta *) NULL; - ta->type = TA_TYPE_ACTION; ta->args.action = fn; - if(hSession->ta_head) - { - hSession->ta_tail->next = ta; - } - else - { - hSession->ta_head = ta; - status_typeahead(hSession,True); - } - hSession->ta_tail = ta; - - lib3270_trace_event(hSession," action queued (kybdlock 0x%x)\n", hSession->kybdlock); + lib3270_trace_event(hSession,"single action queued (kybdlock 0x%x)\n", hSession->kybdlock); } @@ -320,6 +347,10 @@ int run_ta(H3270 *hSession) lib3270_free(ta->args.def.parm[1]); break; + case TA_TYPE_CURSOR_MOVE: + ta->args.move.fn(hSession,ta->args.move.direction,ta->args.move.sel); + break; + case TA_TYPE_ACTION: ta->args.action(hSession); break; @@ -753,9 +784,11 @@ static void key_Character_wrapper(H3270 *hSession, const char *param1, const cha (void) key_Character(hSession, code, with_ge, pasting, NULL); } -/* - * Handle an ordinary displayable character key. Lots of stuff to handle - * insert-mode, protected fields and etc. +/** + * @brief Handle an ordinary displayable character key. + * + * Lots of stuff to handle insert-mode, protected fields and etc. + * */ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean pasting, Boolean *skipped) { @@ -1732,9 +1765,9 @@ LIB3270_EXPORT int lib3270_nextword(H3270 *hSession) if (hSession->kybdlock) { enq_action(hSession, lib3270_nextword ); -// enq_ta(NextWord_action, CN, CN); return 0; } + #if defined(X3270_ANSI) /*[*/ if (IN_ANSI) return 0; @@ -1798,48 +1831,37 @@ LIB3270_EXPORT int lib3270_move_cursor(H3270 *hSession, LIB3270_DIRECTION dir, u { FAIL_IF_NOT_ONLINE(hSession); - int cursor_addr = hSession->cursor_addr; - int maxlen = hSession->cols * hSession->rows; + if (hSession->kybdlock) { + + struct ta *ta = new_ta(hSession, TA_TYPE_CURSOR_MOVE); + + ta->args.move.direction = dir; + ta->args.move.fn = lib3270_move_cursor; + ta->args.move.sel = sel; + + return 0; + } switch(dir) { case LIB3270_DIR_UP: - - if(sel && cursor_addr <= hSession->cols) - return errno = EINVAL; - - cursor_addr -= hSession->cols; + lib3270_cursor_up(hSession); break; case LIB3270_DIR_DOWN: - - if(sel && cursor_addr >= (hSession->cols * (hSession->rows-1))) - return errno = EINVAL; - - cursor_addr += hSession->cols; + lib3270_cursor_down(hSession); break; case LIB3270_DIR_LEFT: - - if(sel && (cursor_addr % hSession->cols) < 1) - return errno = EINVAL; - - cursor_addr--; + lib3270_cursor_left(hSession); break; case LIB3270_DIR_RIGHT: - - if(sel && (cursor_addr % hSession->cols) >= (hSession->cols-1)) - return errno = EINVAL; - - cursor_addr++; + lib3270_cursor_right(hSession); break; case LIB3270_DIR_END: - - cursor_addr = lib3270_get_field_end(hSession,cursor_addr); - if(cursor_addr == -1) - return errno = EINVAL; + cursor_move(hSession,lib3270_get_field_end(hSession,hSession->cursor_addr)); break; default: @@ -1848,31 +1870,7 @@ LIB3270_EXPORT int lib3270_move_cursor(H3270 *hSession, LIB3270_DIRECTION dir, u } if(sel) - { - lib3270_select_to(hSession,cursor_addr); - } - else - { - - if(cursor_addr >= maxlen) - { - cursor_move(hSession,cursor_addr % maxlen); - } - else if(cursor_addr < 0) - { - cursor_move(hSession,cursor_addr + maxlen); - } - else - { - cursor_move(hSession,cursor_addr); - } - - if(hSession->kybdlock && (KYBDLOCK_IS_OERR(hSession))) - { - status_reset(hSession); - } - - } + lib3270_select_to(hSession,hSession->cursor_addr); return 0; } diff --git a/src/lib3270/linux/connect.c b/src/lib3270/linux/connect.c index a4bc472..a4fbbfb 100644 --- a/src/lib3270/linux/connect.c +++ b/src/lib3270/linux/connect.c @@ -87,7 +87,8 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u else if(err) { char buffer[4096]; - snprintf(buffer,4095,_( "Can't connect to %s" ), hSession->host.current ); + + snprintf(buffer,4095,_( "Can't connect to %s" ), lib3270_get_url(hSession) ); lib3270_disconnect(hSession); lib3270_popup_dialog( diff --git a/src/lib3270/ssl/linux/getcrl.c b/src/lib3270/ssl/linux/getcrl.c index 99ae285..4c6a150 100644 --- a/src/lib3270/ssl/linux/getcrl.c +++ b/src/lib3270/ssl/linux/getcrl.c @@ -170,7 +170,7 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) return NULL; } - trace_ssl(hSession, "crl=%s",consturl); + trace_ssl(hSession, "crl=%s\n",consturl); if(strncasecmp(consturl,"file://",7) == 0) { diff --git a/src/lib3270/ssl/windows/getcrl.c b/src/lib3270/ssl/windows/getcrl.c index 308f063..725ece6 100644 --- a/src/lib3270/ssl/windows/getcrl.c +++ b/src/lib3270/ssl/windows/getcrl.c @@ -130,7 +130,7 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) return NULL; } - trace_ssl(hSession, "crl=%s",consturl); + trace_ssl(hSession, "crl=%s\n",consturl); if(strncasecmp(consturl,"file://",7) == 0) { @@ -185,6 +185,9 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) return NULL; } + debug("Tamanho da resposta: %u", (unsigned int) crl_data->length); + debug("Resposta:\n-------------------------------------------\n%s\n-------------------------------------------\n",crl_data->contents); + char *ct = NULL; res = curl_easy_getinfo(hCurl, CURLINFO_CONTENT_TYPE, &ct); if(res != CURLE_OK) @@ -192,12 +195,12 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) message->error = hSession->ssl.error = 0; message->title = N_( "Security error" ); message->text = N_( "Error loading CRL" ); - message->description = curl_easy_strerror(res); + message->description = curl_easy_strerror(res); lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->description); return NULL; } - debug("content-type: %s",ct); + // debug("content-type: %s",ct); if(ct) { @@ -233,7 +236,6 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) message->error = hSession->ssl.error = ERR_get_error(); message->title = N_( "Security error" ); message->text = N_( "Got an invalid CRL from LDAP server" ); - lib3270_write_log(hSession,"ssl","%s: invalid format:\n%s\n",consturl, crl_data->contents); return NULL; } data += 3; diff --git a/src/lib3270/testprogram/testprogram.c b/src/lib3270/testprogram/testprogram.c index c4d8e6c..21ccef0 100644 --- a/src/lib3270/testprogram/testprogram.c +++ b/src/lib3270/testprogram/testprogram.c @@ -28,6 +28,8 @@ int main(int argc, char *argv[]) h = lib3270_session_new(""); printf("3270 session %p created\n]",h); + lib3270_set_url(h,NULL); + int long_index =0; int opt; while((opt = getopt_long(argc, argv, "C:U:", options, &long_index )) != -1) { diff --git a/src/lib3270/windows/connect.c b/src/lib3270/windows/connect.c index 1d781c6..6b7574f 100644 --- a/src/lib3270/windows/connect.c +++ b/src/lib3270/windows/connect.c @@ -86,7 +86,7 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u else if(err) { char buffer[4096]; - snprintf(buffer,4095,_( "Can't connect to %s" ), hSession->host.current ); + snprintf(buffer,4095,_( "Can't connect to %s" ), lib3270_get_url(hSession) ); lib3270_disconnect(hSession); lib3270_popup_dialog( hSession, @@ -175,12 +175,17 @@ LIB3270_EXPORT int lib3270_connect_url(H3270 *hSession, const char *url, int wai struct addrinfo * result = NULL; struct addrinfo * rp = NULL; + if(!(hSession->host.current && hSession->host.srvc)) + return errno = ENOENT; + memset(&hints,0,sizeof(hints)); hints.ai_family = AF_UNSPEC; // Allow IPv4 or IPv6 hints.ai_socktype = SOCK_STREAM; // Stream socket hints.ai_flags = AI_PASSIVE; // For wildcard IP address hints.ai_protocol = 0; // Any protocol + debug("%s(%s,%s)",__FUNCTION__,hSession->host.current, hSession->host.srvc); + int rc = getaddrinfo(hSession->host.current, hSession->host.srvc, &hints, &result); if(rc != 0) { @@ -250,7 +255,7 @@ int lib3270_reconnect(H3270 *hSession, int seconds) char buffer[4096]; char msg[4096]; - snprintf(buffer,4095,_( "Can't connect to %s:%s"), hSession->host.current, hSession->host.srvc); + snprintf(buffer,4095,_( "Can't connect to %s"), lib3270_get_url(hSession)); strncpy(msg,host.message,4095); -- libgit2 0.21.2