r10510: Decrease the amount of data included by includes.h a bit
[bbaumbach/samba-autobuild/.git] / source4 / lib / replace / config.m4
1 AC_CHECK_TYPE(uint_t, unsigned int)
2 AC_CHECK_TYPE(int8_t, signed char)
3 AC_CHECK_TYPE(uint8_t, unsigned char)
4 AC_CHECK_TYPE(int16_t, short)
5 AC_CHECK_TYPE(uint16_t, unsigned short)
6 AC_CHECK_TYPE(int32_t, long)
7 AC_CHECK_TYPE(uint32_t, unsigned long)
8 AC_CHECK_TYPE(int64_t, long long)
9 AC_CHECK_TYPE(uint64_t, unsigned long long)
10 AC_CHECK_TYPE(u_int32_t, unsigned long)
11 AC_CHECK_TYPE(u_int16_t, unsigned short)
12 AC_CHECK_TYPE(u_int8_t, unsigned char)
13 AC_CHECK_TYPE(ssize_t, int)
14
15 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
16 AC_TRY_RUN([
17 #include <stdio.h>
18 #include <sys/types.h>
19 #include <netinet/in.h>
20 #ifdef HAVE_ARPA_INET_H
21 #include <arpa/inet.h>
22 #endif
23 main() { struct in_addr ip; ip.s_addr = 0x12345678;
24 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
25     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
26 exit(1);}],
27            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
28 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
29     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
30 fi
31
32 dnl Provided by replace.c:
33 AC_CHECK_TYPE([socklen_t], int)
34 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
35 AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
36 AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
37 AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename)
38 AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup)
39 AC_CHECK_FUNCS(pread pwrite strndup)
40 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
41 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
42 AC_HAVE_DECL(errno, [#include <errno.h>])
43
44 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
45 AC_TRY_RUN([#include <stdlib.h>
46 #include <sys/types.h>
47 #include <sys/stat.h>
48 #include <unistd.h>
49 main() { 
50   struct stat st;
51   char tpl[20]="/tmp/test.XXXXXX"; 
52   int fd = mkstemp(tpl); 
53   if (fd == -1) exit(1);
54   unlink(tpl);
55   if (fstat(fd, &st) != 0) exit(1);
56   if ((st.st_mode & 0777) != 0600) exit(1);
57   exit(0);
58 }],
59 samba_cv_HAVE_SECURE_MKSTEMP=yes,
60 samba_cv_HAVE_SECURE_MKSTEMP=no,
61 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
62 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
63     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
64 fi
65
66 dnl Provided by snprintf.c:
67 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
68 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
69 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
70 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
71 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
72
73 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
74 AC_TRY_RUN([
75 #include <sys/types.h>
76 #include <stdarg.h>
77 void foo(const char *format, ...) { 
78        va_list ap;
79        int len;
80        char buf[20];
81        long long l = 1234567890;
82        l *= 100;
83
84        va_start(ap, format);
85        len = vsnprintf(buf, 0, format, ap);
86        va_end(ap);
87        if (len != 5) exit(1);
88
89        va_start(ap, format);
90        len = vsnprintf(0, 0, format, ap);
91        va_end(ap);
92        if (len != 5) exit(1);
93
94        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
95
96        if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(1);
97
98        exit(0);
99 }
100 main() { foo("hello"); }
101 ],
102 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
103 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
104     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
105 fi
106
107 dnl Provided by dlfcn.c:
108 AC_SEARCH_LIBS_EXT(dlopen, [dl], DL_LIBS)
109 SMB_EXT_LIB(DL,[${DL_LIBS}],[${DL_CFLAGS}],[${DL_CPPFLAGS}],[${DL_LDFLAGS}])
110 SAVE_LIBS="$LIBS"
111 LIBS="$LIBS $DL_LIBS"
112 AC_CHECK_HEADERS(dlfcn.h)
113 AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose)
114 LIBS="$SAVE_LIBS"
115
116 AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],,
117                            [AC_MSG_ERROR([Required function not found])])