1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "tpl.h"
4
main()5 int main() {
6 tpl_node *tn;
7 int i,rc,j;
8 char toosmall[10];
9 char buf[60];
10
11 tn = tpl_map("A(i)",&i);
12 for(i=0;i<10;i++) tpl_pack(tn,1);
13 rc=tpl_dump(tn,TPL_MEM|TPL_PREALLOCD,toosmall,sizeof(toosmall));
14 printf("testing undersized output buffer... %d \n", rc);
15 rc=tpl_dump(tn,TPL_MEM|TPL_PREALLOCD,buf,sizeof(buf));
16 printf("testing sufficient output buffer... %d \n", rc);
17 tpl_free(tn);
18
19 tn = tpl_map("A(i)",&j);
20 tpl_load(tn,TPL_MEM|TPL_EXCESS_OK,buf,sizeof(buf));
21 while (tpl_unpack(tn,1) > 0) printf("j is %d\n", j);
22 tpl_free(tn);
23 return(0);
24 }
25