2016-03-27 22:15:45 +02:00
|
|
|
#include "mbag.h"
|
|
|
|
|
|
|
|
static int to_str(void *item,char *dst)
|
|
|
|
{
|
|
|
|
mbag_item_t *i= item;
|
2018-03-03 17:42:28 +01:00
|
|
|
return sprintf(dst, "%s", (char*)i->u2.data);
|
2016-03-27 22:15:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct mbag_item * from_str(const char *src)
|
|
|
|
{
|
|
|
|
struct mbag_item *i= malloc(sizeof(mbag_item_t));
|
|
|
|
if (!i)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
i->type = MBAG_STR;
|
|
|
|
i->dynid=0;
|
2018-03-03 17:42:28 +01:00
|
|
|
i->u2.data = strndup(src,2000);
|
2016-03-27 22:15:45 +02:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const struct mbag_typedef mbag_type_str = {
|
|
|
|
"Sstr",free,to_str,from_str
|
|
|
|
};
|
|
|
|
|
|
|
|
|