tpl/tests/test104.c
2013-03-12 16:38:58 -04:00

34 lines
680 B
C

#include "tpl.h"
#include <stdio.h>
const char *filename = "/tmp/test104.tpl";
int main() {
tpl_node *tn;
struct {
int i;
char *s;
char c;
char *t;
int j;
unsigned u;
} s;
char *fmt, *ps, pc, *pt;
int pi, pj;
tn = tpl_map("S(iscsiu)", &s);
s.i = 1; s.s = NULL; s.c = '^'; s.t = "world"; s.j = 2; s.u = 3;
tpl_pack(tn, 0);
tpl_dump(tn, TPL_FILE, filename);
tpl_free(tn);
fmt = tpl_peek(TPL_FILE|TPL_DATAPEEK, filename, "iscsi",&pi,&ps,&pc,&pt,&pj);
if (fmt) {
printf("fmt: %s\n", fmt);
printf("pi: %d, ps: %s, pc: %c, pt: %s, pi: %d\n",pi,ps?ps:"NULL",pc,pt,pj);
} else {
printf("peek failed\n");
}
return 0;
}