[BACK]Return to makeerrnos.sh CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.bin / ktruss

File: [cvs.NetBSD.org] / src / usr.bin / ktruss / makeerrnos.sh (download)

Revision 1.3, Sun Feb 18 18:38:18 2001 UTC (18 years, 11 months ago) by kim
Branch: MAIN
CVS Tags: netbsd-3-base, netbsd-3-1-RELEASE, netbsd-3-1-RC4, netbsd-3-1-RC3, netbsd-3-1-RC2, netbsd-3-1-RC1, netbsd-3-1-1-RELEASE, netbsd-3-1, netbsd-3-0-RELEASE, netbsd-3-0-RC6, netbsd-3-0-RC5, netbsd-3-0-RC4, netbsd-3-0-RC3, netbsd-3-0-RC2, netbsd-3-0-RC1, netbsd-3-0-3-RELEASE, netbsd-3-0-2-RELEASE, netbsd-3-0-1-RELEASE, netbsd-3-0, netbsd-3, netbsd-2-base, netbsd-2-1-RELEASE, netbsd-2-1-RC6, netbsd-2-1-RC5, netbsd-2-1-RC4, netbsd-2-1-RC3, netbsd-2-1-RC2, netbsd-2-1-RC1, netbsd-2-1, netbsd-2-0-base, netbsd-2-0-RELEASE, netbsd-2-0-RC5, netbsd-2-0-RC4, netbsd-2-0-RC3, netbsd-2-0-RC2, netbsd-2-0-RC1, netbsd-2-0-3-RELEASE, netbsd-2-0-2-RELEASE, netbsd-2-0-1-RELEASE, netbsd-2-0, netbsd-2, netbsd-1-6-base, netbsd-1-6-RELEASE, netbsd-1-6-RC3, netbsd-1-6-RC2, netbsd-1-6-RC1, netbsd-1-6-PATCH002-RELEASE, netbsd-1-6-PATCH002-RC4, netbsd-1-6-PATCH002-RC3, netbsd-1-6-PATCH002-RC2, netbsd-1-6-PATCH002-RC1, netbsd-1-6-PATCH002, netbsd-1-6-PATCH001-RELEASE, netbsd-1-6-PATCH001-RC3, netbsd-1-6-PATCH001-RC2, netbsd-1-6-PATCH001-RC1, netbsd-1-6-PATCH001, netbsd-1-6, fvdl_fs64_base
Changes since 1.2: +3 -3 lines

Use the errno.h and signal.h passed in on the command line.

#! /bin/sh
#
#	$NetBSD: makeerrnos.sh,v 1.3 2001/02/18 18:38:18 kim Exp $

if [ $# -ne 3 ]; then
	echo "usage: makeerrnos.sh errno.h signal.h output"
	exit 1;
fi

ERRNOH=$1
SIGNALH=$2
CFILE=$3.c
HFILE=$3.h

: ${CPP:=cpp}
: ${CPPFLAGS:=}

cat <<__EOF__ > $CFILE
#include "misc.h"

struct systab errnos[] = {
__EOF__
cat ${ERRNOH} | ${CPP} ${CPPFLAGS} -dM |
awk '
/^#[ 	]*define[ 	]*E[A-Z0-9]*[ 	]*[0-9-][0-9]*[ 	]*.*/ {
	for (i = 1; i <= NF; i++)
		if ($i ~ /define/) 
			break;
	i++;
	j = i + 1;
	#
	printf("\t{ \"%s\", %s },\n", $i, $j);
}
END {
	print "	{ \"0\", 0 },\n";
}
' | sort -n +2 >> $CFILE
echo "	{ 0L, 0},
};" >> $CFILE
lines=`wc -l $CFILE|awk ' { print $1; } ' -`
lines=`expr $lines - 4`

cat <<__EOF__ >> $CFILE

struct systab signals[] = {
__EOF__
cat ${SIGNALH} | ${CPP} ${CPPFLAGS} -dM |
awk '
/^#[ 	]*define[ 	]*S[A-Z0-9]*[ 	]*[0-9-][0-9]*[ 	]*.*/ {
	for (i = 1; i <= NF; i++)
		if ($i ~ /define/) 
			break;
	i++;
	j = i + 1;
	#
	printf("\t{ \"%s\", %s },\n", $i, $j);
}
END {
	print "	{ \"0\", 0 },\n";
}
' | sort -n +2 >> $CFILE
echo "	{ 0L, 0},
};" >> $CFILE
elines=`grep '{ "SIG' $CFILE | wc -l`
elines=`expr $elines + 1`

cat <<__EOF__ >$HFILE
struct	systab	{
	char	*name;
	int	value;
};

extern struct systab errnos[$lines + 1];
extern struct systab signals[$elines + 1];

#define	MAXERRNOS	$lines
#define	MAXSIGNALS	$elines
__EOF__