This patch is generated from the errorpages branch of HEAD in squid Sun Sep 16 00:19:11 2007 GMT See http://devel.squid-cache.org/ Index: squid/errors/English/generic diff -u squid/errors/English/generic:1.2 squid/errors/English/generic:1.2.68.1 --- squid/errors/English/generic:1.2 Thu Jul 18 17:00:46 2002 +++ squid/errors/English/generic Sun Sep 2 05:18:10 2007 @@ -1,6 +1,6 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML><HEAD> -<TITLE>ERROR: The requested URL could not be retrieved</TITLE> +<TITLE>@title@</TITLE> <STYLE type="text/css"><!--BODY{background-color:#ffffff; font-family:verdana,sans-serif}--></STYLE> </HEAD><BODY> <H1>ERROR</H1> @@ -14,18 +14,9 @@ <UL> <LI> <STRONG> -@SHORT_DESCRIPTION@ +@short_description@ </STRONG> </UL> -<P> -The system returned: -<PRE><I> %E</I></PRE> - -<P> -This means that: -<PRE> - @LONG_DESCRIPTION@ -</PRE> -</P> +@long_description@ Index: squid/errors/English/templates/ERR_ACCESS_DENIED diff -u /dev/null squid/errors/English/templates/ERR_ACCESS_DENIED:1.1.2.2 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_ACCESS_DENIED Sun Sep 2 05:19:13 2007 @@ -0,0 +1,15 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Access Denied. +[/short_description] + +[long_description] +<p> +Access control configuration prevents your request from +being allowed at this time. Please contact your service provider if +you feel this is incorrect. +</p> +[/long_escription] Index: squid/errors/English/templates/ERR_CACHE_ACCESS_DENIED diff -u /dev/null squid/errors/English/templates/ERR_CACHE_ACCESS_DENIED:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_CACHE_ACCESS_DENIED Sun Sep 2 04:53:55 2007 @@ -0,0 +1,21 @@ +[title] +ERROR: Cache Access Denied +[/title] + +[short_description] +Cache Access Denied. +[/short_description] + +[long_description] +<P>Sorry, you are not currently allowed to request: +<PRE> %U</PRE> +from this cache until you have authenticated yourself. +</P> +<P> +You need to use Netscape version 2.0 or greater, or Microsoft Internet +Explorer 3.0, or an HTTP/1.1 compliant browser for this to work. Please +contact the <A HREF="mailto:%w">cache administrator</a> if you have +difficulties authenticating yourself or here +<A HREF="http://%h/cgi-bin/chpasswd.cgi">change</a> your default password. +</P> +[/long_description] Index: squid/errors/English/templates/ERR_CACHE_MGR_ACCESS_DENIED diff -u /dev/null squid/errors/English/templates/ERR_CACHE_MGR_ACCESS_DENIED:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_CACHE_MGR_ACCESS_DENIED Sun Sep 2 04:53:55 2007 @@ -0,0 +1,20 @@ +[title] +ERROR: Cache Manager Access Denied +[/title] + +[short_description] +Cache Manager Access Denied. +[/short_description] + +[long_description] +<P>Sorry, you are not currently allowed to request: +<PRE> %U</PRE> +from this cache manager until you have authenticated yourself. +</P> +<P> You need to use Netscape version 2.0 or greater, or Microsoft Internet +Explorer 3.0, or an HTTP/1.1 compliant browser for this to work. Please +contact the <A HREF="mailto:%w">cache administrator</a> if you have +difficulties authenticating yourself or, if you <em>are</em> the +administrator, read Squid documentation on cache manager interface and check +cache log for more detailed error messages.</P> +[/long_description] Index: squid/errors/English/templates/ERR_CANNOT_FORWARD diff -u /dev/null squid/errors/English/templates/ERR_CANNOT_FORWARD:1.1.2.2 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_CANNOT_FORWARD Sun Sep 2 05:19:13 2007 @@ -0,0 +1,19 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Unable to forward this request at this time. +[/short_description] + +[long_description] +<p> +This request could not be forwarded to the origin server or to any +parent caches. The most likely cause for this error is that: +</p> +<UL> +<LI>The cache administrator does not allow this cache to make + direct connections to origin servers, and +<LI>All configured parent caches are currently unreachable. +</UL> +[/long_description] Index: squid/errors/English/templates/ERR_CONNECT_FAIL diff -u /dev/null squid/errors/English/templates/ERR_CONNECT_FAIL:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_CONNECT_FAIL Sun Sep 2 04:53:55 2007 @@ -0,0 +1,15 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Connection to %I Failed +[/short_description] + +[long_description] +<P> +The system returned: +<PRE><I> %E</I></PRE> +<P> +The remote host or network may be down. Please try the request again. +[/long_description] Index: squid/errors/English/templates/ERR_DNS_FAIL diff -u /dev/null squid/errors/English/templates/ERR_DNS_FAIL:1.1.2.2 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_DNS_FAIL Sun Sep 2 05:19:13 2007 @@ -0,0 +1,22 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Unable to determine IP address from host name for <I>%H</I> +[/short_description] + +[long_description] +<p> +The dnsserver returned: +</p> +<BLOCKQUOTE> +%z +</BLOCKQUOTE> +<P> +This means that: +<PRE> + The cache was not able to resolve the hostname presented in the URL. + Check if the address is correct. +</PRE> +[/long_description] Index: squid/errors/English/templates/ERR_FORWARDING_DENIED diff -u /dev/null squid/errors/English/templates/ERR_FORWARDING_DENIED:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_FORWARDING_DENIED Sun Sep 2 04:53:56 2007 @@ -0,0 +1,14 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Forwarding Denied. +[/short_description] + +[long_description] +<P> +This cache will not forward your request because it is trying to enforce a +sibling relationship. Perhaps the client at %i is a cache which has been +misconfigured. +[/long_description] Index: squid/errors/English/templates/ERR_FTP_DISABLED diff -u /dev/null squid/errors/English/templates/ERR_FTP_DISABLED:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_FTP_DISABLED Sun Sep 2 04:53:56 2007 @@ -0,0 +1,11 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +FTP is Disabled +[/short_description] + +[long_description] +This cache does not support FTP. +[/long_description] Index: squid/errors/English/templates/ERR_FTP_FAILURE diff -u /dev/null squid/errors/English/templates/ERR_FTP_FAILURE:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_FTP_FAILURE Sun Sep 2 04:53:56 2007 @@ -0,0 +1,15 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +There was a unexpected reply to an FTP command. +[/short_description] + +[long_description] +Squid sent the following FTP command: +<blockquote><strong><pre>%f</pre></strong></blockquote> +and then received this reply +<blockquote><strong><pre>%F</pre></strong></blockquote> +<blockquote><strong><pre>%g</pre></strong></blockquote> +[/long_description] Index: squid/errors/English/templates/ERR_FTP_FORBIDDEN diff -u /dev/null squid/errors/English/templates/ERR_FTP_FORBIDDEN:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_FTP_FORBIDDEN Sun Sep 2 04:53:56 2007 @@ -0,0 +1,15 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +An FTP authentication failure occurred while trying to retrieve the URL. +[/short_description] + +[long_description] +Squid sent the following FTP command: +<blockquote><strong><pre>%f</pre></strong></blockquote> +and then received this reply +<blockquote><strong><pre>%F</pre></strong></blockquote> +<blockquote><strong><pre>%g</pre></strong></blockquote> +[/long_description] Index: squid/errors/English/templates/ERR_FTP_NOT_FOUND diff -u /dev/null squid/errors/English/templates/ERR_FTP_NOT_FOUND:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_FTP_NOT_FOUND Sun Sep 2 04:53:56 2007 @@ -0,0 +1,19 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +The requested FTP file could not be found. +[/short_description] + +[long_description] +Squid sent the following FTP command: +<blockquote><strong><pre>%f</pre></strong></blockquote> +and then received this reply +<blockquote><strong><pre>%F</pre></strong></blockquote> +<blockquote><strong><pre>%g</pre></strong></blockquote> +<P> +This might be caused by an FTP URL with an absolute path (which does +not comply with RFC 1738). If this is the cause, then the file +can be found at <A HREF="%B">%B</A>. +[/long_description] Index: squid/errors/English/templates/ERR_FTP_PUT_CREATED diff -u /dev/null squid/errors/English/templates/ERR_FTP_PUT_CREATED:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_FTP_PUT_CREATED Sun Sep 2 04:53:56 2007 @@ -0,0 +1,11 @@ +[title] +FTP PUT Successful: File Created +[/title] + +[short_description] +Operation successful +[/short_description] + +[long_description] +File created. +[/long_description] Index: squid/errors/English/templates/ERR_FTP_PUT_ERROR diff -u /dev/null squid/errors/English/templates/ERR_FTP_PUT_ERROR:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_FTP_PUT_ERROR Sun Sep 2 04:53:56 2007 @@ -0,0 +1,23 @@ +[title] +ERROR: FTP upload failed +[/title] + +[short_description] +FTP PUT/upload failed +[/short_description] + +[long_description] +Squid sent the following FTP command: +<PRE><STRONG> + %f +</STRONG></PRE> +and then received this reply +<PRE><STRONG> + %F +</STRONG></PRE> +<P> +This means that: +<PRE> +Check path, permissions, diskspace and try again. +</PRE> +[/long_description] Index: squid/errors/English/templates/ERR_FTP_PUT_MODIFIED diff -u /dev/null squid/errors/English/templates/ERR_FTP_PUT_MODIFIED:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_FTP_PUT_MODIFIED Sun Sep 2 04:53:57 2007 @@ -0,0 +1,11 @@ +[title] +FTP PUT Successful: File updated +[/title] + +[short_description] +Operation successful +[/short_description] + +[long_description] +File updated +[/long_description] Index: squid/errors/English/templates/ERR_FTP_UNAVAILABLE diff -u /dev/null squid/errors/English/templates/ERR_FTP_UNAVAILABLE:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_FTP_UNAVAILABLE Sun Sep 2 04:53:57 2007 @@ -0,0 +1,15 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +The FTP server was too busy while trying to retrieve the URL. +[/short_description] + +[long_description] +Squid sent the following FTP command: +<blockquote><strong><pre>%f</pre></strong></blockquote> +and then received this reply +<blockquote><strong><pre>%F</pre></strong></blockquote> +<blockquote><strong><pre>%g</pre></strong></blockquote> +[/long_description] Index: squid/errors/English/templates/ERR_INVALID_REQ diff -u /dev/null squid/errors/English/templates/ERR_INVALID_REQ:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_INVALID_REQ Sun Sep 2 04:53:57 2007 @@ -0,0 +1,20 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Invalid Request (%R) +[/short_description] + +[long_description] +<P> +Some aspect of the HTTP Request is invalid. Possible problems: +<UL> +<LI>Missing or unknown request method +<LI>Missing URL +<LI>Missing HTTP Identifier (HTTP/1.0) +<LI>Request is too large +<LI>Content-Length missing for POST or PUT requests +<LI>Illegal character in hostname; underscores are not allowed +</UL> +[/long_description] Index: squid/errors/English/templates/ERR_INVALID_RESP diff -u /dev/null squid/errors/English/templates/ERR_INVALID_RESP:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_INVALID_RESP Sun Sep 2 04:53:57 2007 @@ -0,0 +1,15 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Invalid Response (%R) +[/short_description] + +[long_description] +<P> +The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. +[/long_description] Index: squid/errors/English/templates/ERR_INVALID_URL diff -u /dev/null squid/errors/English/templates/ERR_INVALID_URL:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_INVALID_URL Sun Sep 2 04:53:57 2007 @@ -0,0 +1,17 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Invalid URL +[/short_description] + +[long_description] +Some aspect of the requested URL is incorrect. Possible problems: +<UL> +<LI>Missing or incorrect access protocol (should be `http://'' or similar) +<LI>Missing hostname +<LI>Illegal double-escape in the URL-Path +<LI>Illegal character in hostname; underscores are not allowed +</UL> +[/long_description] Index: squid/errors/English/templates/ERR_LIFETIME_EXP diff -u /dev/null squid/errors/English/templates/ERR_LIFETIME_EXP:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_LIFETIME_EXP Sun Sep 2 04:53:57 2007 @@ -0,0 +1,12 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Connection Lifetime Expired +[/short_description] + +[long_description] +Squid has terminated the request because it has exceeded the maximum +connection lifetime. +[/long_description] Index: squid/errors/English/templates/ERR_NO_RELAY diff -u /dev/null squid/errors/English/templates/ERR_NO_RELAY:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_NO_RELAY Sun Sep 2 04:53:57 2007 @@ -0,0 +1,11 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +No Wais Relay +[/short_description] + +[long_description] +There is no WAIS Relay host defined for this Cache! Yell at the administrator. +[/long_description] Index: squid/errors/English/templates/ERR_ONLY_IF_CACHED_MISS diff -u /dev/null squid/errors/English/templates/ERR_ONLY_IF_CACHED_MISS:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_ONLY_IF_CACHED_MISS Sun Sep 2 04:53:57 2007 @@ -0,0 +1,14 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Valid document was not found in the cache and <code>only-if-cached</code> +directive was specified. +[/short_description] + +[long_description] +You have issued a request with a <code>only-if-cached</code> cache control +directive. The document was not found in the cache, <em>or</em> it required +revalidation prohibited by <code>only-if-cached</code> directive. +[/long_description] Index: squid/errors/English/templates/ERR_READ_ERROR diff -u /dev/null squid/errors/English/templates/ERR_READ_ERROR:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_READ_ERROR Sun Sep 2 04:53:58 2007 @@ -0,0 +1,16 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Read Error +[/short_description] + +[long_description] +<P> +The system returned: +<PRE><I> %E</I></PRE> +<P> +An error condition occurred while reading data from the network. Please +retry your request. +[/long_description] Index: squid/errors/English/templates/ERR_READ_TIMEOUT diff -u /dev/null squid/errors/English/templates/ERR_READ_TIMEOUT:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_READ_TIMEOUT Sun Sep 2 04:53:58 2007 @@ -0,0 +1,16 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Read Timeout +[/short_description] + +[long_description] +<P> +The system returned: +<PRE><I> %E</I></PRE> +<P> +A Timeout occurred while waiting to read data from the network. The network +or server may be down or congested. Please retry your request. +[/long_description] Index: squid/errors/English/templates/ERR_SHUTTING_DOWN diff -u /dev/null squid/errors/English/templates/ERR_SHUTTING_DOWN:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_SHUTTING_DOWN Sun Sep 2 04:53:58 2007 @@ -0,0 +1,13 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +This Squid cache is shutting down. +[/short_description] + +[long_description] +This cache is in the process of shutting down and can not +service your request at this time. Please retry your +request again soon. +[/long_description] Index: squid/errors/English/templates/ERR_SOCKET_FAILURE diff -u /dev/null squid/errors/English/templates/ERR_SOCKET_FAILURE:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_SOCKET_FAILURE Sun Sep 2 04:53:58 2007 @@ -0,0 +1,16 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Socket Failure +[/short_description] + +[long_description] +<P> +The system returned: +<PRE><I> %E</I></PRE> +<P> +Squid is unable to create a TCP socket, presumably due to excessive load. +Please retry your request. +[/long_description] Index: squid/errors/English/templates/ERR_TOO_BIG diff -u /dev/null squid/errors/English/templates/ERR_TOO_BIG:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_TOO_BIG Sun Sep 2 04:54:01 2007 @@ -0,0 +1,16 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +The request or reply is too large. +[/short_description] + +[long_description] +If you are making a POST or PUT request, then your request body +(the thing you are trying to upload) is too large. If you are +making a GET request, then the reply body (what you are trying +to download) is too large. These limits have been established +by the Internet Service Provider who operates this cache. Please +contact them directly if you feel this is an error. +[/long_description] Index: squid/errors/English/templates/ERR_UNSUP_REQ diff -u /dev/null squid/errors/English/templates/ERR_UNSUP_REQ:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_UNSUP_REQ Sun Sep 2 04:54:01 2007 @@ -0,0 +1,13 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Unsupported Request Method and Protocol +[/short_description] + + +[long_description] +Squid does not support all request methods for all access protocols. +For example, you can not POST a Gopher request. +[/long_description] Index: squid/errors/English/templates/ERR_URN_RESOLVE diff -u /dev/null squid/errors/English/templates/ERR_URN_RESOLVE:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_URN_RESOLVE Sun Sep 2 04:54:01 2007 @@ -0,0 +1,11 @@ +[title] +ERROR: The requested URN not be retrieved +[title] + +[short_description] +Cannot Resolve URN +[/short_description] + +[long_description] +Hey, don't expect too much from URNs on %T :) +[/long_description] Index: squid/errors/English/templates/ERR_WRITE_ERROR diff -u /dev/null squid/errors/English/templates/ERR_WRITE_ERROR:1.1.2.2 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_WRITE_ERROR Sun Sep 2 05:20:13 2007 @@ -0,0 +1,18 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Write Error +[/short_description] + +[long_description] +<p> +The system returned: +</p> +<PRE><I> %E</I></PRE> + +<P> +An error condition occurred while writing to the network. Please retry your +request. +[/long_description] Index: squid/errors/English/templates/ERR_ZERO_SIZE_OBJECT diff -u /dev/null squid/errors/English/templates/ERR_ZERO_SIZE_OBJECT:1.1.2.2 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/errors/English/templates/ERR_ZERO_SIZE_OBJECT Sun Sep 2 05:20:13 2007 @@ -0,0 +1,13 @@ +[title] +ERROR: The requested URL could not be retrieved +[/title] + +[short_description] +Zero Sized Reply +[/short_description] + +[long_description] +<p> + Squid did not receive any data for this request. +</p> +[/long_description] Index: squid/scripts/BuildErrorPages diff -u /dev/null squid/scripts/BuildErrorPages:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/scripts/BuildErrorPages Sun Sep 2 05:28:11 2007 @@ -0,0 +1,16 @@ +#!/bin/sh + +# $Id$ + +# Adrian Chadd <adrian@squid-cache.org> + +if [ "$1" = "" ]; then + echo "ERROR: please supply an errorpage directory with a 'generic' template and a templates/ subdirectory." + exit 127 +fi + +for i in `ls $1/templates/ERR*`; do + ERRFILE="`basename $i`" + echo "Error page: $ERRFILE" + ./ErrorPage.pl $1/generic $1/templates/$ERRFILE $1/$ERRFILE +done Index: squid/scripts/ErrorPage.pl diff -u /dev/null squid/scripts/ErrorPage.pl:1.1.2.1 --- /dev/null Thu Jan 1 01:00:00 1970 +++ squid/scripts/ErrorPage.pl Sun Sep 2 05:17:20 2007 @@ -0,0 +1,63 @@ +#!/usr/bin/perl -w + +# Written by Adrian Chadd <adrian@squid-cache.org> + +# $Id + +use strict; +use IO::File; + +if (scalar @ARGV < 3) { + print "Usage: <template> <input file> <output file>\n"; + exit 127; +} + +my ($template) = $ARGV[0]; +my ($ifile) = $ARGV[1]; +my ($ofile) = $ARGV[2]; + +# Suck in the input file and create the sections +my ($section) = ""; +my (%sections); +my ($if) = new IO::File; +$if->open($ifile, "r") || die "Couldn't read $ifile: $!\n"; + +while (<$if>) { + chomp; + if (m/^\[([A-Za-z0-9_\-]*)\]/) { + $section = $1; + $sections{$section} = ""; + next; + } + if (m/^\[\/([A-Za-z0-9_\-]*)\]/) { + $section = ""; + next; + } + next if ($section eq "" && $_ eq ""); + + if ($section eq "") { + print "ERROR: Text not in a section: $_\n"; + next; + } + $sections{$section} .= $_ . "\n"; +} + +$if->close(); +undef $if; + +# Next, time to read in the template file +my ($tf); +$tf = new IO::File; +$tf->open($template, "r") || die "Couldn't read $template: $!\n"; + +my ($of); +$of = new IO::File; +$of->open($ofile, "w") || die "Couldn't write to template file: $!\n"; + +while (<$tf>) { + chomp; + s/@([A-Za-z0-9\-_]*?)@/$sections{$1}/ge; + print $of $_ . "\n"; +} +$tf->close(); +$of->close();