actube/src/cw/mbag_type_str.c
7u83@mail.ru 93d53d3351 separated from mbag.c
FossilOrigin-Name: 6abe9eb7aa44bcfb3314621e6dd437e9cc278ce08fd5cc8683a5c5f8ebaa3377
2016-03-27 20:15:45 +00:00

27 lines
426 B
C

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