This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
4cb0007346ae695edfc546a355caa8601a6afb96
[metaconfig.git] / U / protos / socksizetype.U
1 ?RCS: $Id: socksizetype.U,v $
2 ?RCS:
3 ?RCS: Copyright (c) 2000 Jarkko Hietaniemi
4 ?RCS:
5 ?RCS: You may distribute under the terms of either the GNU General Public
6 ?RCS: License or the Artistic License, as specified in the README file.
7 ?RCS:
8 ?MAKE:socksizetype: \
9         Protochk Oldconfig Myread cat d_socket d_socklen_t sizetype
10 ?MAKE:  -pick add $@ %<
11 ?S:socksizetype:
12 ?S:     This variable holds the type used for the size argument
13 ?S:     for various socket calls like accept.  Usual values include
14 ?S:     socklen_t, size_t, and int.
15 ?S:.
16 ?C:Sock_size_t:
17 ?C:     This symbol holds the type used for the size argument
18 ?C:     of various socket calls.
19 ?C:.
20 ?H:#define Sock_size_t          $socksizetype /**/
21 ?H:.
22 ?T:xxx yyy try hdrs
23 @if Sock_size_t
24 : check for type of the size argument to socket calls
25 case "$d_socket" in
26 "$define")
27         $cat <<EOM
28
29 Checking to see what type is the last argument of accept().
30 EOM
31         hdrs="$define sys/types.h $d_socket sys/socket.h" 
32         yyy=''
33         case "$d_socklen_t" in
34         "$define") yyy="$yyy socklen_t"
35         esac
36         yyy="$yyy $sizetype int long"
37         for xxx in $yyy; do
38                 case "$socksizetype" in
39                 '')     try="extern int accept(int, struct sockaddr *, $xxx *);"
40                         if ./protochk "$try" $hdrs; then
41                                 echo "Your system accepts '$xxx *' for the last argument of accept()."
42                                 socksizetype="$xxx *"
43                         fi
44                         ;;
45                 esac
46         done
47 : In case none of those worked, prompt the user.
48         case "$socksizetype" in
49         '')     rp='What is the type for the last argument to accept()?'
50                 dflt='int *'
51                 . ./myread
52                 socksizetype=$ans
53                 ;;
54         esac
55         ;;
56 *)      : no gethostbyaddr, so pick relatively harmless defaults
57         socksizetype='char *'
58         ;;
59 esac
60 @end
61