File: template.awk

package info (click to toggle)
samba 2.2.3a-15
  • links: PTS
  • area: main
  • in suites: woody
  • size: 24,336 kB
  • ctags: 19,246
  • sloc: ansic: 179,555; sh: 6,888; perl: 2,091; makefile: 1,491; awk: 1,143; exp: 1,143; csh: 161
file content (18 lines) | stat: -rw-r--r-- 457 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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);
}