trunk: changeset 1583

Sun, 20 Jun 2004 13:22:50 +0200

author
tuomov
date
Sun, 20 Jun 2004 13:22:50 +0200
changeset 75
725a7187c6ff
parent 74
60cb620a0341
child 76
58280b944cda

trunk: changeset 1583
Added stringintmap_key (taken from the Ion dock
module/stringintmap_reverse_value).

map.c file | annotate | diff | comparison | revisions
map.h file | annotate | diff | comparison | revisions
--- 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;
+    
+}
--- 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 */

mercurial