1 #include "tpl.h"
2 #include <stdlib.h>
3 #include <stdio.h>
4 
main(int argc,char * argv[])5 int main(int argc, char*argv[]) {
6     tpl_bin bin;
7     tpl_node *tn;
8     int i;
9     char *file = "/tmp/test31.tpl";
10 
11     bin.addr = NULL;
12     bin.sz = 0;
13 
14     tn = tpl_map("B", &bin);
15     tpl_pack(tn,0);
16     tpl_dump(tn,TPL_FILE,file);
17     tpl_free(tn);
18 
19     /* load these two fields with bogus values to test that tpl_unpack
20      * sets them back to NULL, and 0 respectively.  */
21     bin.addr = file;
22     bin.sz = 4;
23 
24     tn = tpl_map("B", &bin);
25     tpl_load(tn,TPL_FILE,file);
26     tpl_unpack(tn,0);
27     tpl_free(tn);
28 
29     /* print the buffer char-by-char ; its not a nul-termd string */
30     printf("buffer length: %u\n", bin.sz);
31     for(i=0; i < bin.sz; i++) printf("%c", ((char*)bin.addr)[i]);
32     printf("\n");
33 
34     if (bin.sz > 0)
35         free(bin.addr);  /* malloc'd for us by tpl_unpack, we must free */
36     return(0);
37 }
38 
39