Commit 29b5a3c1aaad92e7a87c85f88d6adebd33acea04
1 parent
235217f1
Exists in
master
and in
3 other branches
Using only alfanumeric chars to translate toggle names.
Showing
2 changed files
with
22 additions
and
1 deletions
Show diff stats
src/core/toggles/table.c
| @@ -37,6 +37,7 @@ | @@ -37,6 +37,7 @@ | ||
| 37 | #include <internals.h> | 37 | #include <internals.h> |
| 38 | #include <lib3270/toggle.h> | 38 | #include <lib3270/toggle.h> |
| 39 | #include "togglesc.h" | 39 | #include "togglesc.h" |
| 40 | +#include "utilc.h" | ||
| 40 | 41 | ||
| 41 | /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ | 42 | /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ |
| 42 | 43 | ||
| @@ -367,6 +368,20 @@ LIB3270_EXPORT const char * lib3270_get_toggle_name(LIB3270_TOGGLE_ID ix) | @@ -367,6 +368,20 @@ LIB3270_EXPORT const char * lib3270_get_toggle_name(LIB3270_TOGGLE_ID ix) | ||
| 367 | return ""; | 368 | return ""; |
| 368 | } | 369 | } |
| 369 | 370 | ||
| 371 | +LIB3270_EXPORT const LIB3270_TOGGLE * lib3270_toggle_get_by_name(const char *name) | ||
| 372 | +{ | ||
| 373 | + if(name) | ||
| 374 | + { | ||
| 375 | + int ix; | ||
| 376 | + for(ix=0;ix<LIB3270_TOGGLE_COUNT;ix++) | ||
| 377 | + { | ||
| 378 | + if(!lib3270_compare_alnum(name,toggle_descriptor[ix].name)) | ||
| 379 | + return &toggle_descriptor[ix]; | ||
| 380 | + } | ||
| 381 | + } | ||
| 382 | + return NULL; | ||
| 383 | +} | ||
| 384 | + | ||
| 370 | LIB3270_EXPORT LIB3270_TOGGLE_ID lib3270_get_toggle_id(const char *name) | 385 | LIB3270_EXPORT LIB3270_TOGGLE_ID lib3270_get_toggle_id(const char *name) |
| 371 | { | 386 | { |
| 372 | if(name) | 387 | if(name) |
| @@ -374,7 +389,7 @@ LIB3270_EXPORT LIB3270_TOGGLE_ID lib3270_get_toggle_id(const char *name) | @@ -374,7 +389,7 @@ LIB3270_EXPORT LIB3270_TOGGLE_ID lib3270_get_toggle_id(const char *name) | ||
| 374 | int f; | 389 | int f; |
| 375 | for(f=0;f<LIB3270_TOGGLE_COUNT;f++) | 390 | for(f=0;f<LIB3270_TOGGLE_COUNT;f++) |
| 376 | { | 391 | { |
| 377 | - if(!strcasecmp(name,toggle_descriptor[f].name)) | 392 | + if(!lib3270_compare_alnum(name,toggle_descriptor[f].name)) |
| 378 | return f; | 393 | return f; |
| 379 | } | 394 | } |
| 380 | } | 395 | } |
src/include/lib3270/toggle.h
| @@ -102,6 +102,12 @@ | @@ -102,6 +102,12 @@ | ||
| 102 | } LIB3270_TOGGLE; | 102 | } LIB3270_TOGGLE; |
| 103 | 103 | ||
| 104 | /** | 104 | /** |
| 105 | + * @brief Get the toggle by name. | ||
| 106 | + * | ||
| 107 | + */ | ||
| 108 | + LIB3270_EXPORT const LIB3270_TOGGLE * lib3270_toggle_get_by_name(const char *name); | ||
| 109 | + | ||
| 110 | + /** | ||
| 105 | * @brief Get the toggle descriptors. | 111 | * @brief Get the toggle descriptors. |
| 106 | * | 112 | * |
| 107 | * @return Pointer to all available toggles. | 113 | * @return Pointer to all available toggles. |