map.c

changeset 51
2d95d77aa954
parent 49
755bdb97a607
child 53
f8f9366b359c
equal deleted inserted replaced
50:855953c2f413 51:2d95d77aa954
13 { 13 {
14 int i; 14 int i;
15 15
16 for(i=0; map[i].string!=NULL; i++){ 16 for(i=0; map[i].string!=NULL; i++){
17 if(strcmp(str, map[i].string)==0) 17 if(strcmp(str, map[i].string)==0)
18 return map[i].value; 18 return i;
19 } 19 }
20 20
21 return -1; 21 return -1;
22 } 22 }
23 23
24
25 int stringintmap_value(const StringIntMap *map, const char *str, int dflt)
26 {
27 int i=stringintmap_ndx(map, str);
28 return (i==-1 ? dflt : map[i].value);
29 }
30

mercurial