actube/src/cw/mbag_type_str.c
7u83@mail.ru d2d1be3346 changes for actubent - not compiling!
FossilOrigin-Name: adf99bdc2ee784a4acf4066b90c33fb1e6124e8c49c255d3fd5011bb33852d52
2018-03-03 16:42:28 +00:00

27 lines
432 B
C

#include "mbag.h"
static int to_str(void *item,char *dst)
{
mbag_item_t *i= item;
return sprintf(dst, "%s", (char*)i->u2.data);
}
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;
i->u2.data = strndup(src,2000);
return i;
}
const struct mbag_typedef mbag_type_str = {
"Sstr",free,to_str,from_str
};