Commit 7fe37ca628a3709842d402bbd46cd28d62d09720

Authored by Perry Werneck
1 parent 0c40faba

Debugging API.

src/core/ctlr.c
... ... @@ -429,14 +429,21 @@ static void ctlr_connect(H3270 *hSession, int GNUC_UNUSED(ignored), void GNUC_UN
429 429 hSession->crm_nattr = 0;
430 430 }
431 431  
  432 +/**
  433 + * @brief Get field address.
  434 + *
  435 + * @return Negative on error(sets errno) or field address.
  436 + *
  437 + */
432 438 LIB3270_EXPORT int lib3270_get_field_start(H3270 *hSession, int baddr)
433 439 {
434 440 int sbaddr;
435 441  
436   - CHECK_SESSION_HANDLE(hSession);
  442 + if(check_online_session(hSession))
  443 + return - errno;
437 444  
438 445 if (!hSession->formatted)
439   - return errno = ENOTCONN;
  446 + return - (errno = ENOTCONN);
440 447  
441 448 if(baddr < 0)
442 449 baddr = hSession->cursor_addr;
... ...
src/core/iocalls.c
... ... @@ -472,7 +472,7 @@ LIB3270_EXPORT int lib3270_wait(H3270 *hSession, int seconds)
472 472 return 0;
473 473 }
474 474  
475   -LIB3270_EXPORT int wait_for_update(H3270 *hSession, int seconds)
  475 +LIB3270_EXPORT int lib3270_wait_for_update(H3270 *hSession, int seconds)
476 476 {
477 477 return errno = ENOTSUP;
478 478 }
... ...
src/core/paste.c
... ... @@ -93,9 +93,10 @@
93 93  
94 94 /*---[ Implement ]----------------------------------------------------------------------------------------------*/
95 95  
96   -/*
97   - * Move the cursor back within the legal paste area.
98   - * Returns a Boolean indicating success.
  96 +/**
  97 + * @brief Move the cursor back within the legal paste area.
  98 + *
  99 + * @return A Boolean indicating success.
99 100 */
100 101 static int remargin(H3270 *hSession, int lmargin)
101 102 {
... ... @@ -234,18 +235,22 @@ static int set_string(H3270 *hSession, const unsigned char *str, int length)
234 235 * @param col Col for the first character.
235 236 * @param str String to set.
236 237 *
237   - * @return -1 if error (sets errno) or number of processed characters.
  238 + * @return negative if error (sets errno) or number of processed characters.
238 239 *
239 240 */
240 241 LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, unsigned int row, unsigned int col, const unsigned char *str)
241 242 {
242 243 int rc = 0;
243 244  
244   - FAIL_IF_NOT_ONLINE(hSession);
  245 + if(!(str && *str))
  246 + return 0;
  247 +
  248 + if(check_online_session(hSession))
  249 + return - errno;
245 250  
246 251 // Is Keyboard locked ?
247 252 if(hSession->kybdlock)
248   - return errno = EPERM;
  253 + return - (errno = EPERM);
249 254  
250 255 if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED))
251 256 lib3270_unselect(hSession);
... ... @@ -272,12 +277,19 @@ LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, con
272 277 {
273 278 int rc = -1;
274 279  
275   - FAIL_IF_NOT_ONLINE(hSession);
  280 + if(!(str && *str))
  281 + return 0;
  282 +
  283 + if(check_online_session(hSession))
  284 + return - errno;
  285 +
  286 + if(length < 0)
  287 + length = (int) strlen((const char *) str);
276 288  
277 289 if(hSession->kybdlock)
278   - return errno = EPERM;
  290 + return - (errno = EPERM);
279 291  
280   - if(lib3270_set_cursor_address(hSession,baddr) < 0)
  292 + if(baddr >= 0 && lib3270_set_cursor_address(hSession,baddr) < 0)
281 293 return -1;
282 294  
283 295 if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED))
... ... @@ -296,17 +308,21 @@ LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, con
296 308 * @param hSession Session handle.
297 309 * @param str String to set
298 310 *
299   - * @return -1 if error (sets errno) or number of processed characters.
  311 + * @return negative if error (sets errno) or number of processed characters.
300 312 *
301 313 */
302 314 LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str)
303 315 {
304 316 int rc;
305 317  
306   - FAIL_IF_NOT_ONLINE(hSession);
  318 + if(!(str && *str))
  319 + return 0;
  320 +
  321 + if(check_online_session(hSession))
  322 + return - errno;
307 323  
308 324 if(hSession->kybdlock)
309   - return errno = EPERM;
  325 + return - (errno = EPERM);
310 326  
311 327 hSession->cbk.suspend(hSession);
312 328 rc = set_string(hSession, str, -1);
... ...
src/include/lib3270.h
... ... @@ -723,7 +723,7 @@
723 723 * @brief Set string at defined adress.
724 724 *
725 725 * @param hSession Session handle.
726   - * @param baddr Adress for the first character.
  726 + * @param baddr Adress for the first character (-1 for cursor position).
727 727 * @param str String to set.
728 728 * @param length Length of the string (-1 for auto-detect).
729 729 *
... ... @@ -1017,7 +1017,7 @@
1017 1017 * @param seconds Number of seconds to wait.
1018 1018 *
1019 1019 */
1020   - LIB3270_EXPORT int wait_for_update(H3270 *hSession, int seconds);
  1020 + LIB3270_EXPORT int lib3270_wait_for_update(H3270 *hSession, int seconds);
1021 1021  
1022 1022 /**
1023 1023 * Wait "N" seconds for "ready" state.
... ...