#include #include #include #include "tpl.h" #define COUNT 10 #define BUF_SIZE 256 const char *filename = "/tmp/test115.tpl"; typedef struct { char* s; } s1_t; typedef struct { char* s; int i; } s2_t; typedef struct { char c[BUF_SIZE]; char* s; int i; } s3_t; const char hw[]="hello, world!"; int main () { tpl_node* tn; s1_t* s1, *S1; s2_t* s2, *S2; s3_t* s3, *S3; int i; /* case 1: */ s1 = (s1_t*)calloc (sizeof (s1_t), COUNT); for(i=0; i < COUNT; i++) { s1[i].s = malloc(sizeof(hw)); memcpy(s1[i].s, hw, sizeof(hw)); s1[i].s[sizeof(hw)-2]='0'+i; } tn = tpl_map ("S(s)#", s1, COUNT); tpl_pack (tn, 0); tpl_dump (tn, TPL_FILE, filename); tpl_free (tn); for(i=0; i < COUNT; i++) free(s1[i].s); S1 = (s1_t*)calloc (sizeof (s1_t), COUNT); memset(S1, 0xff, sizeof(s1_t)*COUNT); tn = tpl_map ("S(s)#", S1, COUNT); tpl_load (tn, TPL_FILE, filename); tpl_unpack (tn, 0); tpl_free (tn); for(i=0; i