# HG changeset patch # User tuomov # Date 1087730570 -7200 # Node ID 725a7187c6ff582d6ff9867f9e92b5e6f5cc3733 # Parent 60cb620a034138bbe58c2d9fd7008640ad62fea4 trunk: changeset 1583 Added stringintmap_key (taken from the Ion dock module/stringintmap_reverse_value). diff -r 60cb620a0341 -r 725a7187c6ff map.c --- a/map.c Sat Jun 19 00:13:45 2004 +0200 +++ b/map.c Sun Jun 20 13:22:50 2004 +0200 @@ -30,3 +30,18 @@ return (i==-1 ? dflt : map[i].value); } + +const char *stringintmap_reverse_value(const StringIntMap *map, int value, + const char *dflt) +{ + int i; + + for(i=0; map[i].string!=NULL; ++i){ + if(map[i].value==value){ + return map[i].string; + } + } + + return dflt; + +} diff -r 60cb620a0341 -r 725a7187c6ff map.h --- a/map.h Sat Jun 19 00:13:45 2004 +0200 +++ b/map.h Sun Jun 20 13:22:50 2004 +0200 @@ -21,5 +21,7 @@ extern int stringintmap_ndx(const StringIntMap *map, const char *str); extern int stringintmap_value(const StringIntMap *map, const char *str, int dflt); +extern const char *stringintmap_key(const StringIntMap *map, + int value, const char *dflt); #endif /* LIBTU_MAP_H */