[util] Add name_func_rlookup()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-23 16:53:37 +02:00
parent 8bba0ba76a
commit ff8603110a
2 changed files with 24 additions and 4 deletions

View File

@ -78,10 +78,10 @@ compute_new_value_from_arg(const char *arg, double current_value)
}
/** Lookup for a function pointer from its name
* in the given name_func_link_t list
* \param funcname Function name
* \param list Function and name link list
* \return function pointer
* in the given name_func_link_t list.
* \param funcname Function name.
* \param list Function and name link list.
* \return Function pointer.
*/
void *
name_func_lookup(const char *funcname, const name_func_link_t *list)
@ -96,6 +96,25 @@ name_func_lookup(const char *funcname, const name_func_link_t *list)
return NULL;
}
/** Lookup for a function name from its pointer
* in the given name_func_link_t list.
* \param funcp Function pointer.
* \param list Function and name link list.
* \return Name of the function.
*/
const char *
name_func_rlookup(void * funcp, const name_func_link_t *list)
{
int i;
if(funcp && list)
for(i = 0; list[i].name; i++)
if(funcp == list[i].func)
return list[i].name;
return NULL;
}
position_t
position_get_from_str(const char *pos)
{

View File

@ -284,6 +284,7 @@ char * position_to_str(position_t);
fuzzy_t fuzzy_get_from_str(const char *);
double compute_new_value_from_arg(const char *, double);
void *name_func_lookup(const char *, const name_func_link_t *);
const char * name_func_rlookup(void *, const name_func_link_t *);
void a_exec(const char *);
#endif