Commit 538f302a570f923eb215a1bb736c2efcf3ff410c
1 parent
7b519ee8
Exists in
master
and in
3 other branches
Working on new API.
Showing
2 changed files
with
72 additions
and
60 deletions
Show diff stats
src/include/lib3270.h
... | ... | @@ -67,7 +67,7 @@ |
67 | 67 | #define LIB3270_BIND_PLU_NAME_MAX 8 |
68 | 68 | |
69 | 69 | /** |
70 | - * Maximum size for LUNAME | |
70 | + * @brief Maximum size for LUNAME | |
71 | 71 | * |
72 | 72 | */ |
73 | 73 | #define LIB3270_LUNAME_LENGTH 16 |
... | ... | @@ -171,17 +171,17 @@ |
171 | 171 | |
172 | 172 | |
173 | 173 | /** |
174 | - * OIA Status indicators. | |
174 | + * @brief OIA Status indicators. | |
175 | 175 | * |
176 | 176 | */ |
177 | 177 | typedef enum _lib3270_flag |
178 | 178 | { |
179 | - LIB3270_FLAG_BOXSOLID, /**< System available */ | |
180 | - LIB3270_FLAG_UNDERA, /**< Control Unit STATUS */ | |
179 | + LIB3270_FLAG_BOXSOLID, /**< @brief System available */ | |
180 | + LIB3270_FLAG_UNDERA, /**< @brief Control Unit STATUS */ | |
181 | 181 | LIB3270_FLAG_TYPEAHEAD, |
182 | - LIB3270_FLAG_PRINTER, /**< Printer session status */ | |
182 | + LIB3270_FLAG_PRINTER, /**< @brief Printer session status */ | |
183 | 183 | LIB3270_FLAG_REVERSE, |
184 | - LIB3270_FLAG_SCRIPT, /**< Script status */ | |
184 | + LIB3270_FLAG_SCRIPT, /**< @brief Script status */ | |
185 | 185 | |
186 | 186 | LIB3270_FLAG_COUNT |
187 | 187 | |
... | ... | @@ -217,7 +217,7 @@ |
217 | 217 | |
218 | 218 | |
219 | 219 | /** |
220 | - * Pointer modes. | |
220 | + * @brief Pointer modes. | |
221 | 221 | * |
222 | 222 | * Pointer modes set by library; an application can use it |
223 | 223 | * as a hint to change the mouse pointer based on connection status. |
... | ... | @@ -225,9 +225,9 @@ |
225 | 225 | */ |
226 | 226 | typedef enum _LIB3270_POINTER |
227 | 227 | { |
228 | - LIB3270_POINTER_UNLOCKED, /**< Ready for user actions */ | |
229 | - LIB3270_POINTER_WAITING, /**< Waiting for host */ | |
230 | - LIB3270_POINTER_LOCKED, /**< Locked, can't receive user actions */ | |
228 | + LIB3270_POINTER_UNLOCKED, /**< @brief Ready for user actions */ | |
229 | + LIB3270_POINTER_WAITING, /**< @brief Waiting for host */ | |
230 | + LIB3270_POINTER_LOCKED, /**< @brief Locked, can't receive user actions */ | |
231 | 231 | |
232 | 232 | LIB3270_POINTER_PROTECTED, |
233 | 233 | LIB3270_POINTER_MOVE_SELECTION, |
... | ... | @@ -247,20 +247,20 @@ |
247 | 247 | |
248 | 248 | |
249 | 249 | /** |
250 | - * connection state | |
250 | + * @brief Connection state | |
251 | 251 | */ |
252 | 252 | typedef enum lib3270_cstate |
253 | 253 | { |
254 | - LIB3270_NOT_CONNECTED, /**< no socket, disconnected */ | |
255 | - LIB3270_RESOLVING, /**< resolving hostname */ | |
256 | - LIB3270_PENDING, /**< connection pending */ | |
257 | - LIB3270_CONNECTED_INITIAL, /**< connected, no mode yet */ | |
258 | - LIB3270_CONNECTED_ANSI, /**< connected in NVT ANSI mode */ | |
259 | - LIB3270_CONNECTED_3270, /**< connected in old-style 3270 mode */ | |
260 | - LIB3270_CONNECTED_INITIAL_E, /**< connected in TN3270E mode, unnegotiated */ | |
261 | - LIB3270_CONNECTED_NVT, /**< connected in TN3270E mode, NVT mode */ | |
262 | - LIB3270_CONNECTED_SSCP, /**< connected in TN3270E mode, SSCP-LU mode */ | |
263 | - LIB3270_CONNECTED_TN3270E /**< connected in TN3270E mode, 3270 mode */ | |
254 | + LIB3270_NOT_CONNECTED, /**< @brief no socket, disconnected */ | |
255 | + LIB3270_RESOLVING, /**< @brief resolving hostname */ | |
256 | + LIB3270_PENDING, /**< @brief connection pending */ | |
257 | + LIB3270_CONNECTED_INITIAL, /**< @brief connected, no mode yet */ | |
258 | + LIB3270_CONNECTED_ANSI, /**< @brief connected in NVT ANSI mode */ | |
259 | + LIB3270_CONNECTED_3270, /**< @brief connected in old-style 3270 mode */ | |
260 | + LIB3270_CONNECTED_INITIAL_E, /**< @brief connected in TN3270E mode, unnegotiated */ | |
261 | + LIB3270_CONNECTED_NVT, /**< @brief connected in TN3270E mode, NVT mode */ | |
262 | + LIB3270_CONNECTED_SSCP, /**< @brief connected in TN3270E mode, SSCP-LU mode */ | |
263 | + LIB3270_CONNECTED_TN3270E /**< @brief connected in TN3270E mode, 3270 mode */ | |
264 | 264 | } LIB3270_CSTATE; |
265 | 265 | |
266 | 266 | |
... | ... | @@ -585,15 +585,16 @@ |
585 | 585 | LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *str); |
586 | 586 | |
587 | 587 | /** |
588 | - * Set cursor address. | |
588 | + * @brief Move cursor to a new position. | |
589 | 589 | * |
590 | - * @param h Session handle. | |
591 | - * @param baddr New cursor address. | |
590 | + * @see lib3270_set_cursor_position | |
592 | 591 | * |
593 | - * @return or -1 if invalid (sets errno). | |
592 | + * @param hSession TN3270 session. | |
593 | + * @param baddr New cursor position. | |
594 | 594 | * |
595 | + * @return Old cursor address or -1 in case of error (sets errno). | |
595 | 596 | */ |
596 | - LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr); | |
597 | + LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, int baddr); | |
597 | 598 | |
598 | 599 | /** |
599 | 600 | * Set cursor position. |
... | ... | @@ -602,7 +603,7 @@ |
602 | 603 | * @param row New cursor row. |
603 | 604 | * @param col New cursor col. |
604 | 605 | * |
605 | - * @return last cursor address or -1 if invalid (sets errno).. | |
606 | + * @return last cursor address or -1 if invalid (sets errno). | |
606 | 607 | * |
607 | 608 | */ |
608 | 609 | LIB3270_EXPORT int lib3270_set_cursor_position(H3270 *h, int row, int col); |
... | ... | @@ -610,12 +611,12 @@ |
610 | 611 | /** |
611 | 612 | * get cursor address. |
612 | 613 | * |
613 | - * @param h Session handle. | |
614 | + * @param hSession Session handle. | |
614 | 615 | * |
615 | - * @return Cursor address. | |
616 | + * @return Cursor address or -1 if invalid (sets errno). | |
616 | 617 | * |
617 | 618 | */ |
618 | - LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h); | |
619 | + LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *hSession); | |
619 | 620 | |
620 | 621 | |
621 | 622 | /** |
... | ... | @@ -737,7 +738,8 @@ |
737 | 738 | LIB3270_EXPORT void lib3270_remove_poll_fd(H3270 *session, int fd); |
738 | 739 | LIB3270_EXPORT void lib3270_update_poll_fd(H3270 *session, int fd, LIB3270_IO_FLAG flag); |
739 | 740 | |
740 | - /** Callback table | |
741 | + /** | |
742 | + * @brief Callback table | |
741 | 743 | * |
742 | 744 | * Structure with GUI unblocking I/O calls, used to replace the lib3270´s internal ones. |
743 | 745 | * |
... | ... | @@ -827,21 +829,6 @@ |
827 | 829 | LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_secure(H3270 *session); |
828 | 830 | LIB3270_EXPORT long lib3270_get_SSL_verify_result(H3270 *session); |
829 | 831 | |
830 | - | |
831 | - /** | |
832 | - * Call non gui function. | |
833 | - * | |
834 | - * Call informed function in a separate thread, keep gui main loop running until | |
835 | - * the function returns. | |
836 | - * | |
837 | - * @param callback Function to call. | |
838 | - * @param h Related session (for timer indicator) | |
839 | - * @param parm Parameter to be passed to the function. | |
840 | - * | |
841 | - */ | |
842 | -// LIB3270_EXPORT int lib3270_call_thread(int(*callback)(H3270 *h, void *), H3270 *h, void *parm); | |
843 | - | |
844 | - | |
845 | 832 | /** |
846 | 833 | * Run main iteration. |
847 | 834 | * |
... | ... | @@ -923,7 +910,7 @@ |
923 | 910 | LIB3270_EXPORT int lib3270_has_selection(H3270 *hSession); |
924 | 911 | |
925 | 912 | /** |
926 | - * Get all text inside the terminal. | |
913 | + * @brief Get all text inside the terminal. | |
927 | 914 | * |
928 | 915 | * @param h Session Handle. |
929 | 916 | * @param offset Start position. |
... | ... | @@ -936,7 +923,7 @@ |
936 | 923 | LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len, char lf); |
937 | 924 | |
938 | 925 | /** |
939 | - * Get text at requested position | |
926 | + * @brief Get text at requested position | |
940 | 927 | * |
941 | 928 | * @param h Session Handle. |
942 | 929 | * @param row Desired row. |
... | ... | @@ -950,7 +937,7 @@ |
950 | 937 | LIB3270_EXPORT char * lib3270_get_text_at(H3270 *h, int row, int col, int len, char lf); |
951 | 938 | |
952 | 939 | /** |
953 | - * Check for text at requested position | |
940 | + * @brief Check for text at requested position | |
954 | 941 | * |
955 | 942 | * @param h Session Handle. |
956 | 943 | * @param row Desired row. |
... | ... | @@ -965,7 +952,7 @@ |
965 | 952 | |
966 | 953 | |
967 | 954 | /** |
968 | - * Get contents of the field at position. | |
955 | + * @brief Get contents of the field at position. | |
969 | 956 | * |
970 | 957 | * @param h Session Handle. |
971 | 958 | * @param baddr Reference position. |
... | ... | @@ -976,7 +963,7 @@ |
976 | 963 | LIB3270_EXPORT char * lib3270_get_field_at(H3270 *h, int baddr); |
977 | 964 | |
978 | 965 | /** |
979 | - * Find the next unprotected field. | |
966 | + * @brief Find the next unprotected field. | |
980 | 967 | * |
981 | 968 | * @param hSession Session handle. |
982 | 969 | * @param baddr0 Search start addr (-1 to use current cursor position). |
... | ... | @@ -993,7 +980,7 @@ |
993 | 980 | LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr0); |
994 | 981 | |
995 | 982 | /** |
996 | - * Get Check if the screen position is protected. | |
983 | + * @brief Get Check if the screen position is protected. | |
997 | 984 | * |
998 | 985 | * @param h Session Handle. |
999 | 986 | * @param row Desired row. |
... | ... | @@ -1003,7 +990,7 @@ |
1003 | 990 | LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, int row, int col); |
1004 | 991 | |
1005 | 992 | /** |
1006 | - * Get address of the first blank. | |
993 | + * @brief Get address of the first blank. | |
1007 | 994 | * |
1008 | 995 | * Get address of the first blank after the last nonblank in the |
1009 | 996 | * field, or if the field is full, to the last character in the field. |
... | ... | @@ -1016,7 +1003,7 @@ |
1016 | 1003 | LIB3270_EXPORT int lib3270_get_field_end(H3270 *hSession, int baddr); |
1017 | 1004 | |
1018 | 1005 | /** |
1019 | - * Find the buffer address of the field attribute for a given buffer address. | |
1006 | + * @brief Find the buffer address of the field attribute for a given buffer address. | |
1020 | 1007 | * |
1021 | 1008 | * @param h Session handle. |
1022 | 1009 | * @param addr Buffer address of the field. |
... | ... | @@ -1029,7 +1016,7 @@ |
1029 | 1016 | LIB3270_EXPORT int lib3270_field_attribute(H3270 *hSession, int baddr); |
1030 | 1017 | |
1031 | 1018 | /** |
1032 | - * Get the length of the field at given buffer address. | |
1019 | + * @brief Get the length of the field at given buffer address. | |
1033 | 1020 | * |
1034 | 1021 | * @param h Session handle. |
1035 | 1022 | * @param addr Buffer address of the field. |
... | ... | @@ -1041,7 +1028,7 @@ |
1041 | 1028 | |
1042 | 1029 | |
1043 | 1030 | /** |
1044 | - * Get a terminal character and attribute. | |
1031 | + * @brief Get a terminal character and attribute. | |
1045 | 1032 | * |
1046 | 1033 | * @param h Session Handle. |
1047 | 1034 | * @param baddr Element address ((element_row*cols)+element_col) |
... | ... | @@ -1083,6 +1070,8 @@ |
1083 | 1070 | |
1084 | 1071 | /** |
1085 | 1072 | * |
1073 | + * @brief Overrides the default value for the unlock delay. | |
1074 | + * | |
1086 | 1075 | * Overrides the default value for the unlock delay (the delay between the host unlocking the |
1087 | 1076 | * keyboard and lib3270 actually performing the unlock). |
1088 | 1077 | * The value is in milliseconds; use 0 to turn off the delay completely. |
... | ... | @@ -1095,7 +1084,7 @@ |
1095 | 1084 | |
1096 | 1085 | |
1097 | 1086 | /** |
1098 | - * Alloc/Realloc memory buffer. | |
1087 | + * @brief Alloc/Realloc memory buffer. | |
1099 | 1088 | * |
1100 | 1089 | * Allocate/reallocate an array. |
1101 | 1090 | * |
... | ... | @@ -1114,7 +1103,7 @@ |
1114 | 1103 | LIB3270_EXPORT void * lib3270_strdup(const char *str); |
1115 | 1104 | |
1116 | 1105 | /** |
1117 | - * Release allocated memory. | |
1106 | + * @brief Release allocated memory. | |
1118 | 1107 | * |
1119 | 1108 | * @param p Memory block to release (can be NULL) |
1120 | 1109 | * | ... | ... |
src/lib3270++/local/session.cc
... | ... | @@ -233,12 +233,35 @@ |
233 | 233 | } |
234 | 234 | |
235 | 235 | TN3270::Session & Local::Session::pop(int row, int col, std::string &text) { |
236 | - std::lock_guard<std::mutex> lock(sync); | |
237 | - return *this; | |
236 | + return this->pop(lib3270_translate_to_address(hSession,row,col),text); | |
238 | 237 | } |
239 | 238 | |
240 | 239 | TN3270::Session & Local::Session::pop(std::string &text) { |
240 | + | |
241 | 241 | std::lock_guard<std::mutex> lock(sync); |
242 | + | |
243 | + int baddr = lib3270_get_cursor_address(hSession); | |
244 | + if(baddr < 0) { | |
245 | + throw std::system_error(errno, std::system_category()); | |
246 | + } | |
247 | + | |
248 | + char *contents = lib3270_get_field_at(hSession, baddr); | |
249 | + | |
250 | + if(!contents) { | |
251 | + throw std::runtime_error("Can't get field contents"); | |
252 | + } | |
253 | + | |
254 | + text.assign(convertFromHost(contents).c_str()); | |
255 | + | |
256 | + lib3270_free(contents); | |
257 | + | |
258 | + baddr = lib3270_get_next_unprotected(hSession,baddr); | |
259 | + if(!baddr) { | |
260 | + baddr = lib3270_get_next_unprotected(hSession,0); | |
261 | + } | |
262 | + | |
263 | + lib3270_set_cursor_address(hSession,baddr); | |
264 | + | |
242 | 265 | return *this; |
243 | 266 | } |
244 | 267 | ... | ... |