Commit f007470aee9bd8b7d0a275122cbaba4c6c5d860d

Authored by Perry Werneck
1 parent ded9d88d

Adding "length" parameters in the "set" api calls.

Showing 2 changed files with 15 additions and 31 deletions   Show diff stats
src/core/paste.c
... ... @@ -227,18 +227,8 @@ static int set_string(H3270 *hSession, const unsigned char *str, int length)
227 227 return data.qtd;
228 228 }
229 229  
230   -/**
231   - * @brief Set string at defined position.
232   - *
233   - * @param hSession Session handle.
234   - * @param row Row for the first character.
235   - * @param col Col for the first character.
236   - * @param str String to set.
237   - *
238   - * @return negative if error (sets errno) or number of processed characters.
239   - *
240   - */
241   -LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, unsigned int row, unsigned int col, const unsigned char *str)
  230 +/// @brief Set string at defined position.
  231 +LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, unsigned int row, unsigned int col, const unsigned char *str, int length)
242 232 {
243 233 int rc = 0;
244 234  
... ... @@ -263,7 +253,7 @@ LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, unsigned int row, unsi
263 253 hSession->cbk.suspend(hSession);
264 254  
265 255 hSession->cursor_addr = (row * hSession->cols) + col;
266   - rc += set_string(hSession, str, -1);
  256 + rc += set_string(hSession, str, length);
267 257  
268 258 hSession->cbk.resume(hSession);
269 259 }
... ... @@ -302,16 +292,8 @@ LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, con
302 292 return rc;
303 293 }
304 294  
305   -/**
306   - * @brief Set string at cursor position.
307   - *
308   - * @param hSession Session handle.
309   - * @param str String to set
310   - *
311   - * @return negative if error (sets errno) or number of processed characters.
312   - *
313   - */
314   -LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str)
  295 +/// @brief Set string at cursor position.
  296 +LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str, int length)
315 297 {
316 298 int rc;
317 299  
... ... @@ -325,7 +307,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str)
325 307 return - (errno = EPERM);
326 308  
327 309 hSession->cbk.suspend(hSession);
328   - rc = set_string(hSession, str, -1);
  310 + rc = set_string(hSession, str, length);
329 311 hSession->cbk.resume(hSession);
330 312  
331 313 return rc;
... ... @@ -349,7 +331,7 @@ LIB3270_EXPORT int lib3270_paste(H3270 *h, const unsigned char *str)
349 331 h->paste_buffer = NULL;
350 332 }
351 333  
352   - sz = lib3270_set_string(h,str);
  334 + sz = lib3270_set_string(h,str,-1);
353 335 if(sz < 0)
354 336 {
355 337 // Can´t paste
... ...
src/include/lib3270.h
... ... @@ -696,15 +696,16 @@
696 696 * Returns are ignored; newlines mean "move to beginning of next line";
697 697 * tabs and formfeeds become spaces. Backslashes are not special
698 698 *
699   - * @param h Session handle.
700   - * @param s String to input.
  699 + * @param hSession Session handle.
  700 + * @param text String to input.
  701 + * @param length Length of the string (-1 for auto-detect).
701 702 *
702   - * @return -1 if error (sets errno) or number of processed characters.
  703 + * @return Negative if error (sets errno) or number of processed characters.
703 704 *
704 705 */
705   - LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str);
  706 + LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *text, int length);
706 707  
707   - #define lib3270_set_text_at(h,r,c,t) lib3270_set_string_at(h,r,c,t)
  708 + #define lib3270_set_text_at(h,r,c,t) lib3270_set_string_at(h,r,c,t,-1)
708 709  
709 710 /**
710 711 * @brief Set string at defined row/column.
... ... @@ -713,11 +714,12 @@
713 714 * @param row Row for the first character.
714 715 * @param col Col for the first character.
715 716 * @param str String to set.
  717 + * @param length Length of the string (-1 for auto-detect).
716 718 *
717 719 * @return Negative if error or number of processed characters.
718 720 *
719 721 */
720   - LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, unsigned int row, unsigned int col, const unsigned char *str);
  722 + LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, unsigned int row, unsigned int col, const unsigned char *str, int length);
721 723  
722 724 /**
723 725 * @brief Set string at defined adress.
... ...