blob: bb2ef4cd55a3bf7ebca9aada6747eab52e5a7269 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include <stdint.h>
#include <string.h>
#include "rt_string.h"
const char *
try_val_to_str_idx(const unsigned int val, const struct value_string *vs, int *idx)
{
int i = 0;
if (idx == NULL){
goto finish;
}
if(vs) {
while (vs[i].strptr) {
if (vs[i].value == val) {
*idx = i;
return(vs[i].strptr);
}
i++;
}
}
finish:
*idx = -1;
return NULL;
}
const char*
val_to_str(const unsigned int val, const struct value_string *vs)
{
int ignore_me;
return try_val_to_str_idx(val, vs, &ignore_me);
}
|