summaryrefslogtreecommitdiff
path: root/common/rt/src/rt_string.cpp
diff options
context:
space:
mode:
authorfengweihao <[email protected]>2019-11-05 11:38:40 +0800
committerfengweihao <[email protected]>2019-11-05 11:38:40 +0800
commit7192f437e55c9141d8cc72858295d4c5c6556616 (patch)
tree95dbf9e93da30601c34af4279ac9380251ae3d86 /common/rt/src/rt_string.cpp
parent8b089533e9c75bc6a99917cce71bc3839dd0ab44 (diff)
* 修改编译方式为CMakev2.1.2-20191105
* 删除C++适配代码 * 修改编译告警
Diffstat (limited to 'common/rt/src/rt_string.cpp')
-rw-r--r--common/rt/src/rt_string.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/common/rt/src/rt_string.cpp b/common/rt/src/rt_string.cpp
new file mode 100644
index 0000000..bb2ef4c
--- /dev/null
+++ b/common/rt/src/rt_string.cpp
@@ -0,0 +1,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);
+}
+