#!/bin/sh
#
# Quick script to re-generate the status
# codes and method arrays from the httpd.h
# file; note the peculiar searching !
#
# Dirk.vanGulik@jrc.it
#
(
cat <<EOM

/* 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)
 */

int responseTypes[] = {
EOM

grep "define HTTP_" ../../include/httpd.h |\
	grep -v "HTTP_VERSION" |\
	sed -e "s/HTTP_//g" |\
	awk '{ printf "%d,",$3 }' |\
	sort -n |\
	sed -e "s/,$//g"
cat <<EOM
, 0 };

char * requestTypes[] ={
EOM

grep "define M_" ../../include/httpd.h |\
	sed -e "s/INVALID/HEAD/g" |\
	sed -e "s/M_//g" |\
	awk '{ print length($2) " " $2 }' |\
	sort -n |\
	awk '{ printf "\"%s\",",$2 }' |\
	sort |\
	sed -e "s/,$//g"

cat <<EOM
};

EOM

) > status_codes.h
	
