2 * Copyright (c) 2008 Teodor Sigaev <teodor@sigaev.ru>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the author nor the names of any co-contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 "memtest [-t TEMPLATENAME]\n"
52 outfunc(char *str, int len) {
60 main(int argn, char *argv[]) {
63 TemplateData template;
66 opentlog(TL_OPEN_STDERR,TL_DEBUG, NULL);
69 while((i=getopt(argn,argv,"ht:")) != EOF) {
72 name = tstrdup(optarg);
84 base = allocMemoryContext(NULL, MC_DEBUG);
86 printf("initTemplate: %d\n", initTemplate(&template, base, ".", name) );
87 /* dumpTemplate(&template); */
89 setTemplateValueInt(&template, "ID", 17);
90 setTemplateValueUndefined(&template, "emptyID");
91 setTemplateValueInt(&template, "zeroid", 0);
93 addTemplateRow(&template, "outerLoop");
94 setTemplateValueString(&template, "outerLoop.data1", "ha1");
95 setTemplateValueUndefined(&template, "outerLoop.data2");
97 addTemplateRow(&template, "outerLoop");
98 setTemplateValueInt(&template, "outerLoop.data1", 10);
99 setTemplateValueString(&template, "outerLoop.data2", "WOW");
100 addTemplateRow(&template, "outerLoop.innerLoop");
101 setTemplateValueString(&template, "outerLoop.innerLoop.camenty", "Number 1");
102 addTemplateRow(&template, "outerLoop.innerLoop");
103 setTemplateValueString(&template, "outerLoop.innerLoop.camenty", "Number 2");
105 addTemplateRow(&template, "outerLoop");
106 setTemplateValueString(&template, "outerLoop.data1", "ha3");
108 template.printString = outfunc;
109 printTemplate( &template );
111 resetTemplate(&template);
113 setTemplateValueInt(&template, "ID", 23);
114 setTemplateValueUndefined(&template, "emptyID");
115 setTemplateValueInt(&template, "zeroid", 0);
116 addTemplateRow(&template, "outerLoop");
117 setTemplateValueString(&template, "outerLoop.data1", "ha1");
118 setTemplateValueInt(&template, "outerLoop.data1", 1234);
119 setTemplateValueString(&template, "outerLoop.data2", "FOO");
120 addTemplateRow(&template, "outerLoop.innerLoop");
121 setTemplateValueString(&template, "outerLoop.innerLoop.camenty", "Again 1");
123 fputs("================================================\n", stdout);
124 printTemplate( &template );
126 resetTemplate(&template);
127 freeTemplate(&template);