1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "tpl.h"
4 #include <errno.h>
5 #include <string.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 
main()10 int main() {
11     tpl_node *tn;
12     unsigned i;
13     char *file = "test24.tpl";
14     int fd;
15 
16     if ( (fd=open( file,O_RDONLY)) == -1) {
17         printf("failed to open %s: %s", file, strerror(errno));
18         exit(-1);
19     }
20 
21     tn = tpl_map("A(u)",&i);
22     tpl_load(tn, TPL_FD, fd);
23     while (tpl_unpack(tn,1) > 0) printf("i is %d\n", i);
24     tpl_free(tn);
25     return(0);
26 }
27