1 #include <stdio.h>
2 #include <string.h>
3 #include "tpl.h"
4 
5 #define XDIM 10
6 #define YDIM 2
7 
8 const char *filename = "/tmp/test114.tpl";
9 extern tpl_hook_t tpl_hook;
10 
main()11 int main() {
12   tpl_node *tn;
13   int xy[XDIM][YDIM], XY[XDIM][YDIM];
14   int i,j;
15 
16   tpl_hook.oops = printf;
17 
18   for(i=0; i<XDIM; i++) {
19     for(j=0; j<YDIM; j++) {
20       xy[i][j] = i+j;
21       XY[i][j] = 0;
22     }
23   }
24 
25   tn = tpl_map("i##", xy, XDIM, YDIM);
26   if (!tn) {
27     printf("tpl_map failed; exiting\n");
28     return -1;
29   }
30   tpl_pack(tn,0);
31   tpl_dump(tn,TPL_FILE,filename);
32   tpl_free(tn);
33 
34   tn = tpl_map("i##", XY, XDIM, YDIM);
35   if (!tn) {
36     printf("tpl_map failed; exiting\n");
37     return -1;
38   }
39   tpl_load(tn,TPL_FILE,filename);
40   tpl_unpack(tn,0);
41   tpl_free(tn);
42 
43   printf("matrices %s\n", (!memcmp(xy,XY,sizeof(xy))) ?  "match" : "mismatch");
44   return 0;
45 }
46