#!/bin/sh

# This script gets most prototypes right. Function-declarations with the
# right-paren on another line gets missed.
#
# (C) 1994 Mikael Nordqvist (d91mn@efd.lth.se, mech@df.lth.se)
#

cat << EOF
/*
 *  protos.c - Prototypes for all functions.
 *
 *  (C) 1994 Mikael Nordqvist (d91mn@efd.lth.se, mech@df.lth.se)
 */

/*
EOF
echo " *  Automagically generated "`date`"."
cat << EOF
 */

#ifndef _PROTOS_H
#define _PROTOS_H

#include <sys/types.h>
#include <linux/dirent.h>

/* User-defined types */

EOF
for FILE in *.h; do
  grep "^struct.*{" $FILE|sed "s/ *{$/;/"
done
echo
echo "/* Function prototypes */"
echo
for FILE in *.c; do
  echo "/* "$FILE" */"
  grep "^[_a-zA-Z].*(.*)[ ]*$" $FILE|grep -v "^\(static\|inline\)"|sed -e "s/^/extern /" \
	-e "s/$/;/"
  echo
done
echo "#endif /* _PROTOS_H */"
