Commit 13d1732bc9ffc14209f8980dd2b20ce81f23d9c7

Authored by Perry Werneck
1 parent 48efc5cc

Adjustments in the API.

src/core/ctlr.c
@@ -515,29 +515,35 @@ LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr) @@ -515,29 +515,35 @@ LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr)
515 return -1; 515 return -1;
516 } 516 }
517 517
518 -LIB3270_EXPORT int lib3270_get_field_attribute(H3270 *hSession, int baddr) 518 +LIB3270_EXPORT LIB3270_FIELD_ATTRIBUTE lib3270_get_field_attribute(H3270 *hSession, int baddr)
519 { 519 {
520 int sbaddr; 520 int sbaddr;
521 521
522 FAIL_IF_NOT_ONLINE(hSession); 522 FAIL_IF_NOT_ONLINE(hSession);
523 523
524 if(!hSession->formatted) 524 if(!hSession->formatted)
525 - return errno = ENOTCONN; 525 + {
  526 + errno = ENOTCONN;
  527 + return (LIB3270_FIELD_ATTRIBUTE) 0;
  528 + }
  529 +
  530 + if(baddr < 0)
  531 + baddr = lib3270_get_cursor_address(hSession);
526 532
527 sbaddr = baddr; 533 sbaddr = baddr;
528 do 534 do
529 { 535 {
530 if(hSession->ea_buf[baddr].fa) 536 if(hSession->ea_buf[baddr].fa)
531 - return hSession->ea_buf[baddr].fa; 537 + return (LIB3270_FIELD_ATTRIBUTE) hSession->ea_buf[baddr].fa;
  538 +
532 DEC_BA(baddr); 539 DEC_BA(baddr);
533 } while (baddr != sbaddr); 540 } while (baddr != sbaddr);
534 541
535 errno = EINVAL; 542 errno = EINVAL;
536 - return -1; 543 + return (LIB3270_FIELD_ATTRIBUTE) 0;
537 544
538 } 545 }
539 546
540 -  
541 /** 547 /**
542 * @brief Get the length of the field at given buffer address. 548 * @brief Get the length of the field at given buffer address.
543 * 549 *
src/include/lib3270.h
@@ -547,6 +547,14 @@ @@ -547,6 +547,14 @@
547 LIB3270_EXPORT int lib3270_get_secure_host(H3270 *hSession); 547 LIB3270_EXPORT int lib3270_get_secure_host(H3270 *hSession);
548 548
549 /** 549 /**
  550 + * @brief Get security state.
  551 + *
  552 + */
  553 + LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_ssl_state(H3270 *session);
  554 +
  555 + LIB3270_EXPORT long lib3270_get_SSL_verify_result(H3270 *session);
  556 +
  557 + /**
550 * @brief Get security state as text. 558 * @brief Get security state as text.
551 * 559 *
552 */ 560 */
@@ -971,8 +979,6 @@ @@ -971,8 +979,6 @@
971 LIB3270_EXPORT int lib3270_is_secure(H3270 *h); 979 LIB3270_EXPORT int lib3270_is_secure(H3270 *h);
972 980
973 LIB3270_EXPORT LIB3270_MESSAGE lib3270_lock_status(H3270 *h); 981 LIB3270_EXPORT LIB3270_MESSAGE lib3270_lock_status(H3270 *h);
974 - LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_secure(H3270 *session);  
975 - LIB3270_EXPORT long lib3270_get_SSL_verify_result(H3270 *session);  
976 982
977 /** 983 /**
978 * Run main iteration. 984 * Run main iteration.
@@ -1176,11 +1182,11 @@ @@ -1176,11 +1182,11 @@
1176 * @brief Get field attribute for a given buffer address. 1182 * @brief Get field attribute for a given buffer address.
1177 * 1183 *
1178 * @param hSession Session handle. 1184 * @param hSession Session handle.
1179 - * @param addr Buffer address of the field. 1185 + * @param addr Buffer address of the field (-1 to use the cursor address).
1180 * 1186 *
1181 - * @return field attribute or -1 when failed (sets errno). 1187 + * @return field attribute or 0 when failed (sets errno).
1182 */ 1188 */
1183 - LIB3270_EXPORT int lib3270_get_field_attribute(H3270 *hSession, int baddr); 1189 + LIB3270_EXPORT LIB3270_FIELD_ATTRIBUTE lib3270_get_field_attribute(H3270 *hSession, int baddr);
1184 1190
1185 /** 1191 /**
1186 * @brief Get the length of the field at given buffer address. 1192 * @brief Get the length of the field at given buffer address.
src/ssl/negotiate.c
@@ -434,30 +434,17 @@ void ssl_info_callback(INFO_CONST SSL *s, int where, int ret) @@ -434,30 +434,17 @@ void ssl_info_callback(INFO_CONST SSL *s, int where, int ret)
434 434
435 #endif /*]*/ 435 #endif /*]*/
436 436
437 -int popup_ssl_error(H3270 *hSession, int rc, const char *title, const char *summary, const char *body) 437 +int popup_ssl_error(H3270 GNUC_UNUSED(*hSession), int rc, const char *title, const char *summary, const char *body)
438 { 438 {
439 -#ifdef SSL_ENABLE_NOTIFICATION_WHEN_FAILED  
440 -  
441 - lib3270_write_log(hSession, "SSL", "%s", summary );  
442 - return hSession->cbk.popup_ssl_error(hSession,rc,title,summary,body);  
443 -  
444 -#else  
445 -  
446 - lib3270_autoptr(char) message = NULL;  
447 -  
448 - if(body && *body)  
449 - message = lib3270_strdup_printf("%s - rc=%d",body,rc);  
450 - else if(rc)  
451 - message = lib3270_strdup_printf("%s (rc=%d)",strerror(rc),rc);  
452 - else  
453 - message = lib3270_strdup_printf("rc=%d",rc);  
454 -  
455 #ifdef _WIN32 439 #ifdef _WIN32
456 440
  441 + lib3270_autoptr(char) rcMessage = lib3270_strdup_printf("The error code was %d",rc);
  442 +
457 const char *outMsg[] = { 443 const char *outMsg[] = {
458 title, 444 title,
459 summary, 445 summary,
460 - message 446 + (body ? body : ""),
  447 + rcMessage
461 }; 448 };
462 449
463 ReportEvent( 450 ReportEvent(
@@ -466,7 +453,7 @@ int popup_ssl_error(H3270 *hSession, int rc, const char *title, const char *summ @@ -466,7 +453,7 @@ int popup_ssl_error(H3270 *hSession, int rc, const char *title, const char *summ
466 1, 453 1,
467 0, 454 0,
468 NULL, 455 NULL,
469 - 3, 456 + (sizeof(outMsg)/sizeof(outMsg[0])),
470 0, 457 0,
471 outMsg, 458 outMsg,
472 NULL 459 NULL
@@ -474,18 +461,18 @@ int popup_ssl_error(H3270 *hSession, int rc, const char *title, const char *summ @@ -474,18 +461,18 @@ int popup_ssl_error(H3270 *hSession, int rc, const char *title, const char *summ
474 461
475 #else 462 #else
476 463
477 - lib3270_write_log(  
478 - hSession,  
479 - "SSL",  
480 - "%s - %s - %s",  
481 - title,  
482 - summary,  
483 - message  
484 - ); 464 + lib3270_write_log(hSession, "SSL", "%s %s (rc=%d)", summary, (body ? body : ""), rc);
485 465
486 #endif // _WIN32 466 #endif // _WIN32
487 467
  468 +#ifdef SSL_ENABLE_NOTIFICATION_WHEN_FAILED
  469 +
  470 + return hSession->cbk.popup_ssl_error(hSession,rc,title,summary,body);
  471 +
  472 +#else
  473 +
488 return 0; 474 return 0;
  475 +
489 #endif // SSL_ENABLE_NOTIFICATION_WHEN_FAILED 476 #endif // SSL_ENABLE_NOTIFICATION_WHEN_FAILED
490 477
491 } 478 }
src/ssl/state.c
@@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
47 47
48 LIB3270_EXPORT int lib3270_is_secure(H3270 *hSession) 48 LIB3270_EXPORT int lib3270_is_secure(H3270 *hSession)
49 { 49 {
50 - return lib3270_get_secure(hSession) == LIB3270_SSL_SECURE; 50 + return lib3270_get_ssl_state(hSession) == LIB3270_SSL_SECURE;
51 } 51 }
52 52
53 LIB3270_EXPORT long lib3270_get_SSL_verify_result(H3270 *hSession) 53 LIB3270_EXPORT long lib3270_get_SSL_verify_result(H3270 *hSession)
@@ -60,7 +60,7 @@ LIB3270_EXPORT long lib3270_get_SSL_verify_result(H3270 *hSession) @@ -60,7 +60,7 @@ LIB3270_EXPORT long lib3270_get_SSL_verify_result(H3270 *hSession)
60 return -1; 60 return -1;
61 } 61 }
62 62
63 -LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_secure(H3270 *hSession) 63 +LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_ssl_state(H3270 *hSession)
64 { 64 {
65 CHECK_SESSION_HANDLE(hSession); 65 CHECK_SESSION_HANDLE(hSession);
66 return hSession->ssl.state; 66 return hSession->ssl.state;
@@ -365,7 +365,7 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state) @@ -365,7 +365,7 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state)
365 365
366 const char * lib3270_get_ssl_state_message(H3270 *hSession) 366 const char * lib3270_get_ssl_state_message(H3270 *hSession)
367 { 367 {
368 - if(lib3270_get_secure(hSession) != LIB3270_SSL_UNSECURE) 368 + if(lib3270_get_ssl_state(hSession) != LIB3270_SSL_UNSECURE)
369 { 369 {
370 const struct ssl_status_msg *info = get_ssl_status_msg(hSession); 370 const struct ssl_status_msg *info = get_ssl_status_msg(hSession);
371 if(info) 371 if(info)
@@ -378,7 +378,7 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state) @@ -378,7 +378,7 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state)
378 378
379 const char * lib3270_get_ssl_state_icon_name(H3270 *hSession) 379 const char * lib3270_get_ssl_state_icon_name(H3270 *hSession)
380 { 380 {
381 - if(lib3270_get_secure(hSession) != LIB3270_SSL_UNSECURE) 381 + if(lib3270_get_ssl_state(hSession) != LIB3270_SSL_UNSECURE)
382 { 382 {
383 const struct ssl_status_msg *info = get_ssl_status_msg(hSession); 383 const struct ssl_status_msg *info = get_ssl_status_msg(hSession);
384 if(info) 384 if(info)
@@ -392,7 +392,7 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state) @@ -392,7 +392,7 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state)
392 392
393 const char * lib3270_get_ssl_state_description(H3270 *hSession) 393 const char * lib3270_get_ssl_state_description(H3270 *hSession)
394 { 394 {
395 - if(lib3270_get_secure(hSession) != LIB3270_SSL_UNSECURE) 395 + if(lib3270_get_ssl_state(hSession) != LIB3270_SSL_UNSECURE)
396 { 396 {
397 const struct ssl_status_msg *info = get_ssl_status_msg(hSession); 397 const struct ssl_status_msg *info = get_ssl_status_msg(hSession);
398 if(info) 398 if(info)
@@ -408,7 +408,7 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state) @@ -408,7 +408,7 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state)
408 408
409 LIB3270_NOTIFY lib3270_get_ssl_state_icon(H3270 *hSession) 409 LIB3270_NOTIFY lib3270_get_ssl_state_icon(H3270 *hSession)
410 { 410 {
411 - if(lib3270_get_secure(hSession) != LIB3270_SSL_UNSECURE) 411 + if(lib3270_get_ssl_state(hSession) != LIB3270_SSL_UNSECURE)
412 { 412 {
413 const struct ssl_status_msg *info = get_ssl_status_msg(hSession); 413 const struct ssl_status_msg *info = get_ssl_status_msg(hSession);
414 if(info) 414 if(info)