Browse code

check for socklen_t and define it if needed

git-svn: trunk@2222

Tomasz Kojm authored on 2006/08/31 06:22:44
Showing 4 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Aug 30 23:20:42 CEST 2006 (tk)
2
+----------------------------------
3
+  * configure: check for socklen_t and define it if needed
4
+
1 5
 Sun Aug 27 19:48:17 CEST 2006 (tk)
2 6
 ----------------------------------
3 7
   * freshclam: apply timeout patch from Everton da Silva Marques
... ...
@@ -362,3 +362,6 @@
362 362
 
363 363
 /* Define to `long int' if <sys/types.h> does not define. */
364 364
 #undef off_t
365
+
366
+/* Define to "int" if <sys/socket.h> does not define. */
367
+#undef socklen_t
... ...
@@ -15434,6 +15434,173 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15434 15434
 echo "${ECHO_T}yes, and it takes $ac_cv_ctime_args arguments" >&6; }
15435 15435
 fi
15436 15436
 
15437
+{ echo "$as_me:$LINENO: checking for socklen_t" >&5
15438
+echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6; }
15439
+if test "${ac_cv_socklen_t+set}" = set; then
15440
+  echo $ECHO_N "(cached) $ECHO_C" >&6
15441
+else
15442
+
15443
+    ac_cv_socklen_t=no
15444
+    cat >conftest.$ac_ext <<_ACEOF
15445
+/* confdefs.h.  */
15446
+_ACEOF
15447
+cat confdefs.h >>conftest.$ac_ext
15448
+cat >>conftest.$ac_ext <<_ACEOF
15449
+/* end confdefs.h.  */
15450
+
15451
+	#include <sys/types.h>
15452
+        #include <sys/socket.h>
15453
+
15454
+int
15455
+main ()
15456
+{
15457
+
15458
+	socklen_t len;
15459
+        getpeername(0,0,&len);
15460
+
15461
+  ;
15462
+  return 0;
15463
+}
15464
+_ACEOF
15465
+rm -f conftest.$ac_objext
15466
+if { (ac_try="$ac_compile"
15467
+case "(($ac_try" in
15468
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15469
+  *) ac_try_echo=$ac_try;;
15470
+esac
15471
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15472
+  (eval "$ac_compile") 2>conftest.er1
15473
+  ac_status=$?
15474
+  grep -v '^ *+' conftest.er1 >conftest.err
15475
+  rm -f conftest.er1
15476
+  cat conftest.err >&5
15477
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
15478
+  (exit $ac_status); } &&
15479
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
15480
+  { (case "(($ac_try" in
15481
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15482
+  *) ac_try_echo=$ac_try;;
15483
+esac
15484
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15485
+  (eval "$ac_try") 2>&5
15486
+  ac_status=$?
15487
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
15488
+  (exit $ac_status); }; } &&
15489
+	 { ac_try='test -s conftest.$ac_objext'
15490
+  { (case "(($ac_try" in
15491
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15492
+  *) ac_try_echo=$ac_try;;
15493
+esac
15494
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15495
+  (eval "$ac_try") 2>&5
15496
+  ac_status=$?
15497
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
15498
+  (exit $ac_status); }; }; then
15499
+
15500
+	ac_cv_socklen_t=yes
15501
+
15502
+else
15503
+  echo "$as_me: failed program was:" >&5
15504
+sed 's/^/| /' conftest.$ac_ext >&5
15505
+
15506
+
15507
+fi
15508
+
15509
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15510
+
15511
+fi
15512
+
15513
+{ echo "$as_me:$LINENO: result: $ac_cv_socklen_t" >&5
15514
+echo "${ECHO_T}$ac_cv_socklen_t" >&6; }
15515
+    if test $ac_cv_socklen_t = no; then
15516
+    { echo "$as_me:$LINENO: checking for socklen_t equivalent" >&5
15517
+echo $ECHO_N "checking for socklen_t equivalent... $ECHO_C" >&6; }
15518
+    if test "${ac_cv_socklen_t_equiv+set}" = set; then
15519
+  echo $ECHO_N "(cached) $ECHO_C" >&6
15520
+else
15521
+
15522
+	ac_cv_socklen_t_equiv=int
15523
+        for t in int size_t unsigned long "unsigned long"; do
15524
+	    cat >conftest.$ac_ext <<_ACEOF
15525
+/* confdefs.h.  */
15526
+_ACEOF
15527
+cat confdefs.h >>conftest.$ac_ext
15528
+cat >>conftest.$ac_ext <<_ACEOF
15529
+/* end confdefs.h.  */
15530
+
15531
+		#include <sys/types.h>
15532
+		#include <sys/socket.h>
15533
+
15534
+int
15535
+main ()
15536
+{
15537
+
15538
+		$t len;
15539
+		getpeername(0,0,&len);
15540
+
15541
+  ;
15542
+  return 0;
15543
+}
15544
+_ACEOF
15545
+rm -f conftest.$ac_objext
15546
+if { (ac_try="$ac_compile"
15547
+case "(($ac_try" in
15548
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15549
+  *) ac_try_echo=$ac_try;;
15550
+esac
15551
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15552
+  (eval "$ac_compile") 2>conftest.er1
15553
+  ac_status=$?
15554
+  grep -v '^ *+' conftest.er1 >conftest.err
15555
+  rm -f conftest.er1
15556
+  cat conftest.err >&5
15557
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
15558
+  (exit $ac_status); } &&
15559
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
15560
+  { (case "(($ac_try" in
15561
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15562
+  *) ac_try_echo=$ac_try;;
15563
+esac
15564
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15565
+  (eval "$ac_try") 2>&5
15566
+  ac_status=$?
15567
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
15568
+  (exit $ac_status); }; } &&
15569
+	 { ac_try='test -s conftest.$ac_objext'
15570
+  { (case "(($ac_try" in
15571
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15572
+  *) ac_try_echo=$ac_try;;
15573
+esac
15574
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15575
+  (eval "$ac_try") 2>&5
15576
+  ac_status=$?
15577
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
15578
+  (exit $ac_status); }; }; then
15579
+
15580
+		ac_cv_socklen_t_equiv="$t"
15581
+		break
15582
+
15583
+else
15584
+  echo "$as_me: failed program was:" >&5
15585
+sed 's/^/| /' conftest.$ac_ext >&5
15586
+
15587
+
15588
+fi
15589
+
15590
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15591
+	done
15592
+
15593
+fi
15594
+
15595
+    { echo "$as_me:$LINENO: result: $ac_cv_socklen_t_equiv" >&5
15596
+echo "${ECHO_T}$ac_cv_socklen_t_equiv" >&6; }
15597
+
15598
+cat >>confdefs.h <<_ACEOF
15599
+#define socklen_t $ac_cv_socklen_t_equiv
15600
+_ACEOF
15601
+
15602
+fi
15603
+
15437 15604
 if test "$test_clamav" = "yes"
