+++ /dev/null
-#! /bin/sh
-
-die() {
- echo "$@" 1>&2
- exit 2
-}
-
-do_h() {
- echo "#ifndef MUTT_LIB_MIME_RFC822HDRS_H"
- echo "#define MUTT_LIB_MIME_RFC822HDRS_H"
- echo "/* THIS FILE IS AUTOGENERATED FROM $< DO NOT MODIFY */"
- echo "enum rfc822hdr {"
- echo " HDR_UNKNOWN,"
- tr 'a-z-' 'A-Z_' | sed -e 's/.*/ HDR_&,/'
- echo "};"
- echo
- echo "enum rfc822hdr rfc822_well_known(const char *s);"
- echo "#endif /* MUTT_LIB_MIME_RFC822HDRS_H */"
-}
-
-do_c() {
- echo "%{"
- echo "#include <string.h>"
- echo "#include \"rfc822hdrs.h\""
- echo "%}"
- echo "struct hdr { const char *name; int val; };"
- echo "%%"
- awk '{print $$0 ", " NR }'
- echo "%%"
- echo "enum rfc822hdr rfc822_well_known(const char *s) {"
- echo " const struct hdr *res = in_word_set(s, strlen(s));"
- echo " return res ? res->val : HDR_UNKNOWN;"
- echo "}"
-}
-
-case "$1" in
- *.h) do_h > "$1" ;;
- *.c) do_c | gperf --ignore-case -t -C -F,0 > "$1" ;;
- *) die "you must ask for the 'h' or 'c' generation" ;;
-esac
-
-exit 0