1 #include <stdio.h>
2 #include <string.h>
3 #include "tpl.h"
4 #define LEN 10
5
6 const char *filename = "/tmp/test124.tpl";
7
8 typedef struct {
9 char name[LEN];
10 } test_t;
main()11 int main() {
12 test_t t;
13 char *s;
14 tpl_node *tn;
15
16 tn = tpl_map("A(S(c#)s)", &t, LEN, &s);
17 printf("mapped\n");
18
19 memcpy(t.name,"abcdefghi\0",10);
20 s="first";
21 tpl_pack(tn,1);
22
23 memcpy(t.name,"jklmnopqr\0",10);
24 s="second";
25 tpl_pack(tn,1);
26
27 tpl_dump(tn,TPL_FILE,filename);
28 tpl_free(tn);
29 printf("freed\n");
30
31 tn = tpl_map("A(S(c#)s)", &t, LEN, &s);
32 tpl_load(tn,TPL_FILE,filename);
33 while(tpl_unpack(tn,1) > 0) {
34 printf("%s %s\n", t.name, s);
35 }
36 tpl_free(tn);
37 return 0;
38 }
39