From 260255dac7d783e6133a22fd3622400374aaec9d Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Fri, 9 Aug 2019 15:28:15 -0300 Subject: [PATCH] Updating API. --- src/core/keyboard/kybd.c | 16 +++++++++------- src/include/lib3270.h | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/core/keyboard/kybd.c b/src/core/keyboard/kybd.c index bc564a1..a0450b0 100644 --- a/src/core/keyboard/kybd.c +++ b/src/core/keyboard/kybd.c @@ -926,17 +926,19 @@ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean return True; } -LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str) +LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str, int length) { int rc = 0; - FAIL_IF_NOT_ONLINE(hSession); + if(check_online_session(hSession)) + return errno; - while(*str && !rc) - { - rc = key_ACharacter(hSession,(unsigned char)((*str) & 0xff), KT_STD, IA_KEY, NULL); - str++; - } + if(length < 0) + length = strlen((char *) str); + + int pos; + for(pos = 0; pos < length && str[pos] && !rc; pos++) + rc = key_ACharacter(hSession,(str[pos] & 0xff), KT_STD, IA_KEY, NULL); screen_update(hSession,0,hSession->rows*hSession->cols); diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 5702957..f8462db 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -729,11 +729,12 @@ * * @param hSession Session handle. * @param str Text to insert. + * @param length Length of the string (-1 for auto-detect). * * @return 0 if success, non zero if failed. * */ - LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str); + LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str, int length); /** * @brief Move cursor to a new position. -- libgit2 0.21.2