map.c

changeset 62
aae5facf9fc5
parent 53
f8f9366b359c
child 70
e866dc825481
equal deleted inserted replaced
61:fc585645ad05 62:aae5facf9fc5
12 12
13 13
14 int stringintmap_ndx(const StringIntMap *map, const char *str) 14 int stringintmap_ndx(const StringIntMap *map, const char *str)
15 { 15 {
16 int i; 16 int i;
17 17
18 for(i=0; map[i].string!=NULL; i++){ 18 for(i=0; map[i].string!=NULL; i++){
19 if(strcmp(str, map[i].string)==0) 19 if(strcmp(str, map[i].string)==0)
20 return i; 20 return i;
21 } 21 }
22 22
23 return -1; 23 return -1;
24 } 24 }
25 25
26 26
27 int stringintmap_value(const StringIntMap *map, const char *str, int dflt) 27 int stringintmap_value(const StringIntMap *map, const char *str, int dflt)
28 { 28 {
29 int i=stringintmap_ndx(map, str); 29 int i=stringintmap_ndx(map, str);
30 return (i==-1 ? dflt : map[i].value); 30 return (i==-1 ? dflt : map[i].value);
31 } 31 }
32 32

mercurial