#!/usr/local/bin/perl
# $Date: 2005-05-19 14:27:44 -0400 (Thu, 19 May 2005) $ $Id: remake_status 2 2005-05-19 18:27:44Z jmazzitelli $
#
$SRCDIR=shift || die
	"usage: remake <apache-src-dir>";

open FH,"$SRCDIR/httpd.h"
	or die "Cannot open apache httpd.h: $!";

$t=scalar(gmtime(time));

print qq|/*>status_codes.h
 *
 * Dynamicaly generated HTTP Status Codes and their ascii
 * representation. Do not edit manually; but delete the
 * file and do another make (or a make status_codes.h)
 *
 * Generated from $SRCDIR on 
 * $t
 */
|;

while(<FH>) {
	next unless m/^\#define/;
	next if m/HTTP_VERSION/;
	s/INVALID/HEAD/g;
	if (m/^\#define\s+HTTP_(\w+)\s*(\d+)/) {
		$p{ $2 } = $1;
	};
	if (m/M_(\w+)\s*(\d+)/) {
		$q{ $2 } = $1;
	};
};

print qq|
int responseTypes[] = {
|;

map {
	print "$_,";
	} sort { $a <=> $b } keys %p;

print qq|0 }; 

char * requestTypes[] ={
|;

map {
	print "\"$_\",";
	} sort { 
		$x = length($a) <=> length($b);
		return $x ? $x : (uc $a cmp uc $b);
		} values %q;

print "NULL };

";
