#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <locale.h>
#include "tmalloc.h"
usage() {
puts(
"Usage:\n"
- "memtest [-t TEMPLATENAME]\n"
+ "tmpltest [-t TEMPLATENAME]\n"
);
exit(1);
}
fputs( str, stdout );
}
+static int counter = 0;
+
+static VariableValue
+localCounter(Template tmpl, int nargs, VariableValue *args) {
+ VariableValue out = tmalloc(sizeof(VariableValue));
+
+ out->type = valueInt;
+ out->flags = TND_DEFINED;
+ out->value.intValue = ++counter;
+
+ return out;
+}
+
extern char *optarg;
extern int opterr;
char *name = NULL;
TemplateData template;
int i;
+ executeFunctionDescData funcs[] = {
+ {"callcounter", 0, localCounter},
+ {NULL,0,NULL}
+ };
+
+
opentlog(TL_OPEN_STDERR,TL_DEBUG, NULL);
opterr=0;
if (!name)
usage();
+ setlocale(LC_ALL,"ru_RU.UTF-8");
base = allocMemoryContext(NULL, MC_DEBUG);
- printf("initTemplate: %d\n", initTemplate(&template, base, ".", name) );
- /* dumpTemplate(&template); */
+ printf("initTemplate: %d\n", initTemplate(&template, base, funcs, ".", name) );
+ /* dumpTemplate(&template); */
setTemplateValueInt(&template, "ID", 17);
setTemplateValueUndefined(&template, "emptyID");
setTemplateValueInt(&template, "zeroid", 0);
+ setTemplateValueString(&template, "str", "QWERTY");
addTemplateRow(&template, "outerLoop");
setTemplateValueString(&template, "outerLoop.data1", "ha1");