Commit 29b5a3c1aaad92e7a87c85f88d6adebd33acea04

Authored by Perry Werneck
1 parent 235217f1

Using only alfanumeric chars to translate toggle names.

src/core/toggles/table.c
... ... @@ -37,6 +37,7 @@
37 37 #include <internals.h>
38 38 #include <lib3270/toggle.h>
39 39 #include "togglesc.h"
  40 +#include "utilc.h"
40 41  
41 42 /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
42 43  
... ... @@ -367,6 +368,20 @@ LIB3270_EXPORT const char * lib3270_get_toggle_name(LIB3270_TOGGLE_ID ix)
367 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 385 LIB3270_EXPORT LIB3270_TOGGLE_ID lib3270_get_toggle_id(const char *name)
371 386 {
372 387 if(name)
... ... @@ -374,7 +389,7 @@ LIB3270_EXPORT LIB3270_TOGGLE_ID lib3270_get_toggle_id(const char *name)
374 389 int f;
375 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 393 return f;
379 394 }
380 395 }
... ...
src/include/lib3270/toggle.h
... ... @@ -102,6 +102,12 @@
102 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 111 * @brief Get the toggle descriptors.
106 112 *
107 113 * @return Pointer to all available toggles.
... ...