Commit 423b757c15a7ee486b678697f88372fc2b27ddd8
1 parent
24b6830e
Exists in
master
and in
3 other branches
Small adjustments in the toggle API.
Showing
2 changed files
with
21 additions
and
17 deletions
Show diff stats
src/core/toggles/getset.c
| ... | ... | @@ -41,14 +41,15 @@ |
| 41 | 41 | |
| 42 | 42 | /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ |
| 43 | 43 | |
| 44 | -LIB3270_EXPORT unsigned char lib3270_get_toggle(H3270 *session, LIB3270_TOGGLE ix) | |
| 44 | +LIB3270_EXPORT unsigned char lib3270_get_toggle(const H3270 *hSession, LIB3270_TOGGLE ix) | |
| 45 | 45 | { |
| 46 | - CHECK_SESSION_HANDLE(session); | |
| 47 | 46 | |
| 48 | - if(ix < 0 || ix >= LIB3270_TOGGLE_COUNT) | |
| 47 | + if(ix < 0 || ix >= LIB3270_TOGGLE_COUNT) { | |
| 48 | + errno = EINVAL; | |
| 49 | 49 | return 0; |
| 50 | + } | |
| 50 | 51 | |
| 51 | - return session->toggle[ix].value != 0; | |
| 52 | + return hSession->toggle[ix].value != 0; | |
| 52 | 53 | } |
| 53 | 54 | |
| 54 | 55 | /** |
| ... | ... | @@ -107,8 +108,9 @@ LIB3270_EXPORT int lib3270_toggle(H3270 *session, LIB3270_TOGGLE ix) |
| 107 | 108 | |
| 108 | 109 | CHECK_SESSION_HANDLE(session); |
| 109 | 110 | |
| 110 | - if(ix < 0 || ix >= LIB3270_TOGGLE_COUNT) | |
| 111 | - return 0; | |
| 111 | + if(ix < 0 || ix >= LIB3270_TOGGLE_COUNT) { | |
| 112 | + return -(errno = EINVAL); | |
| 113 | + } | |
| 112 | 114 | |
| 113 | 115 | t = &session->toggle[ix]; |
| 114 | 116 | ... | ... |
src/include/lib3270/toggle.h
| ... | ... | @@ -58,27 +58,27 @@ |
| 58 | 58 | /** |
| 59 | 59 | * @brief get toggle state. |
| 60 | 60 | * |
| 61 | - * @param h Session handle. | |
| 62 | - * @param ix Toggle id. | |
| 61 | + * @param hSession Session handle. | |
| 62 | + * @param ix Toggle id. | |
| 63 | 63 | * |
| 64 | 64 | * @return 0 if the toggle is disabled, non zero if enabled. |
| 65 | 65 | * |
| 66 | 66 | */ |
| 67 | - LIB3270_EXPORT unsigned char lib3270_get_toggle(H3270 *h, LIB3270_TOGGLE ix); | |
| 67 | + LIB3270_EXPORT unsigned char lib3270_get_toggle(const H3270 *hSession, LIB3270_TOGGLE ix); | |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @brief Set toggle state. |
| 71 | 71 | * |
| 72 | - * @param h Session handle. | |
| 73 | - * @param ix Toggle id. | |
| 74 | - * @param value New toggle state (non zero for true). | |
| 72 | + * @param hSession Session handle. | |
| 73 | + * @param ix Toggle id. | |
| 74 | + * @param value New toggle state (non zero for true). | |
| 75 | 75 | * |
| 76 | 76 | * @returns 0 if the toggle is already at the state, 1 if the toggle was changed; < 0 on error (sets errno). |
| 77 | 77 | * |
| 78 | 78 | * @retval -EINVAL Invalid toggle id. |
| 79 | 79 | * |
| 80 | 80 | */ |
| 81 | - LIB3270_EXPORT int lib3270_set_toggle(H3270 *h, LIB3270_TOGGLE ix, int value); | |
| 81 | + LIB3270_EXPORT int lib3270_set_toggle(H3270 *hSession, LIB3270_TOGGLE ix, int value); | |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * @brief Translate a string toggle name to the corresponding value. |
| ... | ... | @@ -127,12 +127,14 @@ |
| 127 | 127 | /** |
| 128 | 128 | * @brief Revert toggle status. |
| 129 | 129 | * |
| 130 | - * @param h Session handle. | |
| 131 | - * @param ix Toggle id. | |
| 130 | + * @param hSession Session handle. | |
| 131 | + * @param ix Toggle id. | |
| 132 | 132 | * |
| 133 | - * @return Toggle status. | |
| 133 | + * @returns 0 if the toggle is already at the state, 1 if the toggle was changed; < 0 on error (sets errno). | |
| 134 | + * | |
| 135 | + * @retval -EINVAL Invalid toggle id. | |
| 134 | 136 | */ |
| 135 | - LIB3270_EXPORT int lib3270_toggle(H3270 *h, LIB3270_TOGGLE ix); | |
| 137 | + LIB3270_EXPORT int lib3270_toggle(H3270 *hSession, LIB3270_TOGGLE ix); | |
| 136 | 138 | |
| 137 | 139 | LIB3270_EXPORT const void * lib3270_register_toggle_listener(H3270 *hSession, LIB3270_TOGGLE tx, void (*func)(H3270 *, LIB3270_TOGGLE, char, void *),void *data); |
| 138 | 140 | LIB3270_EXPORT int lib3270_unregister_toggle_listener(H3270 *hSession, LIB3270_TOGGLE tx, const void *id); | ... | ... |