X-Git-Url: http://sigaev.ru/git/gitweb.cgi?a=blobdiff_plain;f=tmpltest.c;h=c5aef19c4adc4f34f196d94a4b55c857a9ab94fb;hb=029b7a56ef910c2430ddb40a7383c7caa640ecc1;hp=5c3986f7782f0de4b6fd24b1de62a0132697876c;hpb=ac6f06173082a74d22e6a39df025eb4aad98bc0a;p=tedtools.git diff --git a/tmpltest.c b/tmpltest.c index 5c3986f..c5aef19 100644 --- a/tmpltest.c +++ b/tmpltest.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "tmalloc.h" @@ -42,7 +43,7 @@ static void usage() { puts( "Usage:\n" - "memtest [-t TEMPLATENAME]\n" + "tmpltest [-t TEMPLATENAME]\n" ); exit(1); } @@ -53,6 +54,19 @@ outfunc(char *str, int len) { 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; @@ -62,6 +76,12 @@ main(int argn, char *argv[]) { char *name = NULL; TemplateData template; int i; + executeFunctionDescData funcs[] = { + {"callcounter", 0, localCounter}, + {NULL,0,NULL} + }; + + opentlog(TL_OPEN_STDERR,TL_DEBUG, NULL); opterr=0; @@ -81,14 +101,16 @@ main(int argn, char *argv[]) { 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");