Browse Source

Moved template size calculation out to Awk script

pull/4/head
Adrian Perez 18 years ago
parent
commit
1933610719
  1. 13
      ngx_http_fancyindex_module.h
  2. 7
      template.awk
  3. 11
      template.h

13
ngx_http_fancyindex_module.h

@ -8,18 +8,11 @@
#ifndef __ngx_http_fancyindex_module_h__ #ifndef __ngx_http_fancyindex_module_h__
#define __ngx_http_fancyindex_module_h__ #define __ngx_http_fancyindex_module_h__
#define nfi_sizeof_ssz(_s) (sizeof(_s) - 1)
#include "template.h" #include "template.h"
#define NFI_TEMPLATE_SIZE \
( (sizeof(t01_head1) - 1) \
+ (sizeof(t02_head2) - 1) \
+ (sizeof(t03_body1) - 1) \
+ (sizeof(t04_body2) - 1) \
+ (sizeof(t05_list1) - 1) \
+ (sizeof(t06_list2) - 1) \
+ (sizeof(t07_body3) - 1) \
+ (sizeof(t08_body4) - 1) \
+ (sizeof(t09_foot1) - 1) )
/** /**
* Copy a static zero-terminated string. Useful to output template * Copy a static zero-terminated string. Useful to output template

7
template.awk

@ -10,6 +10,7 @@
BEGIN { BEGIN {
varname = 0; varname = 0;
print "/* Automagically generated, do not edit! */" print "/* Automagically generated, do not edit! */"
vars_count = 0;
} }
/^<!--[[:space:]]*var[[:space:]]+[^[:space:]]+[[:space:]]*-->$/ { /^<!--[[:space:]]*var[[:space:]]+[^[:space:]]+[[:space:]]*-->$/ {
@ -19,6 +20,7 @@ BEGIN {
next; next;
} }
varname = $3; varname = $3;
vars[vars_count++] = varname;
print "static const u_char " varname "[] = \"\""; print "static const u_char " varname "[] = \"\"";
next; next;
} }
@ -35,5 +37,10 @@ BEGIN {
END { END {
if (varname) print ";"; if (varname) print ";";
print "#define NFI_TEMPLATE_SIZE (0 \\";
for (var in vars) {
print "\t+ nfi_sizeof_ssz(" var ") \\";
}
print "\t)"
} }

11
template.h

@ -78,3 +78,14 @@ static const u_char t09_foot1[] = ""
"</body>" "</body>"
"</html>" "</html>"
; ;
#define NFI_TEMPLATE_SIZE (0 \
+ nfi_sizeof_ssz(4) \
+ nfi_sizeof_ssz(5) \
+ nfi_sizeof_ssz(6) \
+ nfi_sizeof_ssz(7) \
+ nfi_sizeof_ssz(8) \
+ nfi_sizeof_ssz(0) \
+ nfi_sizeof_ssz(1) \
+ nfi_sizeof_ssz(2) \
+ nfi_sizeof_ssz(3) \
)

Loading…
Cancel
Save