You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngx-fancyindex/template.awk

53 lines
941 B

18 years ago
#! /usr/bin/awk -f
#
# Copyright © Adrian Perez <adrianperez@udc.es>
#
# Converts an HTML template into a C header suitable for inclusion.
# Take a look at the HACKING.rst file to know how to use it :-)
#
# This code is placed in the public domain.
BEGIN {
varname = 0;
print "/* Automagically generated, do not edit! */"
vars_count = 0;
18 years ago
}
/^<!--[[:space:]]*var[[:space:]]+[^[:space:]]+[[:space:]]*-->$/ {
if (varname) print ";";
if ($3 == "NONE") {
varname = 0;
next;
}
18 years ago
varname = $3;
vars[vars_count++] = varname;
18 years ago
print "static const u_char " varname "[] = \"\"";
next;
}
17 years ago
/^$/ {
if (!varname) next;
print "\"\\n\"";
next;
}
18 years ago
{
if (!varname) next;
# Order matters
gsub(/[\t\v\n\r\f]+/, "");
18 years ago
gsub(/\\/, "\\\\");
gsub(/"/, "\\\"");
print "\"" $0 "\""
}
END {
if (varname) print ";";
print "#define NFI_TEMPLATE_SIZE (0 \\";
for (var in vars) {
17 years ago
print "\t+ nfi_sizeof_ssz(" vars[var] ") \\";
}
print "\t)"
18 years ago
}