?RCS: $Id: socksizetype.U,v $
?RCS:
?RCS: Copyright (c) 2000 Jarkko Hietaniemi
?RCS:
?RCS: You may distribute under the terms of either the GNU General Public
?RCS: License or the Artistic License, as specified in the README file.
?RCS:
?MAKE:socksizetype: \
	Protochk Oldconfig Myread cat d_socket d_socklen_t sizetype \
	usesocks i_socks i_systypes extern_C
?MAKE:	-pick add $@ %<
?S:socksizetype:
?S:	This variable holds the type used for the size argument
?S:	for various socket calls like accept.  Usual values include
?S:	socklen_t, size_t, and int.
?S:.
?C:Sock_size_t:
?C:	This symbol holds the type used for the size argument of
?C:	various socket calls (just the base type, not the pointer-to).
?C:.
?H:#define Sock_size_t		$socksizetype /**/
?H:.
?T:xxx yyy try
@if Sock_size_t
: check for type of the size argument to socket calls
case "$d_socket" in
"$define")
	$cat <<EOM

Checking to see what type is the last argument of accept().
EOM
	yyy=''
	case "$d_socklen_t" in
	"$define") yyy="$yyy socklen_t"
	esac
	yyy="$yyy $sizetype int long unsigned"
	for xxx in $yyy; do
		case "$socksizetype" in
		'')	try="$extern_C int accept(int, struct sockaddr *, $xxx *);"
			case "$usesocks" in
			"$define")
				if ./protochk "$try" $i_systypes sys/types.h $d_socket sys/socket.h literal '#define INCLUDE_PROTOTYPES' $i_socks socks.h.; then
					echo "Your system accepts '$xxx *' for the last argument of accept()."
					socksizetype="$xxx"
				fi
				;;
			*)	if ./protochk "$try"  $i_systypes sys/types.h $d_socket sys/socket.h; then
					echo "Your system accepts '$xxx *' for the last argument of accept()."
					socksizetype="$xxx"
				fi
				;;
			esac
			;;
		esac
	done
: In case none of those worked, prompt the user.
	case "$socksizetype" in
	'')	rp='What is the type for socket address structure sizes?'
		dflt='int'
		. ./myread
		socksizetype=$ans
		;;
	esac
	;;
*)	: no sockets, so pick relatively harmless default
	socksizetype='int'
	;;
esac
@end