15438 15605
 then
15439 15606
         if test "$use_id" = "no"
... ...
@@ -1,6 +1,7 @@
1 1
 dnl
2 2
 dnl   Copyright (C) 2002 - 2006 Tomasz Kojm <tkojm@clamav.net>
3 3
 dnl   gethostbyname_r and readdir_r checks (c) COPYRIGHT MIT 1995
4
+dnl   socklen_t check (c) Alexander V. Lukyanov <lav@yars.free.net>
4 5
 dnl
5 6
 dnl   This program is free software; you can redistribute it and/or modify
6 7
 dnl   it under the terms of the GNU General Public License as published by
... ...
@@ -867,6 +868,48 @@ if test "$ac_cv_func_ctime_r" = "yes"; then
867 867
     AC_MSG_RESULT([yes, and it takes $ac_cv_ctime_args arguments])
868 868
 fi
869 869
 
870
+dnl Determine socklen_t type. Code from lftp.
871
+AC_MSG_CHECKING(for socklen_t)
872
+AC_CACHE_VAL(ac_cv_socklen_t,
873
+[
874
+    ac_cv_socklen_t=no
875
+    AC_TRY_COMPILE([
876
+	#include <sys/types.h>
877
+        #include <sys/socket.h>
878
+    ],
879
+    [
880
+	socklen_t len;
881
+        getpeername(0,0,&len);
882
+    ],
883
+    [
884
+	ac_cv_socklen_t=yes
885
+    ])
886
+])
887
+AC_MSG_RESULT($ac_cv_socklen_t)
888
+    if test $ac_cv_socklen_t = no; then
889
+    AC_MSG_CHECKING(for socklen_t equivalent)
890
+    AC_CACHE_VAL(ac_cv_socklen_t_equiv,
891
+    [
892
+	ac_cv_socklen_t_equiv=int
893
+        for t in int size_t unsigned long "unsigned long"; do
894
+	    AC_TRY_COMPILE([
895
+		#include <sys/types.h>
896
+		#include <sys/socket.h>
897
+	    ],
898
+            [
899
+		$t len;
900
+		getpeername(0,0,&len);
901
+            ],
902
+            [
903
+		ac_cv_socklen_t_equiv="$t"
904
+		break
905
+            ])
906
+	done
907
+    ])
908
+    AC_MSG_RESULT($ac_cv_socklen_t_equiv)
909
+    AC_DEFINE_UNQUOTED(socklen_t, $ac_cv_socklen_t_equiv, [Define to "int" if <sys/socket.h> does not define.])
910
+fi
911
+
870 912
 dnl Check for clamav in /etc/passwd
871 913
 if test "$test_clamav" = "yes"
872 914
 then