f->hmf_s64 = s64;
}
+/*
+ *
+ */
+void
+htsmsg_add_u64(htsmsg_t *msg, const char *name, uint64_t u64)
+{
+ htsmsg_field_t *f = htsmsg_field_add(msg, name, HMF_S64, HMF_NAME_ALLOCED);
+ f->hmf_s64 = u64;
+}
+
/*
*
*/
return 0;
}
+/**
+ *
+ */
+int
+htsmsg_get_u64(htsmsg_t *msg, const char *name, uint64_t *u64p)
+{
+ htsmsg_field_t *f;
+
+ if((f = htsmsg_field_find(msg, name)) == NULL)
+ return HTSMSG_ERR_FIELD_NOT_FOUND;
+
+ switch(f->hmf_type) {
+ default:
+ return HTSMSG_ERR_CONVERSION_IMPOSSIBLE;
+ case HMF_STR:
+ *u64p = strtoull(f->hmf_str, NULL, 0);
+ break;
+ case HMF_S64:
+ *u64p = f->hmf_s64;
+ break;
+ }
+ return 0;
+}
+
/*
*
*/
void htsmsg_add_s32(htsmsg_t *msg, const char *name, int32_t s32);
+/**
+ * Add an integer field where source is unsigned 64 bit.
+ */
+void htsmsg_add_u64(htsmsg_t *msg, const char *name, uint64_t u64);
+
/**
* Add an integer field where source is signed 64 bit.
*/
*/
int htsmsg_get_s64(htsmsg_t *msg, const char *name, int64_t *s64p);
+/**
+ * Get an integer as an unsigned 64 bit integer.
+ *
+ * @return HTSMSG_ERR_FIELD_NOT_FOUND - Field does not exist
+ * HTSMSG_ERR_CONVERSION_IMPOSSIBLE - Field is not an integer or
+ * out of range for the requested storage.
+ */
+int htsmsg_get_u64(htsmsg_t *msg, const char *name, uint64_t *u64p);
+
/**
* Get pointer to a binary field. No copying of data is performed.
*
}
}
- if(y == 1 && c > 1) {
+ if(y == 1 && c > 0) {
/* One segment UTF-8 (or 7bit ASCII),
use data directly from source */
return NULL;
}
+
+/*
+ * Get cdata string field
+ */
+const char *
+htsmsg_xml_get_cdata_str(htsmsg_t *tags, const char *name)
+{
+ htsmsg_t *sub;
+ if((sub = htsmsg_get_map(tags, name)) == NULL)
+ return NULL;
+ return htsmsg_get_str(sub, "cdata");
+}
+
+/*
+ * Get cdata u32 field
+ */
+int
+htsmsg_xml_get_cdata_u32(htsmsg_t *tags, const char *name, uint32_t *u32)
+{
+ htsmsg_t *sub;
+ if((sub = htsmsg_get_map(tags, name)) == NULL)
+ return HTSMSG_ERR_FIELD_NOT_FOUND;
+ return htsmsg_get_u32(sub, "cdata", u32);
+}
+
+
#include "htsbuf.h"
htsmsg_t *htsmsg_xml_deserialize(char *src, char *errbuf, size_t errbufsize);
+const char *htsmsg_xml_get_cdata_str (htsmsg_t *tags, const char *tag);
+int htsmsg_xml_get_cdata_u32 (htsmsg_t *tags, const char *tag, uint32_t *u32);
#endif /* HTSMSG_XML_H_ */