#ifndef STRTAB_H_
#define STRTAB_H_
+#include "htsmsg.h"
+
#include <strings.h>
struct strtab {
#define val2str(val, tab) val2str0(val, tab, sizeof(tab) / sizeof(tab[0]))
+static inline htsmsg_t *
+strtab2htsmsg0(const struct strtab tab[], int n)
+{
+ int i;
+ htsmsg_t *e, *l = htsmsg_create_list();
+ for (i = 0; i < n; i++) {
+ e = htsmsg_create_map();
+ htsmsg_add_s32(e, "key", tab[i].val);
+ htsmsg_add_str(e, "val", tab[i].str);
+ htsmsg_add_msg(l, NULL, e);
+ }
+ return l;
+}
+
+#define strtab2htsmsg(tab) strtab2htsmsg0(tab, sizeof(tab) / sizeof(tab[0]))
+
#endif /* STRTAB_H_ */