Commit 6a81f385f489f922f35d660929caa47aaaeab3ed

Authored by Perry Werneck
1 parent d1ef560b
Exists in master and in 2 other branches develop, macos

Debugging unexpected response on lib3270_get_cursor_adress().

src/core/properties/signed.c
@@ -62,6 +62,14 @@ @@ -62,6 +62,14 @@
62 }, 62 },
63 63
64 { 64 {
  65 + .name = "cursor_address", // Property name.
  66 + .group = LIB3270_ACTION_GROUP_ONLINE, // Property group.
  67 + .description = N_( "Cursor address" ), // Property description.
  68 + .get = lib3270_get_cursor_address, // Get value.
  69 + .set = lib3270_set_cursor_address // Set value.
  70 + },
  71 +
  72 + {
65 .name = "program_message", // Property name. 73 .name = "program_message", // Property name.
66 .description = N_( "Latest program message" ), // Property description. 74 .description = N_( "Latest program message" ), // Property description.
67 .get = lib3270_get_program_message_as_int, // Get value. 75 .get = lib3270_get_program_message_as_int, // Get value.
src/core/properties/unsigned.c
@@ -103,14 +103,6 @@ static unsigned int lib3270_get_host_type_number(const H3270 *hSession) @@ -103,14 +103,6 @@ static unsigned int lib3270_get_host_type_number(const H3270 *hSession)
103 }, 103 },
104 104
105 { 105 {
106 - .name = "cursor_address", // Property name.  
107 - .group = LIB3270_ACTION_GROUP_ONLINE, // Property group.  
108 - .description = N_( "Cursor address" ), // Property description.  
109 - .get = lib3270_get_cursor_address, // Get value.  
110 - .set = lib3270_set_cursor_address // Set value.  
111 - },  
112 -  
113 - {  
114 .name = "width", // Property name. 106 .name = "width", // Property name.
115 .description = N_( "Current screen width in columns" ), // Property description. 107 .description = N_( "Current screen width in columns" ), // Property description.
116 .get = lib3270_get_width, // Get value. 108 .get = lib3270_get_width, // Get value.
src/core/screen.c
@@ -416,12 +416,10 @@ void screen_update(H3270 *session, int bstart, int bend) @@ -416,12 +416,10 @@ void screen_update(H3270 *session, int bstart, int bend)
416 416
417 } 417 }
418 418
419 -LIB3270_EXPORT unsigned int lib3270_get_cursor_address(const H3270 *hSession) 419 +LIB3270_EXPORT int lib3270_get_cursor_address(const H3270 *hSession)
420 { 420 {
421 - if(check_online_session(hSession))  
422 - return 0;  
423 -  
424 - return hSession->cursor_addr; 421 + int state = check_online_session(hSession);
  422 + return state ? -state : hSession->cursor_addr;
425 } 423 }
426 424
427 /** 425 /**
@@ -448,13 +446,13 @@ LIB3270_EXPORT int lib3270_translate_to_address(const H3270 *hSession, unsigned @@ -448,13 +446,13 @@ LIB3270_EXPORT int lib3270_translate_to_address(const H3270 *hSession, unsigned
448 } 446 }
449 447
450 448
451 -LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int baddr) 449 +LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, int baddr)
452 { 450 {
453 FAIL_IF_NOT_ONLINE(hSession); 451 FAIL_IF_NOT_ONLINE(hSession);
454 452
455 trace("%s(%d)",__FUNCTION__,baddr); 453 trace("%s(%d)",__FUNCTION__,baddr);
456 454
457 - if(baddr > (hSession->view.rows * hSession->view.cols)) 455 + if( ((unsigned int) baddr) > (hSession->view.rows * hSession->view.cols))
458 return - (errno = EOVERFLOW); 456 return - (errno = EOVERFLOW);
459 457
460 if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED)) 458 if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED))
src/include/lib3270.h
@@ -736,7 +736,7 @@ @@ -736,7 +736,7 @@
736 * @retval -ENOTCONN Disconnected from host. 736 * @retval -ENOTCONN Disconnected from host.
737 * 737 *
738 */ 738 */
739 - LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int baddr); 739 + LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, int baddr);
740 740
741 /** 741 /**
742 * @brief Set cursor position. 742 * @brief Set cursor position.
@@ -757,10 +757,14 @@ @@ -757,10 +757,14 @@
757 * 757 *
758 * @param hSession Session handle. 758 * @param hSession Session handle.
759 * 759 *
760 - * @return Cursor address or 0 if invalid (sets errno). 760 + * @return Cursor address or negative if invalid (sets errno).
  761 + *
  762 + * @retval -ENOTCONN Disconnected from host.
  763 + * @retval -EINVAL Invalid session handle.
  764 + * @retval -1 Unexpected error.
761 * 765 *
762 */ 766 */
763 - LIB3270_EXPORT unsigned int lib3270_get_cursor_address(const H3270 *hSession); 767 + LIB3270_EXPORT int lib3270_get_cursor_address(const H3270 *hSession);
764 768
765 /** 769 /**
766 * @brief Move cursor 770 * @brief Move cursor