Commit 260255dac7d783e6133a22fd3622400374aaec9d

Authored by Perry Werneck
1 parent c8c041d6

Updating API.

Showing 2 changed files with 11 additions and 8 deletions   Show diff stats
src/core/keyboard/kybd.c
@@ -926,17 +926,19 @@ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean @@ -926,17 +926,19 @@ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean
926 return True; 926 return True;
927 } 927 }
928 928
929 -LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str) 929 +LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str, int length)
930 { 930 {
931 int rc = 0; 931 int rc = 0;
932 932
933 - FAIL_IF_NOT_ONLINE(hSession); 933 + if(check_online_session(hSession))
  934 + return errno;
934 935
935 - while(*str && !rc)  
936 - {  
937 - rc = key_ACharacter(hSession,(unsigned char)((*str) & 0xff), KT_STD, IA_KEY, NULL);  
938 - str++;  
939 - } 936 + if(length < 0)
  937 + length = strlen((char *) str);
  938 +
  939 + int pos;
  940 + for(pos = 0; pos < length && str[pos] && !rc; pos++)
  941 + rc = key_ACharacter(hSession,(str[pos] & 0xff), KT_STD, IA_KEY, NULL);
940 942
941 screen_update(hSession,0,hSession->rows*hSession->cols); 943 screen_update(hSession,0,hSession->rows*hSession->cols);
942 944
src/include/lib3270.h
@@ -729,11 +729,12 @@ @@ -729,11 +729,12 @@
729 * 729 *
730 * @param hSession Session handle. 730 * @param hSession Session handle.
731 * @param str Text to insert. 731 * @param str Text to insert.
  732 + * @param length Length of the string (-1 for auto-detect).
732 * 733 *
733 * @return 0 if success, non zero if failed. 734 * @return 0 if success, non zero if failed.
734 * 735 *
735 */ 736 */
736 - LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str); 737 + LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str, int length);
737 738
738 /** 739 /**
739 * @brief Move cursor to a new position. 740 * @brief Move cursor to a new position.