Commit 8f18b25336815a42eee2472ea7b633e255fbb5b2

Authored by Perry Werneck
1 parent 5e9d1f19

Adding documentation and return code on input string method.

src/include/lib3270.h
@@ -723,6 +723,15 @@ @@ -723,6 +723,15 @@
723 */ 723 */
724 LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, const unsigned char *str); 724 LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, const unsigned char *str);
725 725
  726 + /**
  727 + * @brief Insert string at current cursor position.
  728 + *
  729 + * @param hSession Session handle.
  730 + * @param str Text to insert.
  731 + *
  732 + * @return 0 if success, non zero if failed.
  733 + *
  734 + */
726 LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str); 735 LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str);
727 736
728 /** 737 /**
src/lib3270/kybd.c
@@ -437,7 +437,7 @@ static void operator_error(H3270 *hSession, int error_type) @@ -437,7 +437,7 @@ static void operator_error(H3270 *hSession, int error_type)
437 if(hSession->oerr_lock) 437 if(hSession->oerr_lock)
438 { 438 {
439 status_oerr(hSession,error_type); 439 status_oerr(hSession,error_type);
440 - mcursor_locked(hSession); 440 + mcursor_set(hSession,LIB3270_POINTER_LOCKED);
441 kybdlock_set(hSession,(unsigned int)error_type); 441 kybdlock_set(hSession,(unsigned int)error_type);
442 flush_ta(hSession); 442 flush_ta(hSession);
443 } 443 }
@@ -963,24 +963,26 @@ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean @@ -963,24 +963,26 @@ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean
963 963
964 LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str) 964 LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str)
965 { 965 {
  966 + int rc = 0;
  967 +
966 FAIL_IF_NOT_ONLINE(hSession); 968 FAIL_IF_NOT_ONLINE(hSession);
967 969
968 - while(*str) 970 + while(*str && !rc)
969 { 971 {
970 - key_ACharacter(hSession,(unsigned char)((*str) & 0xff), KT_STD, IA_KEY, NULL); 972 + rc = key_ACharacter(hSession,(unsigned char)((*str) & 0xff), KT_STD, IA_KEY, NULL);
971 str++; 973 str++;
972 } 974 }
973 975
974 screen_update(hSession,0,hSession->rows*hSession->cols); 976 screen_update(hSession,0,hSession->rows*hSession->cols);
975 977
976 - return 0; 978 + return rc;
977 } 979 }
978 980
979 /** 981 /**
980 * @brief Handle an ordinary character key, given an ASCII code. 982 * @brief Handle an ordinary character key, given an ASCII code.
981 * 983 *
982 */ 984 */
983 -void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped) 985 +int key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped)
984 { 986 {
985 if (skipped != NULL) 987 if (skipped != NULL)
986 *skipped = False; 988 *skipped = False;
@@ -992,7 +994,7 @@ void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum @@ -992,7 +994,7 @@ void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum
992 if (c < ' ') 994 if (c < ' ')
993 { 995 {
994 lib3270_trace_event(hSession," dropped (control char)\n"); 996 lib3270_trace_event(hSession," dropped (control char)\n");
995 - return; 997 + return errno = EINVAL;
996 } 998 }
997 (void) key_Character(hSession, (int) hSession->charset.asc2ebc[c], keytype == KT_GE, False, skipped); 999 (void) key_Character(hSession, (int) hSession->charset.asc2ebc[c], keytype == KT_GE, False, skipped);
998 } 1000 }
@@ -1005,7 +1007,9 @@ void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum @@ -1005,7 +1007,9 @@ void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum
1005 else 1007 else
1006 { 1008 {
1007 lib3270_trace_event(hSession," dropped (not connected)\n"); 1009 lib3270_trace_event(hSession," dropped (not connected)\n");
  1010 + return errno = ENOTCONN;
1008 } 1011 }
  1012 + return 0;
1009 } 1013 }
1010 1014
1011 LIB3270_EXPORT int lib3270_nextfield(H3270 *hSession) 1015 LIB3270_EXPORT int lib3270_nextfield(H3270 *hSession)
src/lib3270/private.h
@@ -687,7 +687,7 @@ struct _h3270 @@ -687,7 +687,7 @@ struct _h3270
687 #define SELECTION_ACTIVE 0x80 687 #define SELECTION_ACTIVE 0x80
688 688
689 /* Library internal calls */ 689 /* Library internal calls */
690 -LIB3270_INTERNAL void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped); 690 +LIB3270_INTERNAL int key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped);
691 LIB3270_INTERNAL int cursor_move(H3270 *session, int baddr); 691 LIB3270_INTERNAL int cursor_move(H3270 *session, int baddr);
692 692
693 LIB3270_INTERNAL void toggle_rectselect(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE tt); 693 LIB3270_INTERNAL void toggle_rectselect(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE tt);