summaryrefslogtreecommitdiff
path: root/source3/aparser/template.awk
diff options
context:
space:
mode:
Diffstat (limited to 'source3/aparser/template.awk')
-rw-r--r--source3/aparser/template.awk18
1 files changed, 18 insertions, 0 deletions
diff --git a/source3/aparser/template.awk b/source3/aparser/template.awk
new file mode 100644
index 0000000000..2015700835
--- /dev/null
+++ b/source3/aparser/template.awk
@@ -0,0 +1,18 @@
+# template file handling
+
+function print_template(f, tplname, v,
+ LOCAL, i, pat, line)
+{
+ tplname="templates/"tplname;
+ if (numlines(tplname) <= 0) fatal("no template "tplname);
+ while ((getline line < tplname) > 0) {
+ while ((i = match(line,"@[a-zA-Z_]*@")) != 0) {
+ pat=substr(line,i+1,RLENGTH-2);
+ if (v[pat] == "") fatal("no value for "pat" in "tplname);
+ gsub("@"pat"@", v[pat], line);
+ }
+
+ xprintf(f, "%s\n", line);
+ }
+ close(tplname);
+}