Commit 5f3b9cfb4afff5bf555bb4ec43808e664bdc6480
1 parent
5d3c21b8
Exists in
master
and in
3 other branches
Adding method to get the toggle descriptor from id.
Showing
2 changed files
with
19 additions
and
1 deletions
Show diff stats
src/core/toggles/table.c
| @@ -380,3 +380,10 @@ LIB3270_EXPORT LIB3270_TOGGLE_ID lib3270_get_toggle_id(const char *name) | @@ -380,3 +380,10 @@ LIB3270_EXPORT LIB3270_TOGGLE_ID lib3270_get_toggle_id(const char *name) | ||
| 380 | } | 380 | } |
| 381 | return -1; | 381 | return -1; |
| 382 | } | 382 | } |
| 383 | + | ||
| 384 | +LIB3270_EXPORT const LIB3270_TOGGLE * lib3270_toggle_get_from_id(LIB3270_TOGGLE_ID id) | ||
| 385 | +{ | ||
| 386 | + if(id < LIB3270_TOGGLE_COUNT) | ||
| 387 | + return &toggle_descriptor[id]; | ||
| 388 | + return NULL; | ||
| 389 | +} |
src/include/lib3270/toggle.h
| @@ -188,7 +188,7 @@ | @@ -188,7 +188,7 @@ | ||
| 188 | * @param hSession Session handle. | 188 | * @param hSession Session handle. |
| 189 | * @param ix Toggle id. | 189 | * @param ix Toggle id. |
| 190 | * | 190 | * |
| 191 | - * @returns 0 if the toggle is already at the state, 1 if the toggle was changed; < 0 on error (sets errno). | 191 | + * @return 0 if the toggle is already at the state, 1 if the toggle was changed; < 0 on error (sets errno). |
| 192 | * | 192 | * |
| 193 | * @retval -EINVAL Invalid toggle id. | 193 | * @retval -EINVAL Invalid toggle id. |
| 194 | */ | 194 | */ |
| @@ -197,6 +197,17 @@ | @@ -197,6 +197,17 @@ | ||
| 197 | LIB3270_EXPORT const void * lib3270_register_toggle_listener(H3270 *hSession, LIB3270_TOGGLE_ID tx, void (*func)(H3270 *, LIB3270_TOGGLE_ID, char, void *),void *data); | 197 | LIB3270_EXPORT const void * lib3270_register_toggle_listener(H3270 *hSession, LIB3270_TOGGLE_ID tx, void (*func)(H3270 *, LIB3270_TOGGLE_ID, char, void *),void *data); |
| 198 | LIB3270_EXPORT int lib3270_unregister_toggle_listener(H3270 *hSession, LIB3270_TOGGLE_ID tx, const void *id); | 198 | LIB3270_EXPORT int lib3270_unregister_toggle_listener(H3270 *hSession, LIB3270_TOGGLE_ID tx, const void *id); |
| 199 | 199 | ||
| 200 | + | ||
| 201 | + /** | ||
| 202 | + * @brief Get toggle descriptor from ID. | ||
| 203 | + * | ||
| 204 | + * @param id Toggle.id. | ||
| 205 | + * | ||
| 206 | + * @return The toggle descriptor or NULL if the ID is invalid. | ||
| 207 | + * | ||
| 208 | + */ | ||
| 209 | + LIB3270_EXPORT const LIB3270_TOGGLE * lib3270_toggle_get_from_id(LIB3270_TOGGLE_ID id); | ||
| 210 | + | ||
| 200 | #ifdef __cplusplus | 211 | #ifdef __cplusplus |
| 201 | } | 212 | } |
| 202 | #endif | 213 | #endif |