Commit 9e14881bc2555401514a0b787ea26da2edbdf630
1 parent
dd36c196
Exists in
master
and in
3 other branches
Updating documentation, adjusting return codes.
Showing
7 changed files
with
83 additions
and
95 deletions
Show diff stats
Makefile.in
| @@ -64,6 +64,7 @@ GENMARSHAL=@GENMARSHAL@ | @@ -64,6 +64,7 @@ GENMARSHAL=@GENMARSHAL@ | ||
| 64 | CONVERT=@CONVERT@ | 64 | CONVERT=@CONVERT@ |
| 65 | OPTIPNG=@OPTIPNG@ | 65 | OPTIPNG=@OPTIPNG@ |
| 66 | ZIP=@ZIP@ | 66 | ZIP=@ZIP@ |
| 67 | +DOXYGEN=@DOXYGEN@ | ||
| 67 | 68 | ||
| 68 | #---[ Paths ]---------------------------------------------------------------------------- | 69 | #---[ Paths ]---------------------------------------------------------------------------- |
| 69 | 70 | ||
| @@ -351,6 +352,8 @@ $(POTDIR)/lib3270.pot: \ | @@ -351,6 +352,8 @@ $(POTDIR)/lib3270.pot: \ | ||
| 351 | locale: \ | 352 | locale: \ |
| 352 | $(POTDIR)/lib3270.pot | 353 | $(POTDIR)/lib3270.pot |
| 353 | 354 | ||
| 355 | +doc: | ||
| 356 | + @$(DOXYGEN) ./doxygen/doxyfile | ||
| 354 | 357 | ||
| 355 | #---[ Debug Targets ]-------------------------------------------------------------------- | 358 | #---[ Debug Targets ]-------------------------------------------------------------------- |
| 356 | 359 |
src/core/keyboard/kybd.c
| @@ -940,6 +940,9 @@ LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *st | @@ -940,6 +940,9 @@ LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *st | ||
| 940 | if(length < 0) | 940 | if(length < 0) |
| 941 | length = strlen((char *) str); | 941 | length = strlen((char *) str); |
| 942 | 942 | ||
| 943 | + if(hSession->kybdlock) | ||
| 944 | + return (errno = EPERM); | ||
| 945 | + | ||
| 943 | int pos; | 946 | int pos; |
| 944 | for(pos = 0; pos < length && str[pos] && !rc; pos++) | 947 | for(pos = 0; pos < length && str[pos] && !rc; pos++) |
| 945 | rc = key_ACharacter(hSession,(str[pos] & 0xff), KT_STD, IA_KEY, NULL); | 948 | rc = key_ACharacter(hSession,(str[pos] & 0xff), KT_STD, IA_KEY, NULL); |
src/core/paste.c
| @@ -248,15 +248,14 @@ LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, unsigned int row, unsi | @@ -248,15 +248,14 @@ LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, unsigned int row, unsi | ||
| 248 | row--; | 248 | row--; |
| 249 | col--; | 249 | col--; |
| 250 | 250 | ||
| 251 | - if(row <= hSession->rows && col <= hSession->cols) | ||
| 252 | - { | ||
| 253 | - hSession->cbk.suspend(hSession); | 251 | + if(row > hSession->rows || col > hSession->cols) |
| 252 | + return - (errno = EOVERFLOW); | ||
| 254 | 253 | ||
| 255 | - hSession->cursor_addr = (row * hSession->cols) + col; | ||
| 256 | - rc += set_string(hSession, str, length); | 254 | + hSession->cbk.suspend(hSession); |
| 257 | 255 | ||
| 258 | - hSession->cbk.resume(hSession); | ||
| 259 | - } | 256 | + hSession->cursor_addr = (row * hSession->cols) + col; |
| 257 | + rc = set_string(hSession, str, length); | ||
| 258 | + hSession->cbk.resume(hSession); | ||
| 260 | 259 | ||
| 261 | trace("%s rc=%d",__FUNCTION__,rc); | 260 | trace("%s rc=%d",__FUNCTION__,rc); |
| 262 | 261 | ||
| @@ -279,8 +278,12 @@ LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, con | @@ -279,8 +278,12 @@ LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, con | ||
| 279 | if(hSession->kybdlock) | 278 | if(hSession->kybdlock) |
| 280 | return - (errno = EPERM); | 279 | return - (errno = EPERM); |
| 281 | 280 | ||
| 282 | - if(baddr >= 0 && lib3270_set_cursor_address(hSession,baddr) < 0) | ||
| 283 | - return -1; | 281 | + if(baddr >= 0) |
| 282 | + { | ||
| 283 | + rc = lib3270_set_cursor_address(hSession,baddr); | ||
| 284 | + if(rc < 0) | ||
| 285 | + return rc; | ||
| 286 | + } | ||
| 284 | 287 | ||
| 285 | if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED)) | 288 | if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED)) |
| 286 | lib3270_unselect(hSession); | 289 | lib3270_unselect(hSession); |
| @@ -306,6 +309,9 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str, | @@ -306,6 +309,9 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str, | ||
| 306 | if(hSession->kybdlock) | 309 | if(hSession->kybdlock) |
| 307 | return - (errno = EPERM); | 310 | return - (errno = EPERM); |
| 308 | 311 | ||
| 312 | + if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED)) | ||
| 313 | + lib3270_unselect(hSession); | ||
| 314 | + | ||
| 309 | hSession->cbk.suspend(hSession); | 315 | hSession->cbk.suspend(hSession); |
| 310 | rc = set_string(hSession, str, length); | 316 | rc = set_string(hSession, str, length); |
| 311 | hSession->cbk.resume(hSession); | 317 | hSession->cbk.resume(hSession); |
src/core/screen.c
| @@ -431,27 +431,12 @@ LIB3270_EXPORT int lib3270_translate_to_address(H3270 *hSession, unsigned int ro | @@ -431,27 +431,12 @@ LIB3270_EXPORT int lib3270_translate_to_address(H3270 *hSession, unsigned int ro | ||
| 431 | col--; | 431 | col--; |
| 432 | 432 | ||
| 433 | if(row > hSession->rows || col > hSession->cols) | 433 | if(row > hSession->rows || col > hSession->cols) |
| 434 | - { | ||
| 435 | - // Invalid coordinates | ||
| 436 | - errno = EINVAL; | ||
| 437 | - return -1; | ||
| 438 | - } | 434 | + return - (errno = EOVERFLOW); |
| 439 | 435 | ||
| 440 | return (row * hSession->cols) + col; | 436 | return (row * hSession->cols) + col; |
| 441 | } | 437 | } |
| 442 | 438 | ||
| 443 | 439 | ||
| 444 | -/** | ||
| 445 | - * @brief Move cursor to a new position. | ||
| 446 | - * | ||
| 447 | - * @see lib3270_set_cursor_position | ||
| 448 | - * | ||
| 449 | - * @param hSession TN3270 session. | ||
| 450 | - * @param baddr New cursor position. | ||
| 451 | - * | ||
| 452 | - * @return Old cursor address or -1 in case of error (sets errno). | ||
| 453 | - * | ||
| 454 | - */ | ||
| 455 | LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int baddr) | 440 | LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int baddr) |
| 456 | { | 441 | { |
| 457 | FAIL_IF_NOT_ONLINE(hSession); | 442 | FAIL_IF_NOT_ONLINE(hSession); |
| @@ -459,10 +444,7 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int badd | @@ -459,10 +444,7 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int badd | ||
| 459 | trace("%s(%d)",__FUNCTION__,baddr); | 444 | trace("%s(%d)",__FUNCTION__,baddr); |
| 460 | 445 | ||
| 461 | if(baddr > (hSession->rows * hSession->cols)) | 446 | if(baddr > (hSession->rows * hSession->cols)) |
| 462 | - { | ||
| 463 | - errno = EINVAL; | ||
| 464 | - return -1; | ||
| 465 | - } | 447 | + return - (errno = EOVERFLOW); |
| 466 | 448 | ||
| 467 | if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED)) | 449 | if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED)) |
| 468 | lib3270_unselect(hSession); | 450 | lib3270_unselect(hSession); |
| @@ -470,46 +452,13 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int badd | @@ -470,46 +452,13 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int badd | ||
| 470 | return cursor_move(hSession,baddr); | 452 | return cursor_move(hSession,baddr); |
| 471 | } | 453 | } |
| 472 | 454 | ||
| 473 | -/** | ||
| 474 | - * @brief Move cursor to a new position. | ||
| 475 | - * | ||
| 476 | - * @see lib3270_set_cursor_position | ||
| 477 | - * | ||
| 478 | - * @param hSession TN3270 session. | ||
| 479 | - * @param row New cursor row. | ||
| 480 | - * @parma col New cursor column. | ||
| 481 | - * | ||
| 482 | - * @return Old cursor address or -1 in case of error (sets errno). | ||
| 483 | - * | ||
| 484 | - */ | ||
| 485 | LIB3270_EXPORT int lib3270_set_cursor_position(H3270 *hSession, unsigned int row, unsigned int col) | 455 | LIB3270_EXPORT int lib3270_set_cursor_position(H3270 *hSession, unsigned int row, unsigned int col) |
| 486 | { | 456 | { |
| 487 | - return lib3270_set_cursor_address(hSession,lib3270_translate_to_address(hSession, row, col)); | ||
| 488 | - | ||
| 489 | - /* | ||
| 490 | - int baddr = -1; | ||
| 491 | - | ||
| 492 | - CHECK_SESSION_HANDLE(h); | ||
| 493 | - | ||
| 494 | - if(h->selected && !lib3270_get_toggle(h,LIB3270_TOGGLE_KEEP_SELECTED)) | ||
| 495 | - lib3270_unselect(h); | ||
| 496 | - | ||
| 497 | - row--; | ||
| 498 | - col--; | ||
| 499 | - | ||
| 500 | - if(row >= 0 && col >= 0 && row <= h->rows && col <= h->cols) | ||
| 501 | - { | ||
| 502 | - baddr = (row * h->cols) + col; | 457 | + int baddr = lib3270_translate_to_address(hSession, row, col); |
| 458 | + if(baddr < 0) | ||
| 459 | + return -errno; | ||
| 503 | 460 | ||
| 504 | - if(baddr != h->cursor_addr) | ||
| 505 | - { | ||
| 506 | - h->cursor_addr = baddr; | ||
| 507 | - h->cbk.update_cursor(h,(unsigned short) row,(unsigned short) col,h->text[baddr].chr,h->text[baddr].attr); | ||
| 508 | - } | ||
| 509 | - } | ||
| 510 | - | ||
| 511 | - return baddr; | ||
| 512 | - */ | 461 | + return lib3270_set_cursor_address(hSession,baddr); |
| 513 | } | 462 | } |
| 514 | 463 | ||
| 515 | /** | 464 | /** |
| @@ -527,10 +476,7 @@ int cursor_move(H3270 *hSession, int baddr) | @@ -527,10 +476,7 @@ int cursor_move(H3270 *hSession, int baddr) | ||
| 527 | { | 476 | { |
| 528 | int ret = hSession->cursor_addr; | 477 | int ret = hSession->cursor_addr; |
| 529 | 478 | ||
| 530 | - if(ret == baddr) | ||
| 531 | - return ret; | ||
| 532 | - | ||
| 533 | - if(baddr >= 0) | 479 | + if(ret != baddr && baddr >= 0) |
| 534 | { | 480 | { |
| 535 | hSession->cursor_addr = baddr; | 481 | hSession->cursor_addr = baddr; |
| 536 | hSession->cbk.update_cursor( | 482 | hSession->cbk.update_cursor( |
| @@ -545,15 +491,13 @@ int cursor_move(H3270 *hSession, int baddr) | @@ -545,15 +491,13 @@ int cursor_move(H3270 *hSession, int baddr) | ||
| 545 | return ret; | 491 | return ret; |
| 546 | } | 492 | } |
| 547 | 493 | ||
| 548 | -/* Status line stuff. */ | ||
| 549 | - | 494 | +/** |
| 495 | + * @brief Status line stuff. | ||
| 496 | + */ | ||
| 550 | void set_status(H3270 *session, LIB3270_FLAG id, Boolean on) | 497 | void set_status(H3270 *session, LIB3270_FLAG id, Boolean on) |
| 551 | { | 498 | { |
| 552 | - CHECK_SESSION_HANDLE(session); | ||
| 553 | - | ||
| 554 | session->oia.flag[id] = (on != 0); | 499 | session->oia.flag[id] = (on != 0); |
| 555 | session->cbk.update_oia(session,id,session->oia.flag[id]); | 500 | session->cbk.update_oia(session,id,session->oia.flag[id]); |
| 556 | - | ||
| 557 | } | 501 | } |
| 558 | 502 | ||
| 559 | void status_ctlr_done(H3270 *session) | 503 | void status_ctlr_done(H3270 *session) |
src/include/lib3270.h
| @@ -685,7 +685,9 @@ | @@ -685,7 +685,9 @@ | ||
| 685 | * @param row Row inside the screen. | 685 | * @param row Row inside the screen. |
| 686 | * @param col Col inside the screen. | 686 | * @param col Col inside the screen. |
| 687 | * | 687 | * |
| 688 | - * @return Current address or -1 if invalid (sets errno). | 688 | + * @return Current address or negative if invalid (sets errno). |
| 689 | + * | ||
| 690 | + * @retval -EOVERFLOW The coordinates are out of the screen. | ||
| 689 | * | 691 | * |
| 690 | */ | 692 | */ |
| 691 | LIB3270_EXPORT int lib3270_translate_to_address(H3270 *hSession, unsigned int row, unsigned int col); | 693 | LIB3270_EXPORT int lib3270_translate_to_address(H3270 *hSession, unsigned int row, unsigned int col); |
| @@ -710,13 +712,19 @@ | @@ -710,13 +712,19 @@ | ||
| 710 | /** | 712 | /** |
| 711 | * @brief Set string at defined row/column. | 713 | * @brief Set string at defined row/column. |
| 712 | * | 714 | * |
| 715 | + * Set the string in the defined row/column; returns number of processed caracter if succeeds or negative value if not. | ||
| 716 | + * | ||
| 713 | * @param hSession Session handle. | 717 | * @param hSession Session handle. |
| 714 | * @param row Row for the first character. | 718 | * @param row Row for the first character. |
| 715 | * @param col Col for the first character. | 719 | * @param col Col for the first character. |
| 716 | * @param str String to set. | 720 | * @param str String to set. |
| 717 | * @param length Length of the string (-1 for auto-detect). | 721 | * @param length Length of the string (-1 for auto-detect). |
| 718 | * | 722 | * |
| 719 | - * @return Negative if error or number of processed characters. | 723 | + * @return Negative if error or number (sets errno) of processed characters. |
| 724 | + * | ||
| 725 | + * @retval -EPERM The keyboard is locked. | ||
| 726 | + * @retval -EOVERFLOW The row or col is bigger than the screen size. | ||
| 727 | + * @retval -ENOTCONN Disconnected from host. | ||
| 720 | * | 728 | * |
| 721 | */ | 729 | */ |
| 722 | LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, unsigned int row, unsigned int col, const unsigned char *str, int length); | 730 | LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, unsigned int row, unsigned int col, const unsigned char *str, int length); |
| @@ -731,6 +739,10 @@ | @@ -731,6 +739,10 @@ | ||
| 731 | * | 739 | * |
| 732 | * @return Negative if error or number of processed characters. | 740 | * @return Negative if error or number of processed characters. |
| 733 | * | 741 | * |
| 742 | + * @retval -EPERM The keyboard is locked. | ||
| 743 | + * @retval -EOVERFLOW The address is beyond the screen length. | ||
| 744 | + * @retval -ENOTCONN Disconnected from host. | ||
| 745 | + * | ||
| 734 | */ | 746 | */ |
| 735 | LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, const unsigned char *str, int length); | 747 | LIB3270_EXPORT int lib3270_set_string_at_address(H3270 *hSession, int baddr, const unsigned char *str, int length); |
| 736 | 748 | ||
| @@ -741,7 +753,10 @@ | @@ -741,7 +753,10 @@ | ||
| 741 | * @param str Text to insert. | 753 | * @param str Text to insert. |
| 742 | * @param length Length of the string (-1 for auto-detect). | 754 | * @param length Length of the string (-1 for auto-detect). |
| 743 | * | 755 | * |
| 744 | - * @return 0 if success, non zero if failed. | 756 | + * @return 0 if success, non zero if failed (sets errno). |
| 757 | + * | ||
| 758 | + * @retval EPERM The keyboard is locked. | ||
| 759 | + * @retval ENOTCONN Disconnected from host. | ||
| 745 | * | 760 | * |
| 746 | */ | 761 | */ |
| 747 | LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str, int length); | 762 | LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str, int length); |
| @@ -754,7 +769,11 @@ | @@ -754,7 +769,11 @@ | ||
| 754 | * @param hSession TN3270 session. | 769 | * @param hSession TN3270 session. |
| 755 | * @param baddr New cursor position. | 770 | * @param baddr New cursor position. |
| 756 | * | 771 | * |
| 757 | - * @return Old cursor address or -1 in case of error (sets errno). | 772 | + * @return Old cursor address or negative in case of error (sets errno). |
| 773 | + * | ||
| 774 | + * @retval -EOVERFLOW The address is beyond the screen length. | ||
| 775 | + * @retval -ENOTCONN Disconnected from host. | ||
| 776 | + * | ||
| 758 | */ | 777 | */ |
| 759 | LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int baddr); | 778 | LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int baddr); |
| 760 | 779 | ||
| @@ -765,8 +784,10 @@ | @@ -765,8 +784,10 @@ | ||
| 765 | * @param row New cursor row. | 784 | * @param row New cursor row. |
| 766 | * @param col New cursor col. | 785 | * @param col New cursor col. |
| 767 | * | 786 | * |
| 768 | - * @return last cursor address or -1 if invalid (sets errno). | 787 | + * @return Old cursor address or negative in case of error (sets errno). |
| 769 | * | 788 | * |
| 789 | + * @retval -EOVERFLOW The address is beyond the screen length. | ||
| 790 | + * @retval -ENOTCONN Disconnected from host. | ||
| 770 | */ | 791 | */ |
| 771 | LIB3270_EXPORT int lib3270_set_cursor_position(H3270 *h, unsigned int row, unsigned int col); | 792 | LIB3270_EXPORT int lib3270_set_cursor_position(H3270 *h, unsigned int row, unsigned int col); |
| 772 | 793 |
src/include/statusc.h
| 1 | /* | 1 | /* |
| 2 | - * Copyright 1999, 2000, 2002 by Paul Mattes. | ||
| 3 | - * Permission to use, copy, modify, and distribute this software and its | ||
| 4 | - * documentation for any purpose and without fee is hereby granted, | ||
| 5 | - * provided that the above copyright notice appear in all copies and that | ||
| 6 | - * both that copyright notice and this permission notice appear in | ||
| 7 | - * supporting documentation. | ||
| 8 | - * | ||
| 9 | - * c3270 is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| 10 | - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 11 | - * FOR A PARTICULAR PURPOSE. See the file LICENSE for more details. | 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 |
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como host.c e possui 1078 linhas de código. | ||
| 22 | + * | ||
| 23 | + * Contatos: | ||
| 24 | + * | ||
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
| 27 | + * | ||
| 12 | */ | 28 | */ |
| 13 | 29 | ||
| 14 | -/* c3270 verson of statusc.h */ | ||
| 15 | - | ||
| 16 | -// #include "api.h" | ||
| 17 | - | ||
| 18 | LIB3270_INTERNAL void status_compose(int on, unsigned char c, enum keytype keytype); | 30 | LIB3270_INTERNAL void status_compose(int on, unsigned char c, enum keytype keytype); |
| 19 | LIB3270_INTERNAL void status_ctlr_done(H3270 *session); | 31 | LIB3270_INTERNAL void status_ctlr_done(H3270 *session); |
| 20 | 32 |
src/selection/get.c
| @@ -182,7 +182,6 @@ LIB3270_EXPORT lib3270_selection * lib3270_get_selection(H3270 *hSession, int cu | @@ -182,7 +182,6 @@ LIB3270_EXPORT lib3270_selection * lib3270_get_selection(H3270 *hSession, int cu | ||
| 182 | 182 | ||
| 183 | if(baddr < 0) | 183 | if(baddr < 0) |
| 184 | { | 184 | { |
| 185 | - errno = EINVAL; | ||
| 186 | lib3270_free(selection); | 185 | lib3270_free(selection); |
| 187 | return NULL; | 186 | return NULL; |
| 188 | } | 187 | } |