From e4a505192d23c7d77a6ee68e6e2946bab983ae43 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 1 Jun 2005 10:16:35 +0000 Subject: r7166: Move replacement stuff to seperate directory (easier to add win32-specific bits later) Trim LIBBASIC a bit more (This used to be commit fc7f519e4ae2051e9515df5f549c8e1842b7e70b) --- source4/lib/replace/replace.c | 564 +++++++++++++++++++++++ source4/lib/replace/snprintf.c | 981 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1545 insertions(+) create mode 100644 source4/lib/replace/replace.c create mode 100644 source4/lib/replace/snprintf.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c new file mode 100644 index 0000000000..89612912b7 --- /dev/null +++ b/source4/lib/replace/replace.c @@ -0,0 +1,564 @@ +/* + Unix SMB/CIFS implementation. + replacement routines for broken systems + Copyright (C) Andrew Tridgell 1992-1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "system/wait.h" +#include "system/time.h" +#include "system/network.h" + + void replace_dummy(void); + void replace_dummy(void) {} + +#ifndef HAVE_FTRUNCATE + /******************************************************************* +ftruncate for operating systems that don't have it +********************************************************************/ + int ftruncate(int f,off_t l) +{ +#ifdef HAVE_CHSIZE + return chsize(f,l); +#else + struct flock fl; + + fl.l_whence = 0; + fl.l_len = 0; + fl.l_start = l; + fl.l_type = F_WRLCK; + return fcntl(f, F_FREESP, &fl); +#endif +} +#endif /* HAVE_FTRUNCATE */ + + +#ifndef HAVE_STRLCPY +/* like strncpy but does not 0 fill the buffer and always null + terminates. bufsize is the size of the destination buffer */ + size_t strlcpy(char *d, const char *s, size_t bufsize) +{ + size_t len = strlen(s); + size_t ret = len; + if (bufsize <= 0) return 0; + if (len >= bufsize) len = bufsize-1; + memcpy(d, s, len); + d[len] = 0; + return ret; +} +#endif + +#ifndef HAVE_STRLCAT +/* like strncat but does not 0 fill the buffer and always null + terminates. bufsize is the length of the buffer, which should + be one more than the maximum resulting string length */ + size_t strlcat(char *d, const char *s, size_t bufsize) +{ + size_t len1 = strlen(d); + size_t len2 = strlen(s); + size_t ret = len1 + len2; + + if (len1+len2 >= bufsize) { + len2 = bufsize - (len1+1); + } + if (len2 > 0) { + memcpy(d+len1, s, len2); + d[len1+len2] = 0; + } + return ret; +} +#endif + +#ifndef HAVE_MKTIME +/******************************************************************* +a mktime() replacement for those who don't have it - contributed by +C.A. Lademann +Corrections by richard.kettlewell@kewill.com +********************************************************************/ + +#define MINUTE 60 +#define HOUR 60*MINUTE +#define DAY 24*HOUR +#define YEAR 365*DAY + time_t mktime(struct tm *t) +{ + struct tm *u; + time_t epoch = 0; + int n; + int mon [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, + y, m, i; + + if(t->tm_year < 70) + return((time_t)-1); + + n = t->tm_year + 1900 - 1; + epoch = (t->tm_year - 70) * YEAR + + ((n / 4 - n / 100 + n / 400) - (1969 / 4 - 1969 / 100 + 1969 / 400)) * DAY; + + y = t->tm_year + 1900; + m = 0; + + for(i = 0; i < t->tm_mon; i++) { + epoch += mon [m] * DAY; + if(m == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) + epoch += DAY; + + if(++m > 11) { + m = 0; + y++; + } + } + + epoch += (t->tm_mday - 1) * DAY; + epoch += t->tm_hour * HOUR + t->tm_min * MINUTE + t->tm_sec; + + if((u = localtime(&epoch)) != NULL) { + t->tm_sec = u->tm_sec; + t->tm_min = u->tm_min; + t->tm_hour = u->tm_hour; + t->tm_mday = u->tm_mday; + t->tm_mon = u->tm_mon; + t->tm_year = u->tm_year; + t->tm_wday = u->tm_wday; + t->tm_yday = u->tm_yday; + t->tm_isdst = u->tm_isdst; + } + + return(epoch); +} +#endif /* !HAVE_MKTIME */ + + + +#ifndef HAVE_RENAME +/* Rename a file. (from libiberty in GNU binutils) */ + int rename(const char *zfrom, const char *zto) +{ + if (link (zfrom, zto) < 0) + { + if (errno != EEXIST) + return -1; + if (unlink (zto) < 0 + || link (zfrom, zto) < 0) + return -1; + } + return unlink (zfrom); +} +#endif /* HAVE_RENAME */ + + +#ifndef HAVE_INNETGR +#if defined(HAVE_SETNETGRENT) && defined(HAVE_GETNETGRENT) && defined(HAVE_ENDNETGRENT) +/* + * Search for a match in a netgroup. This replaces it on broken systems. + */ + int innetgr(const char *group,const char *host,const char *user,const char *dom) +{ + char *hst, *usr, *dm; + + setnetgrent(group); + while (getnetgrent(&hst, &usr, &dm)) { + if (((host == 0) || (hst == 0) || !strcmp(host, hst)) && + ((user == 0) || (usr == 0) || !strcmp(user, usr)) && + ((dom == 0) || (dm == 0) || !strcmp(dom, dm))) { + endnetgrent(); + return (1); + } + } + endnetgrent(); + return (0); +} +#endif /* HAVE_SETNETGRENT HAVE_GETNETGRENT HAVE_ENDNETGRENT */ +#endif /* HAVE_INNETGR */ + + + +#ifndef HAVE_INITGROUPS +/**************************************************************************** + some systems don't have an initgroups call +****************************************************************************/ + int initgroups(char *name,gid_t id) +{ +#ifndef HAVE_SETGROUPS + static int done; + if (!done) { + DEBUG(1,("WARNING: running without setgroups\n")); + done=1; + } + /* yikes! no SETGROUPS or INITGROUPS? how can this work? */ + return(0); +#else /* HAVE_SETGROUPS */ + gid_t *grouplst = NULL; + int max_gr = groups_max(); + int ret; + int i,j; + struct group *g; + char *gr; + + if((grouplst = malloc_array_p(gid_t, max_gr)) == NULL) { + DEBUG(0,("initgroups: malloc fail !\n")); + return -1; + } + + grouplst[0] = id; + i = 1; + while (i < max_gr && ((g = (struct group *)getgrent()) != (struct group *)NULL)) { + if (g->gr_gid == id) + continue; + j = 0; + gr = g->gr_mem[0]; + while (gr && (*gr != (char)NULL)) { + if (strcmp(name,gr) == 0) { + grouplst[i] = g->gr_gid; + i++; + gr = (char *)NULL; + break; + } + gr = g->gr_mem[++j]; + } + } + endgrent(); + ret = sys_setgroups(i,grouplst); + SAFE_FREE(grouplst); + return ret; +#endif /* HAVE_SETGROUPS */ +} +#endif /* HAVE_INITGROUPS */ + + +#if (defined(SecureWare) && defined(SCO)) +/* This is needed due to needing the nap() function but we don't want + to include the Xenix libraries since that will break other things... + BTW: system call # 0x0c28 is the same as calling nap() */ + long nap(long milliseconds) { + return syscall(0x0c28, milliseconds); + } +#endif + + +#ifndef HAVE_MEMMOVE +/******************************************************************* +safely copies memory, ensuring no overlap problems. +this is only used if the machine does not have it's own memmove(). +this is not the fastest algorithm in town, but it will do for our +needs. +********************************************************************/ + void *memmove(void *dest,const void *src,int size) +{ + unsigned long d,s; + int i; + if (dest==src || !size) return(dest); + + d = (unsigned long)dest; + s = (unsigned long)src; + + if ((d >= (s+size)) || (s >= (d+size))) { + /* no overlap */ + memcpy(dest,src,size); + return(dest); + } + + if (d < s) { + /* we can forward copy */ + if (s-d >= sizeof(int) && + !(s%sizeof(int)) && + !(d%sizeof(int)) && + !(size%sizeof(int))) { + /* do it all as words */ + int *idest = (int *)dest; + int *isrc = (int *)src; + size /= sizeof(int); + for (i=0;i= sizeof(int) && + !(s%sizeof(int)) && + !(d%sizeof(int)) && + !(size%sizeof(int))) { + /* do it all as words */ + int *idest = (int *)dest; + int *isrc = (int *)src; + size /= sizeof(int); + for (i=size-1;i>=0;i--) idest[i] = isrc[i]; + } else { + /* simplest */ + char *cdest = (char *)dest; + char *csrc = (char *)src; + for (i=size-1;i>=0;i--) cdest[i] = csrc[i]; + } + } + return(dest); +} +#endif /* HAVE_MEMMOVE */ + +#ifndef HAVE_STRDUP +/**************************************************************************** +duplicate a string +****************************************************************************/ + char *strdup(const char *s) +{ + size_t len; + char *ret; + + if (!s) return(NULL); + + len = strlen(s)+1; + ret = (char *)malloc(len); + if (!ret) return(NULL); + memcpy(ret,s,len); + return(ret); +} +#endif /* HAVE_STRDUP */ + +#ifndef WITH_PTHREADS +/* REWRITE: not thread safe */ +#ifdef REPLACE_INET_NTOA + char *rep_inet_ntoa(struct in_addr ip) +{ + uint8_t *p = (uint8_t *)&ip.s_addr; + static char buf[18]; + slprintf(buf, 17, "%d.%d.%d.%d", + (int)p[0], (int)p[1], (int)p[2], (int)p[3]); + return buf; +} +#endif /* REPLACE_INET_NTOA */ +#endif + +#ifndef HAVE_STRTOUL +#ifndef ULONG_MAX +#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */ +#endif + +/* + * Convert a string to an unsigned long integer. + * Taken from libg++ - libiberty code. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ + unsigned long strtoul(const char *nptr, char **endptr, int base) +{ + const char *s = nptr; + unsigned long acc; + int c; + unsigned long cutoff; + int neg = 0, any, cutlim; + + /* + * See strtol for comments as to the logic used. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; + cutlim = (int)((unsigned long)ULONG_MAX % (unsigned long)base); + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = ULONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} +#endif /* HAVE_STRTOUL */ + +#ifndef HAVE_SETLINEBUF + int setlinebuf(FILE *stream) +{ + return setvbuf(stream, (char *)NULL, _IOLBF, 0); +} +#endif /* HAVE_SETLINEBUF */ + +#ifndef HAVE_VSYSLOG +#ifdef HAVE_SYSLOG + void vsyslog (int facility_priority, char *format, va_list arglist) +{ + char *msg = NULL; + vasprintf(&msg, format, arglist); + if (!msg) + return; + syslog(facility_priority, "%s", msg); + SAFE_FREE(msg); +} +#endif /* HAVE_SYSLOG */ +#endif /* HAVE_VSYSLOG */ + +/******************************************************************* +yield the difference between *A and *B, in seconds, ignoring leap seconds +********************************************************************/ +static int tm_diff(struct tm *a, struct tm *b) +{ + int ay = a->tm_year + (1900 - 1); + int by = b->tm_year + (1900 - 1); + int intervening_leap_days = + (ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400); + int years = ay - by; + int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday); + int hours = 24*days + (a->tm_hour - b->tm_hour); + int minutes = 60*hours + (a->tm_min - b->tm_min); + int seconds = 60*minutes + (a->tm_sec - b->tm_sec); + + return seconds; +} + +/******************************************************************* + return the UTC offset in seconds west of UTC, or 0 if it cannot be determined + ******************************************************************/ +int get_time_zone(time_t t) +{ + struct tm *tm = gmtime(&t); + struct tm tm_utc; + if (!tm) + return 0; + tm_utc = *tm; + tm = localtime(&t); + if (!tm) + return 0; + return tm_diff(&tm_utc,tm); +} + +#ifndef HAVE_TIMEGM +/* + yes, I know this looks insane, but its really needed. The function in the + Linux timegm() manpage does not work on solaris. +*/ + time_t timegm(struct tm *tm) +{ + struct tm tm2, tm3; + time_t t; + + tm2 = *tm; + + t = mktime(&tm2); + tm3 = *localtime(&t); + tm2 = *tm; + tm2.tm_isdst = tm3.tm_isdst; + t = mktime(&tm2); + t -= get_time_zone(t); + + return t; +} +#endif + +#ifndef HAVE_SETENV + int setenv(const char *name, const char *value, int overwrite) +{ + char *p = NULL; + int ret = -1; + + asprintf(&p, "%s=%s", name, value); + + if (overwrite || getenv(name)) { + if (p) ret = putenv(p); + } else { + ret = 0; + } + + return ret; +} +#endif + + +#ifndef HAVE_STRTOULL + unsigned long long int strtoull(const char *str, char **endptr, int base) +{ +#ifdef HAVE_STRTOUQ + return strtouq(str, endptr, base); +#else +#error "system must support 64 bit integer read from strings" +#endif +} +#endif + + +#ifndef HAVE_STRNDUP +/** + Some platforms don't have strndup. +**/ + char *strndup(const char *s, size_t n) +{ + char *ret; + + n = strnlen(s, n); + ret = malloc(n+1); + if (!ret) + return NULL; + memcpy(ret, s, n); + ret[n] = 0; + + return ret; +} +#endif + +#ifndef HAVE_STRNLEN +/** + Some platforms don't have strnlen +**/ + size_t strnlen(const char *s, size_t n) +{ + int i; + for (i=0; s[i] && i 9/15/96 for mutt 0.43 + * This was ugly. It is still ugly. I opted out of floating point + * numbers, but the formatter understands just about everything + * from the normal C string format, at least as far as I can tell from + * the Solaris 2.5 printf(3S) man page. + * + * Brandon Long 10/22/97 for mutt 0.87.1 + * Ok, added some minimal floating point support, which means this + * probably requires libm on most operating systems. Don't yet + * support the exponent (e,E) and sigfig (g,G). Also, fmtint() + * was pretty badly broken, it just wasn't being exercised in ways + * which showed it, so that's been fixed. Also, formated the code + * to mutt conventions, and removed dead code left over from the + * original. Also, there is now a builtin-test, just compile with: + * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm + * and run snprintf for results. + * + * Thomas Roessler 01/27/98 for mutt 0.89i + * The PGP code was using unsigned hexadecimal formats. + * Unfortunately, unsigned formats simply didn't work. + * + * Michael Elkins 03/05/98 for mutt 0.90.8 + * The original code assumed that both snprintf() and vsnprintf() were + * missing. Some systems only have snprintf() but not vsnprintf(), so + * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF. + * + * Andrew Tridgell (tridge@samba.org) Oct 1998 + * fixed handling of %.0f + * added test for HAVE_LONG_DOUBLE + * + * tridge@samba.org, idra@samba.org, April 2001 + * got rid of fcvt code (twas buggy and made testing harder) + * added C99 semantics + * + **************************************************************/ + +#ifndef NO_CONFIG_H /* for some tests */ +#include "config.h" +#else +#define NULL 0 +#endif + +#ifdef TEST_SNPRINTF /* need math library headers for testing */ +#include +#endif + +#ifdef HAVE_STRING_H +#include +#endif + +#ifdef HAVE_STRINGS_H +#include +#endif +#ifdef HAVE_CTYPE_H +#include +#endif +#include +#include +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifndef VA_COPY +#ifdef HAVE_VA_COPY +#define VA_COPY(dest, src) va_copy(dest, src) +#elif defined(HAVE___VA_COPY) +#define VA_COPY(dest, src) __va_copy(dest, src) +#else +#define VA_COPY(dest, src) (dest) = (src) +#endif +#endif + + +#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF) +/* only include stdio.h if we are not re-defining snprintf or vsnprintf */ +#include + /* make the compiler happy with an empty file */ + void dummy_snprintf(void) {} +#else + +#ifdef HAVE_LONG_DOUBLE +#define LDOUBLE long double +#else +#define LDOUBLE double +#endif + +#ifdef HAVE_LONG_LONG +#define LLONG long long +#else +#define LLONG long +#endif + +/* free memory if the pointer is valid and zero the pointer */ +#ifndef SAFE_FREE +#define SAFE_FREE(x) do { if ((x) != NULL) {free((x)); (x)=NULL;} } while(0) +#endif + +static size_t dopr(char *buffer, size_t maxlen, const char *format, + va_list args_in); +static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max); +static void fmtint(char *buffer, size_t *currlen, size_t maxlen, + long value, int base, int min, int max, int flags); +static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags); +static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); + +/* + * dopr(): poor man's version of doprintf + */ + +/* format read states */ +#define DP_S_DEFAULT 0 +#define DP_S_FLAGS 1 +#define DP_S_MIN 2 +#define DP_S_DOT 3 +#define DP_S_MAX 4 +#define DP_S_MOD 5 +#define DP_S_CONV 6 +#define DP_S_DONE 7 + +/* format flags - Bits */ +#define DP_F_MINUS (1 << 0) +#define DP_F_PLUS (1 << 1) +#define DP_F_SPACE (1 << 2) +#define DP_F_NUM (1 << 3) +#define DP_F_ZERO (1 << 4) +#define DP_F_UP (1 << 5) +#define DP_F_UNSIGNED (1 << 6) + +/* Conversion Flags */ +#define DP_C_SHORT 1 +#define DP_C_LONG 2 +#define DP_C_LDOUBLE 3 +#define DP_C_LLONG 4 + +#define char_to_int(p) ((p)- '0') +#ifndef MAX +#define MAX(p,q) (((p) >= (q)) ? (p) : (q)) +#endif + +static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args_in) +{ + char ch; + LLONG value; + LDOUBLE fvalue; + char *strvalue; + int min; + int max; + int state; + int flags; + int cflags; + size_t currlen; + va_list args; + + VA_COPY(args, args_in); + + state = DP_S_DEFAULT; + currlen = flags = cflags = min = 0; + max = -1; + ch = *format++; + + while (state != DP_S_DONE) { + if (ch == '\0') + state = DP_S_DONE; + + switch(state) { + case DP_S_DEFAULT: + if (ch == '%') + state = DP_S_FLAGS; + else + dopr_outch (buffer, &currlen, maxlen, ch); + ch = *format++; + break; + case DP_S_FLAGS: + switch (ch) { + case '-': + flags |= DP_F_MINUS; + ch = *format++; + break; + case '+': + flags |= DP_F_PLUS; + ch = *format++; + break; + case ' ': + flags |= DP_F_SPACE; + ch = *format++; + break; + case '#': + flags |= DP_F_NUM; + ch = *format++; + break; + case '0': + flags |= DP_F_ZERO; + ch = *format++; + break; + default: + state = DP_S_MIN; + break; + } + break; + case DP_S_MIN: + if (isdigit((unsigned char)ch)) { + min = 10*min + char_to_int (ch); + ch = *format++; + } else if (ch == '*') { + min = va_arg (args, int); + ch = *format++; + state = DP_S_DOT; + } else { + state = DP_S_DOT; + } + break; + case DP_S_DOT: + if (ch == '.') { + state = DP_S_MAX; + ch = *format++; + } else { + state = DP_S_MOD; + } + break; + case DP_S_MAX: + if (isdigit((unsigned char)ch)) { + if (max < 0) + max = 0; + max = 10*max + char_to_int (ch); + ch = *format++; + } else if (ch == '*') { + max = va_arg (args, int); + ch = *format++; + state = DP_S_MOD; + } else { + state = DP_S_MOD; + } + break; + case DP_S_MOD: + switch (ch) { + case 'h': + cflags = DP_C_SHORT; + ch = *format++; + break; + case 'l': + cflags = DP_C_LONG; + ch = *format++; + if (ch == 'l') { /* It's a long long */ + cflags = DP_C_LLONG; + ch = *format++; + } + break; + case 'L': + cflags = DP_C_LDOUBLE; + ch = *format++; + break; + default: + break; + } + state = DP_S_CONV; + break; + case DP_S_CONV: + switch (ch) { + case 'd': + case 'i': + if (cflags == DP_C_SHORT) + value = va_arg (args, int); + else if (cflags == DP_C_LONG) + value = va_arg (args, long int); + else if (cflags == DP_C_LLONG) + value = va_arg (args, LLONG); + else + value = va_arg (args, int); + fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'o': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned int); + else if (cflags == DP_C_LONG) + value = (long)va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = (long)va_arg (args, unsigned LLONG); + else + value = (long)va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); + break; + case 'u': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned int); + else if (cflags == DP_C_LONG) + value = (long)va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = (LLONG)va_arg (args, unsigned LLONG); + else + value = (long)va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'X': + flags |= DP_F_UP; + case 'x': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned int); + else if (cflags == DP_C_LONG) + value = (long)va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = (LLONG)va_arg (args, unsigned LLONG); + else + value = (long)va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); + break; + case 'f': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + /* um, floating point? */ + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + break; + case 'E': + flags |= DP_F_UP; + case 'e': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + break; + case 'G': + flags |= DP_F_UP; + case 'g': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + break; + case 'c': + dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); + break; + case 's': + strvalue = va_arg (args, char *); + if (!strvalue) strvalue = "(NULL)"; + if (max == -1) { + max = strlen(strvalue); + } + if (min > 0 && max >= 0 && min > max) max = min; + fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); + break; + case 'p': + strvalue = va_arg (args, void *); + fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); + break; + case 'n': + if (cflags == DP_C_SHORT) { + short int *num; + num = va_arg (args, short int *); + *num = currlen; + } else if (cflags == DP_C_LONG) { + long int *num; + num = va_arg (args, long int *); + *num = (long int)currlen; + } else if (cflags == DP_C_LLONG) { + LLONG *num; + num = va_arg (args, LLONG *); + *num = (LLONG)currlen; + } else { + int *num; + num = va_arg (args, int *); + *num = currlen; + } + break; + case '%': + dopr_outch (buffer, &currlen, maxlen, ch); + break; + case 'w': + /* not supported yet, treat as next char */ + ch = *format++; + break; + default: + /* Unknown, skip */ + break; + } + ch = *format++; + state = DP_S_DEFAULT; + flags = cflags = min = 0; + max = -1; + break; + case DP_S_DONE: + break; + default: + /* hmm? */ + break; /* some picky compilers need this */ + } + } + if (maxlen != 0) { + if (currlen < maxlen - 1) + buffer[currlen] = '\0'; + else if (maxlen > 0) + buffer[maxlen - 1] = '\0'; + } + + return currlen; +} + +static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max) +{ + int padlen, strln; /* amount to pad */ + int cnt = 0; + +#ifdef DEBUG_SNPRINTF + printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value); +#endif + if (value == 0) { + value = ""; + } + + for (strln = 0; value[strln]; ++strln); /* strlen */ + padlen = min - strln; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; /* Left Justify */ + + while ((padlen > 0) && (cnt < max)) { + dopr_outch (buffer, currlen, maxlen, ' '); + --padlen; + ++cnt; + } + while (*value && (cnt < max)) { + dopr_outch (buffer, currlen, maxlen, *value++); + ++cnt; + } + while ((padlen < 0) && (cnt < max)) { + dopr_outch (buffer, currlen, maxlen, ' '); + ++padlen; + ++cnt; + } +} + +/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ + +static void fmtint(char *buffer, size_t *currlen, size_t maxlen, + long value, int base, int min, int max, int flags) +{ + int signvalue = 0; + unsigned long uvalue; + char convert[20]; + int place = 0; + int spadlen = 0; /* amount to space pad */ + int zpadlen = 0; /* amount to zero pad */ + int caps = 0; + + if (max < 0) + max = 0; + + uvalue = value; + + if(!(flags & DP_F_UNSIGNED)) { + if( value < 0 ) { + signvalue = '-'; + uvalue = -value; + } else { + if (flags & DP_F_PLUS) /* Do a sign (+/i) */ + signvalue = '+'; + else if (flags & DP_F_SPACE) + signvalue = ' '; + } + } + + if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ + + do { + convert[place++] = + (caps? "0123456789ABCDEF":"0123456789abcdef") + [uvalue % (unsigned)base ]; + uvalue = (uvalue / (unsigned)base ); + } while(uvalue && (place < 20)); + if (place == 20) place--; + convert[place] = 0; + + zpadlen = max - place; + spadlen = min - MAX (max, place) - (signvalue ? 1 : 0); + if (zpadlen < 0) zpadlen = 0; + if (spadlen < 0) spadlen = 0; + if (flags & DP_F_ZERO) { + zpadlen = MAX(zpadlen, spadlen); + spadlen = 0; + } + if (flags & DP_F_MINUS) + spadlen = -spadlen; /* Left Justifty */ + +#ifdef DEBUG_SNPRINTF + printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n", + zpadlen, spadlen, min, max, place); +#endif + + /* Spaces */ + while (spadlen > 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + --spadlen; + } + + /* Sign */ + if (signvalue) + dopr_outch (buffer, currlen, maxlen, signvalue); + + /* Zeros */ + if (zpadlen > 0) { + while (zpadlen > 0) { + dopr_outch (buffer, currlen, maxlen, '0'); + --zpadlen; + } + } + + /* Digits */ + while (place > 0) + dopr_outch (buffer, currlen, maxlen, convert[--place]); + + /* Left Justified spaces */ + while (spadlen < 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + ++spadlen; + } +} + +static LDOUBLE abs_val(LDOUBLE value) +{ + LDOUBLE result = value; + + if (value < 0) + result = -value; + + return result; +} + +static LDOUBLE POW10(int exp) +{ + LDOUBLE result = 1; + + while (exp) { + result *= 10; + exp--; + } + + return result; +} + +static LLONG ROUND(LDOUBLE value) +{ + LLONG intpart; + + intpart = (LLONG)value; + value = value - intpart; + if (value >= 0.5) intpart++; + + return intpart; +} + +/* a replacement for modf that doesn't need the math library. Should + be portable, but slow */ +static double my_modf(double x0, double *iptr) +{ + int i; + long l; + double x = x0; + double f = 1.0; + + for (i=0;i<100;i++) { + l = (long)x; + if (l <= (x+1) && l >= (x-1)) break; + x *= 0.1; + f *= 10.0; + } + + if (i == 100) { + /* yikes! the number is beyond what we can handle. What do we do? */ + (*iptr) = 0; + return 0; + } + + if (i != 0) { + double i2; + double ret; + + ret = my_modf(x0-l*f, &i2); + (*iptr) = l*f + i2; + return ret; + } + + (*iptr) = l; + return x - (*iptr); +} + + +static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags) +{ + int signvalue = 0; + double ufvalue; + char iconvert[311]; + char fconvert[311]; + int iplace = 0; + int fplace = 0; + int padlen = 0; /* amount to pad */ + int zpadlen = 0; + int caps = 0; + int index; + double intpart; + double fracpart; + double temp; + + /* + * AIX manpage says the default is 0, but Solaris says the default + * is 6, and sprintf on AIX defaults to 6 + */ + if (max < 0) + max = 6; + + ufvalue = abs_val (fvalue); + + if (fvalue < 0) { + signvalue = '-'; + } else { + if (flags & DP_F_PLUS) { /* Do a sign (+/i) */ + signvalue = '+'; + } else { + if (flags & DP_F_SPACE) + signvalue = ' '; + } + } + +#if 0 + if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ +#endif + +#if 0 + if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */ +#endif + + /* + * Sorry, we only support 16 digits past the decimal because of our + * conversion method + */ + if (max > 16) + max = 16; + + /* We "cheat" by converting the fractional part to integer by + * multiplying by a factor of 10 + */ + + temp = ufvalue; + my_modf(temp, &intpart); + + fracpart = ROUND((POW10(max)) * (ufvalue - intpart)); + + if (fracpart >= POW10(max)) { + intpart++; + fracpart -= POW10(max); + } + + + /* Convert integer part */ + do { + temp = intpart*0.1; + my_modf(temp, &intpart); + index = (int) ((temp -intpart +0.05)* 10.0); + /* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */ + /* printf ("%llf, %f, %x\n", temp, intpart, index); */ + iconvert[iplace++] = + (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; + } while (intpart && (iplace < 311)); + if (iplace == 311) iplace--; + iconvert[iplace] = 0; + + /* Convert fractional part */ + if (fracpart) + { + do { + temp = fracpart*0.1; + my_modf(temp, &fracpart); + index = (int) ((temp -fracpart +0.05)* 10.0); + /* index = (int) ((((temp/10) -fracpart) +0.05) *10); */ + /* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */ + fconvert[fplace++] = + (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; + } while(fracpart && (fplace < 311)); + if (fplace == 311) fplace--; + } + fconvert[fplace] = 0; + + /* -1 for decimal point, another -1 if we are printing a sign */ + padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); + zpadlen = max - fplace; + if (zpadlen < 0) zpadlen = 0; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; /* Left Justifty */ + + if ((flags & DP_F_ZERO) && (padlen > 0)) { + if (signvalue) { + dopr_outch (buffer, currlen, maxlen, signvalue); + --padlen; + signvalue = 0; + } + while (padlen > 0) { + dopr_outch (buffer, currlen, maxlen, '0'); + --padlen; + } + } + while (padlen > 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + --padlen; + } + if (signvalue) + dopr_outch (buffer, currlen, maxlen, signvalue); + + while (iplace > 0) + dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); + +#ifdef DEBUG_SNPRINTF + printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen); +#endif + + /* + * Decimal point. This should probably use locale to find the correct + * char to print out. + */ + if (max > 0) { + dopr_outch (buffer, currlen, maxlen, '.'); + + while (zpadlen > 0) { + dopr_outch (buffer, currlen, maxlen, '0'); + --zpadlen; + } + + while (fplace > 0) + dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); + } + + while (padlen < 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + ++padlen; + } +} + +static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) +{ + if (*currlen < maxlen) { + buffer[(*currlen)] = c; + } + (*currlen)++; +} + +/* yes this really must be a ||. Don't muck with this (tridge) */ +#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) + int vsnprintf (char *str, size_t count, const char *fmt, va_list args) +{ + return dopr(str, count, fmt, args); +} +#endif + +/* yes this really must be a ||. Don't muck wiith this (tridge) + * + * The logic for these two is that we need our own definition if the + * OS *either* has no definition of *sprintf, or if it does have one + * that doesn't work properly according to the autoconf test. Perhaps + * these should really be smb_snprintf to avoid conflicts with buggy + * linkers? -- mbp + */ +#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_SNPRINTF) + int snprintf(char *str,size_t count,const char *fmt,...) +{ + size_t ret; + va_list ap; + + va_start(ap, fmt); + ret = vsnprintf(str, count, fmt, ap); + va_end(ap); + return ret; +} +#endif + +#endif + +#ifndef HAVE_VASPRINTF + int vasprintf(char **ptr, const char *format, va_list ap) +{ + int ret; + va_list ap2; + + VA_COPY(ap2, ap); + + ret = vsnprintf(NULL, 0, format, ap2); + if (ret <= 0) return ret; + + (*ptr) = (char *)malloc(ret+1); + if (!*ptr) return -1; + + VA_COPY(ap2, ap); + + ret = vsnprintf(*ptr, ret+1, format, ap2); + + return ret; +} +#endif + + +#ifndef HAVE_ASPRINTF + int asprintf(char **ptr, const char *format, ...) +{ + va_list ap; + int ret; + + *ptr = NULL; + va_start(ap, format); + ret = vasprintf(ptr, format, ap); + va_end(ap); + + return ret; +} +#endif + +#ifdef TEST_SNPRINTF + + int sprintf(char *str,const char *fmt,...); + + int main (void) +{ + char buf1[1024]; + char buf2[1024]; + char *fp_fmt[] = { + "%1.1f", + "%-1.5f", + "%1.5f", + "%123.9f", + "%10.5f", + "% 10.5f", + "%+22.9f", + "%+4.9f", + "%01.3f", + "%4f", + "%3.1f", + "%3.2f", + "%.0f", + "%f", + "-16.16f", + NULL + }; + double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, + 0.9996, 1.996, 4.136, 5.030201, 0}; + char *int_fmt[] = { + "%-1.5d", + "%1.5d", + "%123.9d", + "%5.5d", + "%10.5d", + "% 10.5d", + "%+22.33d", + "%01.3d", + "%4d", + "%d", + NULL + }; + long int_nums[] = { -1, 134, 91340, 341, 0203, 0}; + char *str_fmt[] = { + "10.5s", + "5.10s", + "10.1s", + "0.10s", + "10.0s", + "1.10s", + "%s", + "%.1s", + "%.10s", + "%10s", + NULL + }; + char *str_vals[] = {"hello", "a", "", "a longer string", NULL}; + int x, y; + int fail = 0; + int num = 0; + + printf ("Testing snprintf format codes against system sprintf...\n"); + + for (x = 0; fp_fmt[x] ; x++) { + for (y = 0; fp_nums[y] != 0 ; y++) { + int l1 = snprintf(NULL, 0, fp_fmt[x], fp_nums[y]); + int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]); + sprintf (buf2, fp_fmt[x], fp_nums[y]); + if (strcmp (buf1, buf2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", + fp_fmt[x], buf1, buf2); + fail++; + } + if (l1 != l2) { + printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, fp_fmt[x]); + fail++; + } + num++; + } + } + + for (x = 0; int_fmt[x] ; x++) { + for (y = 0; int_nums[y] != 0 ; y++) { + int l1 = snprintf(NULL, 0, int_fmt[x], int_nums[y]); + int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]); + sprintf (buf2, int_fmt[x], int_nums[y]); + if (strcmp (buf1, buf2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", + int_fmt[x], buf1, buf2); + fail++; + } + if (l1 != l2) { + printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, int_fmt[x]); + fail++; + } + num++; + } + } + + for (x = 0; str_fmt[x] ; x++) { + for (y = 0; str_vals[y] != 0 ; y++) { + int l1 = snprintf(NULL, 0, str_fmt[x], str_vals[y]); + int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]); + sprintf (buf2, str_fmt[x], str_vals[y]); + if (strcmp (buf1, buf2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", + str_fmt[x], buf1, buf2); + fail++; + } + if (l1 != l2) { + printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, str_fmt[x]); + fail++; + } + num++; + } + } + + printf ("%d tests failed out of %d.\n", fail, num); + + printf("seeing how many digits we support\n"); + { + double v0 = 0.12345678901234567890123456789012345678901; + for (x=0; x<100; x++) { + double p = pow(10, x); + double r = v0*p; + snprintf(buf1, sizeof(buf1), "%1.1f", r); + sprintf(buf2, "%1.1f", r); + if (strcmp(buf1, buf2)) { + printf("we seem to support %d digits\n", x-1); + break; + } + } + } + + return 0; +} +#endif /* SNPRINTF_TEST */ -- cgit From bce8cda06123648c377fbef92526f1f56121e513 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 7 Jun 2005 07:22:25 +0000 Subject: r7352: the internal heimdal build change. This changes quite a few things: - if you want kerberos now, you need to unpack a lorikeet heimdal tree in source/heimdal/. If source/heimdal/ does not exist at configure time then all kerberos features are disabled. You cannot use an external kerberos library for now. That may change later. - moved lib/replace/ config stuff to lib/replace/ and create a lib/replace/replace.h. That allows the heimdal build to use our portability layer, and prevenets duplicate definitions of functions like strlcat() - if you do enable heimdal, then you will need to do 'make HEIMDAL_EXTERNAL' before you build Samba. That should be fixed once I explain the problem to jelmer (the problem is the inability to set a depend without also dragging in the object list of the dependency. We need this for building the heimdal asn1 compiler and et compiler. - disabled all of the m4 checks for external kerberos libraries. I left them in place in auth/kerberos/, but disabled it in configure.in some of the heimdal_build/ code is still very rough, for example I don't correctly detect the correct awk, flex, bison replacements for heimdal_build/build_external.sh. I expect to fix that stuff up over the next few days. (This used to be commit d4648249b2c7fc8b5e7c0fc8d8f92ae043b5691f) --- source4/lib/replace/config.mk | 9 ++++ source4/lib/replace/replace.h | 114 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 source4/lib/replace/config.mk create mode 100644 source4/lib/replace/replace.h (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk new file mode 100644 index 0000000000..bd60402ba3 --- /dev/null +++ b/source4/lib/replace/config.mk @@ -0,0 +1,9 @@ +############################## +# Start SUBSYSTEM LIBREPLACE +[SUBSYSTEM::LIBREPLACE] +INIT_OBJ_FILES = lib/replace/replace.o +ADD_OBJ_FILES = \ + lib/replace/snprintf.o +# End SUBSYSTEM LIBREPLACE +############################## + diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h new file mode 100644 index 0000000000..e0cb1420ec --- /dev/null +++ b/source4/lib/replace/replace.h @@ -0,0 +1,114 @@ +/* + Unix SMB/CIFS implementation. + + macros to go along with the lib/replace/ portability layer code + + Copyright (C) Andrew Tridgell 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef _replace_h +#define _replace_h + +#ifdef __COMPAR_FN_T +#define QSORT_CAST (__compar_fn_t) +#endif + +#ifndef QSORT_CAST +#define QSORT_CAST (int (*)(const void *, const void *)) +#endif + +#ifndef HAVE_STRDUP +char *strdup(const char *s); +#endif + +#ifndef HAVE_MEMMOVE +void *memmove(void *dest,const void *src,int size); +#endif + +#ifndef HAVE_MKTIME +time_t mktime(struct tm *t); +#endif + +#ifndef HAVE_STRLCPY +size_t strlcpy(char *d, const char *s, size_t bufsize); +#endif + +#ifndef HAVE_STRLCAT +size_t strlcat(char *d, const char *s, size_t bufsize); +#endif + +#ifndef HAVE_STRNDUP +char *strndup(const char *s, size_t n); +#endif + +#ifndef HAVE_STRNLEN +size_t strnlen(const char *s, size_t n); +#endif + +#ifndef HAVE_STRTOUL +unsigned long strtoul(const char *nptr, char **endptr, int base); +#endif + +#ifndef HAVE_SETENV +int setenv(const char *name, const char *value, int overwrite); +#endif + +#ifndef HAVE_VASPRINTF_DECL +int vasprintf(char **ptr, const char *format, va_list ap); +#endif + +#if !defined(HAVE_BZERO) && defined(HAVE_MEMSET) +#define bzero(a,b) memset((a),'\0',(b)) +#endif + +/* add varargs prototypes with printf checking */ +#ifndef HAVE_SNPRINTF_DECL +int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4); +#endif +#ifndef HAVE_ASPRINTF_DECL +int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); +#endif + + +/* we used to use these fns, but now we have good replacements + for snprintf and vsnprintf */ +#define slprintf snprintf + + +#ifdef HAVE_VA_COPY +#define VA_COPY(dest, src) va_copy(dest, src) +#elif defined(HAVE___VA_COPY) +#define VA_COPY(dest, src) __va_copy(dest, src) +#else +#define VA_COPY(dest, src) (dest) = (src) +#endif + +#ifndef UINT16_MAX +#define UINT16_MAX 65535 +#endif + +#if defined(HAVE_VOLATILE) +#define VOLATILE volatile +#else +#define VOLATILE +#endif + +#ifndef HAVE_COMPARISON_FN_T +typedef int (*comparison_fn_t)(const void *, const void *); +#endif + +#endif -- cgit From 66a52992ff6a9f2f926249ac428d6fad72303637 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 23 Jun 2005 22:30:26 +0000 Subject: r7850: Support mkdir() with just one parameter. Patch from Steven Edwards . I've moved the Win32-specific tests to win32.m4 so it does not make any of the POSIX configure stuff more complicated. (This used to be commit bf85fdd01552f75b745fdf3159a7a87cd6521ed2) --- source4/lib/replace/win32.m4 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 source4/lib/replace/win32.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/win32.m4 b/source4/lib/replace/win32.m4 new file mode 100644 index 0000000000..6b9c4e6b13 --- /dev/null +++ b/source4/lib/replace/win32.m4 @@ -0,0 +1,20 @@ +AC_CHECK_HEADERS(direct.h) + +####################################### +# Check for mkdir mode +AC_CACHE_CHECK( [whether mkdir supports mode], ac_mkdir_has_mode, + AC_TRY_COMPILE([ + #include + #ifdef HAVE_DIRECT_H + #include + #endif],[ + mkdir("foo",0777); + return 0; + ], + ac_mkdir_has_mode="yes", + ac_mkdir_has_mode="no") ) + +if test "$ac_mkdir_has_mode" = "yes" +then + AC_DEFINE(HAVE_MKDIR_MODE, 1, [Define if target mkdir supports mode option]) +fi -- cgit From d5888fbb60d6b16b20ee95e434a94048ef1806bc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 24 Jun 2005 01:27:34 +0000 Subject: r7866: Remove some unused autoconf macro calls. Some of these should probably be re-added again later when we need them. They should then be added to the appropriate config.m4 file in the source tree rather then in rewrite.m4. (This used to be commit 4eca613470139f6425f454aea016566f9deffa3e) --- source4/lib/replace/win32.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/win32.m4 b/source4/lib/replace/win32.m4 index 6b9c4e6b13..9ac84cdf2a 100644 --- a/source4/lib/replace/win32.m4 +++ b/source4/lib/replace/win32.m4 @@ -1,4 +1,4 @@ -AC_CHECK_HEADERS(direct.h) +AC_CHECK_HEADERS(direct.h windows.h winsock2.h ws2tcpip.h) ####################################### # Check for mkdir mode -- cgit From 54ffd4fdbf470cb71cbf9a9c9e5aa37f73acc559 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Jul 2005 04:17:54 +0000 Subject: r8313: moved PRINTF_ATTRIBUTE to replace.h to try to get irix building with heimdal (This used to be commit 7d4e309f02cfcef661ebf3bbe9c227938318077c) --- source4/lib/replace/replace.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index e0cb1420ec..c7c343ef38 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -111,4 +111,16 @@ int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); typedef int (*comparison_fn_t)(const void *, const void *); #endif +#ifndef PRINTF_ATTRIBUTE +#if (__GNUC__ >= 3) +/** Use gcc attribute to check printf fns. a1 is the 1-based index of + * the parameter containing the format, and a2 the index of the first + * argument. Note that some gcc 2.x versions don't handle this + * properly **/ +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) +#else +#define PRINTF_ATTRIBUTE(a1, a2) +#endif +#endif + #endif -- cgit From 72fbfff1a7c11ac96ef3e7f80691f51856a87478 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Jul 2005 10:22:13 +0000 Subject: r8417: fixed handling of PRINTF_ATTRIBUTE for heimdal portion of build (This used to be commit 117d2fa31d3a7e0b37c09979aa41243c564c0385) --- source4/lib/replace/replace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index c7c343ef38..b67e629aa0 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -112,7 +112,7 @@ typedef int (*comparison_fn_t)(const void *, const void *); #endif #ifndef PRINTF_ATTRIBUTE -#if (__GNUC__ >= 3) +#if !defined(NO_PRINTF_ATTRIBUTE) && (__GNUC__ >= 3) /** Use gcc attribute to check printf fns. a1 is the 1-based index of * the parameter containing the format, and a2 the index of the first * argument. Note that some gcc 2.x versions don't handle this -- cgit From 12ed349f9025a4ca27f7399bb352c674af284ac4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Jul 2005 10:58:43 +0000 Subject: r8418: PRINTF_ATTRIBUTE declaration has to come before it is used :-) (This used to be commit a1ca8352f48cf1942e5a060c79ae1cc78b8a3668) --- source4/lib/replace/replace.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index b67e629aa0..8062c4c683 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -75,6 +75,18 @@ int vasprintf(char **ptr, const char *format, va_list ap); #define bzero(a,b) memset((a),'\0',(b)) #endif +#ifndef PRINTF_ATTRIBUTE +#if !defined(NO_PRINTF_ATTRIBUTE) && (__GNUC__ >= 3) +/** Use gcc attribute to check printf fns. a1 is the 1-based index of + * the parameter containing the format, and a2 the index of the first + * argument. Note that some gcc 2.x versions don't handle this + * properly **/ +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) +#else +#define PRINTF_ATTRIBUTE(a1, a2) +#endif +#endif + /* add varargs prototypes with printf checking */ #ifndef HAVE_SNPRINTF_DECL int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4); @@ -111,16 +123,4 @@ int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); typedef int (*comparison_fn_t)(const void *, const void *); #endif -#ifndef PRINTF_ATTRIBUTE -#if !defined(NO_PRINTF_ATTRIBUTE) && (__GNUC__ >= 3) -/** Use gcc attribute to check printf fns. a1 is the 1-based index of - * the parameter containing the format, and a2 the index of the first - * argument. Note that some gcc 2.x versions don't handle this - * properly **/ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#endif -#endif - #endif -- cgit From 2ea372afd98b133144ad897250bd89d2c2855b16 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Jul 2005 11:17:32 +0000 Subject: r8420: slowly getting my way through some more heimdal portability fixes (This used to be commit 59c3de6ca8b8e153e5cfd67da5f2afc2e23d36db) --- source4/lib/replace/replace.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 8062c4c683..89225d3d65 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -109,10 +109,6 @@ int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); #define VA_COPY(dest, src) (dest) = (src) #endif -#ifndef UINT16_MAX -#define UINT16_MAX 65535 -#endif - #if defined(HAVE_VOLATILE) #define VOLATILE volatile #else -- cgit From 84db0662071a6ab61ae21a5da35317d8aed55d75 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 13 Jul 2005 20:44:46 +0000 Subject: r8434: Win32 portability updates from Steven Edwards : - undefine anything in the win32 api or PSDK headers that Samba already defines - map BSD error codes to Winsock Error codes (This used to be commit d2ea6191259a28a32a1f4ffdff067b1a80e8dcc9) --- source4/lib/replace/win32.m4 | 20 ----- source4/lib/replace/win32/config.m4 | 20 +++++ source4/lib/replace/win32/replace.h | 143 ++++++++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+), 20 deletions(-) delete mode 100644 source4/lib/replace/win32.m4 create mode 100644 source4/lib/replace/win32/config.m4 create mode 100644 source4/lib/replace/win32/replace.h (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/win32.m4 b/source4/lib/replace/win32.m4 deleted file mode 100644 index 9ac84cdf2a..0000000000 --- a/source4/lib/replace/win32.m4 +++ /dev/null @@ -1,20 +0,0 @@ -AC_CHECK_HEADERS(direct.h windows.h winsock2.h ws2tcpip.h) - -####################################### -# Check for mkdir mode -AC_CACHE_CHECK( [whether mkdir supports mode], ac_mkdir_has_mode, - AC_TRY_COMPILE([ - #include - #ifdef HAVE_DIRECT_H - #include - #endif],[ - mkdir("foo",0777); - return 0; - ], - ac_mkdir_has_mode="yes", - ac_mkdir_has_mode="no") ) - -if test "$ac_mkdir_has_mode" = "yes" -then - AC_DEFINE(HAVE_MKDIR_MODE, 1, [Define if target mkdir supports mode option]) -fi diff --git a/source4/lib/replace/win32/config.m4 b/source4/lib/replace/win32/config.m4 new file mode 100644 index 0000000000..9ac84cdf2a --- /dev/null +++ b/source4/lib/replace/win32/config.m4 @@ -0,0 +1,20 @@ +AC_CHECK_HEADERS(direct.h windows.h winsock2.h ws2tcpip.h) + +####################################### +# Check for mkdir mode +AC_CACHE_CHECK( [whether mkdir supports mode], ac_mkdir_has_mode, + AC_TRY_COMPILE([ + #include + #ifdef HAVE_DIRECT_H + #include + #endif],[ + mkdir("foo",0777); + return 0; + ], + ac_mkdir_has_mode="yes", + ac_mkdir_has_mode="no") ) + +if test "$ac_mkdir_has_mode" = "yes" +then + AC_DEFINE(HAVE_MKDIR_MODE, 1, [Define if target mkdir supports mode option]) +fi diff --git a/source4/lib/replace/win32/replace.h b/source4/lib/replace/win32/replace.h new file mode 100644 index 0000000000..94fa140681 --- /dev/null +++ b/source4/lib/replace/win32/replace.h @@ -0,0 +1,143 @@ +#ifndef _WIN32_REPLACE_H +#define _WIN32_REPLACE_H + +/* Map BSD Socket errorcodes to the WSA errorcodes (if possible) */ + +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#define ECONNREFUSED WSAECONNREFUSED +#define EINPROGRESS WSAEINPROGRESS +#define EMSGSIZE WSAEMSGSIZE +#define ENOBUFS WSAENOBUFS +#define ENOTSOCK WSAENOTSOCK +#define ENETUNREACH WSAENETUNREACH +#define ENOPROTOOPT WSAENOPROTOOPT +#define ENOTCONN WSAENOTCONN +#define ENOTSUP 134 + +/* We undefine the following constants due to conflicts with the w32api headers + * and the Windows Platform SDK/DDK. + */ + +#undef interface + +#undef ERROR_INVALID_PARAMETER +#undef ERROR_INSUFFICIENT_BUFFER +#undef ERROR_INVALID_DATATYPE + +#undef FILE_GENERIC_READ +#undef FILE_GENERIC_WRITE +#undef FILE_GENERIC_EXECUTE +#undef FILE_ATTRIBUTE_READONLY +#undef FILE_ATTRIBUTE_HIDDEN +#undef FILE_ATTRIBUTE_SYSTEM +#undef FILE_ATTRIBUTE_DIRECTORY +#undef FILE_ATTRIBUTE_ARCHIVE +#undef FILE_ATTRIBUTE_DEVICE +#undef FILE_ATTRIBUTE_NORMAL +#undef FILE_ATTRIBUTE_TEMPORARY +#undef FILE_ATTRIBUTE_REPARSE_POINT +#undef FILE_ATTRIBUTE_COMPRESSED +#undef FILE_ATTRIBUTE_OFFLINE +#undef FILE_ATTRIBUTE_ENCRYPTED +#undef FILE_FLAG_WRITE_THROUGH +#undef FILE_FLAG_NO_BUFFERING +#undef FILE_FLAG_RANDOM_ACCESS +#undef FILE_FLAG_SEQUENTIAL_SCAN +#undef FILE_FLAG_DELETE_ON_CLOSE +#undef FILE_FLAG_BACKUP_SEMANTICS +#undef FILE_FLAG_POSIX_SEMANTICS +#undef FILE_TYPE_DISK +#undef FILE_TYPE_UNKNOWN +#undef FILE_CASE_SENSITIVE_SEARCH +#undef FILE_CASE_PRESERVED_NAMES +#undef FILE_UNICODE_ON_DISK +#undef FILE_PERSISTENT_ACLS +#undef FILE_FILE_COMPRESSION +#undef FILE_VOLUME_QUOTAS +#undef FILE_VOLUME_IS_COMPRESSED +#undef FILE_NOTIFY_CHANGE_DIR_NAME +#undef FILE_NOTIFY_CHANGE_ATTRIBUTES +#undef FILE_NOTIFY_CHANGE_SIZE +#undef FILE_NOTIFY_CHANGE_LAST_WRITE +#undef FILE_NOTIFY_CHANGE_LAST_ACCESS +#undef FILE_NOTIFY_CHANGE_CREATION +#undef FILE_NOTIFY_CHANGE_EA +#undef FILE_NOTIFY_CHANGE_SECURITY +#undef FILE_NOTIFY_CHANGE_FILE_NAME + +#undef PRINTER_ATTRIBUTE_QUEUED +#undef PRINTER_ATTRIBUTE_DIRECT +#undef PRINTER_ATTRIBUTE_DEFAULT +#undef PRINTER_ATTRIBUTE_SHARED +#undef PRINTER_ATTRIBUTE_NETWORK +#undef PRINTER_ATTRIBUTE_HIDDEN +#undef PRINTER_ATTRIBUTE_LOCAL +#undef PRINTER_ATTRIBUTE_ENABLE_DEVQ +#undef PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS +#undef PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST +#undef PRINTER_ATTRIBUTE_WORK_OFFLINE +#undef PRINTER_ATTRIBUTE_ENABLE_BIDI +#undef PRINTER_ATTRIBUTE_RAW_ONLY +#undef PRINTER_ATTRIBUTE_PUBLISHED +#undef PRINTER_ENUM_DEFAULT +#undef PRINTER_ENUM_LOCAL +#undef PRINTER_ENUM_CONNECTIONS +#undef PRINTER_ENUM_FAVORITE +#undef PRINTER_ENUM_NAME +#undef PRINTER_ENUM_REMOTE +#undef PRINTER_ENUM_SHARED +#undef PRINTER_ENUM_NETWORK +#undef PRINTER_ENUM_EXPAND +#undef PRINTER_ENUM_CONTAINER +#undef PRINTER_ENUM_ICON1 +#undef PRINTER_ENUM_ICON2 +#undef PRINTER_ENUM_ICON3 +#undef PRINTER_ENUM_ICON4 +#undef PRINTER_ENUM_ICON5 +#undef PRINTER_ENUM_ICON6 +#undef PRINTER_ENUM_ICON7 +#undef PRINTER_ENUM_ICON8 +#undef PRINTER_STATUS_PAUSED +#undef PRINTER_STATUS_ERROR +#undef PRINTER_STATUS_PENDING_DELETION +#undef PRINTER_STATUS_PAPER_JAM +#undef PRINTER_STATUS_PAPER_OUT +#undef PRINTER_STATUS_MANUAL_FEED +#undef PRINTER_STATUS_PAPER_PROBLEM +#undef PRINTER_STATUS_OFFLINE +#undef PRINTER_STATUS_IO_ACTIVE +#undef PRINTER_STATUS_BUSY +#undef PRINTER_STATUS_PRINTING +#undef PRINTER_STATUS_OUTPUT_BIN_FULL +#undef PRINTER_STATUS_NOT_AVAILABLE +#undef PRINTER_STATUS_WAITING +#undef PRINTER_STATUS_PROCESSING +#undef PRINTER_STATUS_INITIALIZING +#undef PRINTER_STATUS_WARMING_UP +#undef PRINTER_STATUS_TONER_LOW +#undef PRINTER_STATUS_NO_TONER +#undef PRINTER_STATUS_PAGE_PUNT +#undef PRINTER_STATUS_USER_INTERVENTION +#undef PRINTER_STATUS_OUT_OF_MEMORY +#undef PRINTER_STATUS_DOOR_OPEN +#undef PRINTER_STATUS_SERVER_UNKNOWN +#undef PRINTER_STATUS_POWER_SAVE + +#undef DWORD +#undef HKEY_CLASSES_ROOT +#undef HKEY_CURRENT_USER +#undef HKEY_LOCAL_MACHINE +#undef HKEY_USERS +#undef HKEY_PERFORMANCE_DATA +#undef HKEY_CURRENT_CONFIG +#undef HKEY_DYN_DATA +#undef REG_DWORD +#undef REG_QWORD + +#undef SERVICE_STATE_ALL + +#undef SE_GROUP_MANDATORY +#undef SE_GROUP_ENABLED_BY_DEFAULT +#undef SE_GROUP_ENABLED + +#endif /* _WIN32_REPLACE_H */ -- cgit From e1512846939abceae37f62b755aaf7006b64b0c7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 13 Jul 2005 21:54:34 +0000 Subject: r8437: Win32 doesn't have u_int*_t (This used to be commit 5b007037dfacc5e13141ca41241543ac11a567b6) --- source4/lib/replace/win32/replace.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/win32/replace.h b/source4/lib/replace/win32/replace.h index 94fa140681..2c6d0e1a3f 100644 --- a/source4/lib/replace/win32/replace.h +++ b/source4/lib/replace/win32/replace.h @@ -140,4 +140,7 @@ #undef SE_GROUP_ENABLED_BY_DEFAULT #undef SE_GROUP_ENABLED +typedef uint32_t u_int32_t; +typedef uint16_t u_int16_t; + #endif /* _WIN32_REPLACE_H */ -- cgit From af0574378b3e73ffe637618e2f504d58735d6543 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Jul 2005 06:36:19 +0000 Subject: r8450: more configure tests for solaris. It now builds some binaries, but fails in the ejs floating point code. (This used to be commit 30e1b6140e9f6246cb66eef7cf108d1ccf62bd40) --- source4/lib/replace/replace.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 89225d3d65..48e46ba18e 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -119,4 +119,16 @@ int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); typedef int (*comparison_fn_t)(const void *, const void *); #endif +#ifndef HAVE_U_INT32_T +typedef unsigned u_int32_t; +#endif + +#ifndef HAVE_U_INT16_T +typedef unsigned short u_int16_t; +#endif + +#ifndef HAVE_U_INT8_T +typedef unsigned char u_int8_t; +#endif + #endif -- cgit From c4173f67255f1c620d944bf68d34d577ab433ef1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Jul 2005 09:23:52 +0000 Subject: r8458: next target is irix - this gets the socket wrapper code building (This used to be commit 3d4a2221c3e032bbb6c23d132e00588f44f5e2ed) --- source4/lib/replace/replace.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 48e46ba18e..13cbc9dfe4 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -131,4 +131,8 @@ typedef unsigned short u_int16_t; typedef unsigned char u_int8_t; #endif +#ifndef HAVE_SOCKLEN_T +#define socklen_t int +#endif + #endif -- cgit From 5c453f5698add13c859ff0e4cd3e1865a8f08c39 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Jul 2005 13:14:47 +0000 Subject: r8465: once we define socklen_t, then tell other include files we have it. This prevents roken trying to redefine it (This used to be commit aa9491c0cb00f5cab9e00983bf2a0c266011904a) --- source4/lib/replace/replace.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 13cbc9dfe4..f85c8de634 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -133,6 +133,7 @@ typedef unsigned char u_int8_t; #ifndef HAVE_SOCKLEN_T #define socklen_t int +#define HAVE_SOCKLEN_T 1 #endif #endif -- cgit From b48422173005c83034b474db47f956476e862bba Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 19 Jul 2005 05:35:19 +0000 Subject: r8580: try to fix the build on stratus (This used to be commit 58d7a1e6a311c98c9b4dfc9e280b328406165997) --- source4/lib/replace/replace.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 89612912b7..79b452d69c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -191,16 +191,12 @@ Corrections by richard.kettlewell@kewill.com /**************************************************************************** some systems don't have an initgroups call ****************************************************************************/ - int initgroups(char *name,gid_t id) + int initgroups(char *name, gid_t id) { #ifndef HAVE_SETGROUPS - static int done; - if (!done) { - DEBUG(1,("WARNING: running without setgroups\n")); - done=1; - } /* yikes! no SETGROUPS or INITGROUPS? how can this work? */ - return(0); + errno = ENOSYS; + return -1; #else /* HAVE_SETGROUPS */ gid_t *grouplst = NULL; int max_gr = groups_max(); @@ -209,8 +205,8 @@ Corrections by richard.kettlewell@kewill.com struct group *g; char *gr; - if((grouplst = malloc_array_p(gid_t, max_gr)) == NULL) { - DEBUG(0,("initgroups: malloc fail !\n")); + if((grouplst = malloc(sizeof(gid_t) * max_gr)) == NULL) { + errno = ENOMEM; return -1; } @@ -232,8 +228,8 @@ Corrections by richard.kettlewell@kewill.com } } endgrent(); - ret = sys_setgroups(i,grouplst); - SAFE_FREE(grouplst); + ret = setgroups(i, grouplst); + free(grouplst); return ret; #endif /* HAVE_SETGROUPS */ } @@ -429,7 +425,7 @@ duplicate a string if (!msg) return; syslog(facility_priority, "%s", msg); - SAFE_FREE(msg); + free(msg); } #endif /* HAVE_SYSLOG */ #endif /* HAVE_VSYSLOG */ -- cgit From fe6eeeb60177c0b55366bcfb69be3acf8a95fb3b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Jul 2005 03:46:57 +0000 Subject: r8698: attempt to cope with lack of strtoull() on HPUX (This used to be commit c84c516b179fcbbcdb36c0c0aa4ffb4ff12f2c35) --- source4/lib/replace/replace.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 79b452d69c..20a420084a 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -512,7 +512,15 @@ int get_time_zone(time_t t) #ifdef HAVE_STRTOUQ return strtouq(str, endptr, base); #else -#error "system must support 64 bit integer read from strings" + unsigned long long int v; + if (sscanf(str, "%lli", &v) != 1) { + smb_panic("system does not support %lli in sscanf"); + } + if (endptr) { + /* try to get endptr right - uggh */ + strtoul(str, endptr, base); + } + return v; #endif } #endif -- cgit From 0edd0f43c0d25c31e893a4200aa583d83f81ba9c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Jul 2005 10:01:26 +0000 Subject: r8710: another attempt at fixing HPUX (This used to be commit eb3b3c8b407b2208291385539c3379f0420a448e) --- source4/lib/replace/replace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 20a420084a..9ef3999769 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -514,7 +514,8 @@ int get_time_zone(time_t t) #else unsigned long long int v; if (sscanf(str, "%lli", &v) != 1) { - smb_panic("system does not support %lli in sscanf"); + errno = EINVAL; + return 0; } if (endptr) { /* try to get endptr right - uggh */ -- cgit From f92c000fc903803e1c2817dd407974ec44390593 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 25 Jul 2005 04:03:01 +0000 Subject: r8746: replace opendir/readdir/telldir/seekdir/closedir on systems where they are broken (apparently all BSD systems). This breakage leads to unlink on files in an open directory causing a later seekdir to miss files. The bug happens due to a block boundary bug in the BSD libc implementation of these calls. This replacement code also fixes a severe memory usage problem with telldir that can cause closedir() to take an arbitrary amount of time. I have reported the bug in readdir to Greg Lehey (a FreeBSD maintainer) (This used to be commit e1bf7c4279fbc03a52497d24cea375e75059cba1) --- source4/lib/replace/config.mk | 12 ++- source4/lib/replace/repdir/config.m4 | 17 +++++ source4/lib/replace/repdir/repdir.c | 138 +++++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 source4/lib/replace/repdir/config.m4 create mode 100644 source4/lib/replace/repdir/repdir.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index bd60402ba3..16952ea32d 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -1,9 +1,19 @@ +############################## +# Start SUBSYSTEM REPLACE_READDIR +[SUBSYSTEM::REPLACE_READDIR] +ADD_OBJ_FILES = \ + lib/replace/repdir/repdir.o +NOPROTO = YES +# End SUBSYSTEM REPLACE_READDIR +############################## + + ############################## # Start SUBSYSTEM LIBREPLACE [SUBSYSTEM::LIBREPLACE] INIT_OBJ_FILES = lib/replace/replace.o ADD_OBJ_FILES = \ lib/replace/snprintf.o +REQUIRED_SUBSYSTEMS = REPLACE_READDIR # End SUBSYSTEM LIBREPLACE ############################## - diff --git a/source4/lib/replace/repdir/config.m4 b/source4/lib/replace/repdir/config.m4 new file mode 100644 index 0000000000..0ef40ad8cb --- /dev/null +++ b/source4/lib/replace/repdir/config.m4 @@ -0,0 +1,17 @@ +AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[ + AC_TRY_RUN([#include "${srcdir-.}/build/tests/os2_delete.c"], + samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=yes)]) + +if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then +AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[ + AC_TRY_RUN([ +#include "${srcdir-.}/lib/replace/repdir/repdir.c" +#include "${srcdir-.}/build/tests/os2_delete.c"], + samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)]) +fi + +SMB_SUBSYSTEM_ENABLE(REPLACE_READDIR, NO) +if test x"$samba_cv_REPLACE_READDIR" = x"yes"; then + AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) + SMB_SUBSYSTEM_ENABLE(REPLACE_READDIR, YES) +fi diff --git a/source4/lib/replace/repdir/repdir.c b/source4/lib/replace/repdir/repdir.c new file mode 100644 index 0000000000..9c81355c68 --- /dev/null +++ b/source4/lib/replace/repdir/repdir.c @@ -0,0 +1,138 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (C) Andrew Tridgell 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +/* + a replacement for opendir/readdir/telldir/seekdir/closedir for BSD systems + + This is needed because the existing directory handling in FreeBSD + and OpenBSD (and possibly NetBSD) doesn't correctly handle unlink() + on files in a directory where telldir() has been used. On a block + boundary it will occasionally miss a file when seekdir() is used to + return to a position previously recorded with telldir(). + + This also fixes a severe performance and memory usage problem with + telldir() on BSD systems. Each call to telldir() in BSD adds an + entry to a linked list, and those entries are cleaned up on + closedir(). This means with a large directory closedir() can take an + arbitrary amount of time, causing network timeouts as millions of + telldir() entries are freed + + Note! This replacement code is not portable. It relies on getdents() + always leaving the file descriptor at a seek offset that is a + multiple of DIR_BUF_SIZE. If the code detects that this doesn't + happen then it will abort(). It also does not handle directories + with offsets larger than can be stored in a long, + + This code is available under other free software licenses as + well. Contact the author. +*/ + +#include +#include +#include +#include +#include +#include +#include + +#define DIR_BUF_BITS 9 +#define DIR_BUF_SIZE (1<fd = open(dname, O_RDONLY); + if (d->fd == -1) { + free(d); + return NULL; + } + d->ofs = 0; + d->seekpos = 0; + d->nbytes = 0; + return (DIR *)d; +} + +struct dirent *readdir(DIR *dir) +{ + struct dir_buf *d = (struct dir_buf *)dir; + struct dirent *de; + + if (d->ofs >= d->nbytes) { + d->seekpos = lseek(d->fd, 0, SEEK_CUR); + d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE); + d->ofs = 0; + } + if (d->ofs >= d->nbytes) { + return NULL; + } + de = (struct dirent *)&d->buf[d->ofs]; + d->ofs += de->d_reclen; + return de; +} + +long telldir(DIR *dir) +{ + struct dir_buf *d = (struct dir_buf *)dir; + if (d->ofs >= d->nbytes) { + d->seekpos = lseek(d->fd, 0, SEEK_CUR); + d->ofs = 0; + d->nbytes = 0; + } + /* this relies on seekpos always being a multiple of + DIR_BUF_SIZE. Is that always true on BSD systems? */ + if (d->seekpos & (DIR_BUF_SIZE-1)) { + abort(); + } + return d->seekpos + d->ofs; +} + +void seekdir(DIR *dir, long ofs) +{ + struct dir_buf *d = (struct dir_buf *)dir; + d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET); + d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE); + d->ofs = 0; + while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) { + if (readdir(dir) == NULL) break; + } +} + +int closedir(DIR *dir) +{ + struct dir_buf *d = (struct dir_buf *)dir; + int r = close(d->fd); + if (r != 0) { + return r; + } + free(d); + return 0; +} + -- cgit From ecc691041c0650973830c4c566b362b19967f80c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 25 Jul 2005 04:34:14 +0000 Subject: r8749: for completeness, add rewinddir() and dirfd() (This used to be commit ce022e40908dabad41de276941d2ee7a5739aea4) --- source4/lib/replace/repdir/repdir.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir/repdir.c b/source4/lib/replace/repdir/repdir.c index 9c81355c68..a4317aa11c 100644 --- a/source4/lib/replace/repdir/repdir.c +++ b/source4/lib/replace/repdir/repdir.c @@ -125,6 +125,11 @@ void seekdir(DIR *dir, long ofs) } } +void rewinddir(DIR *dir) +{ + seekdir(dir, 0); +} + int closedir(DIR *dir) { struct dir_buf *d = (struct dir_buf *)dir; @@ -136,3 +141,8 @@ int closedir(DIR *dir) return 0; } +int dirfd(DIR *dir) +{ + struct dir_buf *d = (struct dir_buf *)dir; + return d->fd; +} -- cgit From dc4af82432c43920eeafbcdbbe2a6576a6d8d80e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 25 Jul 2005 04:39:20 +0000 Subject: r8750: drat, on some systems dirfd() is a macro (This used to be commit d974bf3589e1b0cd1d5661a21571b81e99350709) --- source4/lib/replace/repdir/repdir.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir/repdir.c b/source4/lib/replace/repdir/repdir.c index a4317aa11c..b536ed6587 100644 --- a/source4/lib/replace/repdir/repdir.c +++ b/source4/lib/replace/repdir/repdir.c @@ -141,8 +141,11 @@ int closedir(DIR *dir) return 0; } +#ifndef dirfd +/* darn, this is a macro on some systems. */ int dirfd(DIR *dir) { struct dir_buf *d = (struct dir_buf *)dir; return d->fd; } +#endif -- cgit From 56c112bbbc028bf7b74b47b22d41b74c7a3f9855 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 4 Aug 2005 16:49:17 +0000 Subject: r9063: - don't pollute the global $LIBS variable with -ldl - -lresolve seems to not being needed any more (it's actually not used, and the build farm seem to happy with it) - move socket and netif configure test to seperate files - don't pollute the global $LIBS variable with -lsocket ... - actually make use of the -lsocket when needed (should fix the solaris build) metze (This used to be commit adebd56be6f62323d56b6666ca0e02f85a33438e) --- source4/lib/replace/config.m4 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 source4/lib/replace/config.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 new file mode 100644 index 0000000000..8c85663d3b --- /dev/null +++ b/source4/lib/replace/config.m4 @@ -0,0 +1,16 @@ +AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ +AC_TRY_RUN([ +#include +#include +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +main() { struct in_addr ip; ip.s_addr = 0x12345678; +if (strcmp(inet_ntoa(ip),"18.52.86.120") && + strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } +exit(1);}], + samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)]) +if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then + AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) +fi -- cgit From 5d899b8a35c9ef1e3688fc56495be1c37477e726 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 18 Aug 2005 00:20:40 +0000 Subject: r9369: an attempt to fix the build on HPUX. This is based on work by Don McCall, but takes a slightly different approach that I hope will be more generic (This used to be commit e8260a81cf99be2ccae64135ca0572c8a6ae62ad) --- source4/lib/replace/config.m4 | 2 + source4/lib/replace/replace.c | 106 +++++++++++------------------------------- 2 files changed, 29 insertions(+), 79 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 8c85663d3b..33dc33a50b 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -14,3 +14,5 @@ exit(1);}], if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) fi + +AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq seteuid) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 9ef3999769..ae70634215 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -340,75 +340,6 @@ duplicate a string #endif /* REPLACE_INET_NTOA */ #endif -#ifndef HAVE_STRTOUL -#ifndef ULONG_MAX -#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */ -#endif - -/* - * Convert a string to an unsigned long integer. - * Taken from libg++ - libiberty code. - * - * Ignores `locale' stuff. Assumes that the upper and lower case - * alphabets and digits are each contiguous. - */ - unsigned long strtoul(const char *nptr, char **endptr, int base) -{ - const char *s = nptr; - unsigned long acc; - int c; - unsigned long cutoff; - int neg = 0, any, cutlim; - - /* - * See strtol for comments as to the logic used. - */ - do { - c = *s++; - } while (isspace(c)); - if (c == '-') { - neg = 1; - c = *s++; - } else if (c == '+') - c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; - cutlim = (int)((unsigned long)ULONG_MAX % (unsigned long)base); - for (acc = 0, any = 0;; c = *s++) { - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) - any = -1; - else { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) { - acc = ULONG_MAX; - errno = ERANGE; - } else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = (char *) (any ? s - 1 : nptr); - return (acc); -} -#endif /* HAVE_STRTOUL */ - #ifndef HAVE_SETLINEBUF int setlinebuf(FILE *stream) { @@ -511,17 +442,23 @@ int get_time_zone(time_t t) { #ifdef HAVE_STRTOUQ return strtouq(str, endptr, base); +#elif defined(HAVE___STRTOULL) + return __strtoull(str, endptr, base); #else - unsigned long long int v; - if (sscanf(str, "%lli", &v) != 1) { - errno = EINVAL; - return 0; - } - if (endptr) { - /* try to get endptr right - uggh */ - strtoul(str, endptr, base); - } - return v; +# error "You need a strtoull function" +#endif +} +#endif + +#ifndef HAVE_STRTOLL + long long int strtoll(const char *str, char **endptr, int base) +{ +#ifdef HAVE_STRTOQ + return strtoq(str, endptr, base); +#elif defined(HAVE___STRTOLL) + return __strtoll(str, endptr, base); +#else +# error "You need a strtoll function" #endif } #endif @@ -567,3 +504,14 @@ int sys_waitpid(pid_t pid,int *status,int options) return wait4(pid, status, options, NULL); #endif /* USE_WAITPID */ } + +#ifndef HAVE_SETEUID + int seteuid(uid_t euid) +{ +#ifdef HAVE_SETRESUID + return setresuid(-1, euid, -1); +#else +# error "You need a seteuid function" +#endif +} +#endif -- cgit From 4e21575ed2144c0ca330439989278906c273270d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 18 Aug 2005 00:31:40 +0000 Subject: r9370: need a configure test for setresuid() (This used to be commit 5a38b9a10b3c5363cddc7acaaea2e1e9aceb254c) --- source4/lib/replace/config.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 33dc33a50b..a912675d0f 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -15,4 +15,4 @@ if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) fi -AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq seteuid) +AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq seteuid setresuid) -- cgit From 3f260e2efe416a05571c29d8edb81ae0385a00c9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 18 Aug 2005 01:57:43 +0000 Subject: r9374: HPUX is also missing setegid() (This used to be commit 57e6bd61395e82064c72510dcc326b11b7bdf7fd) --- source4/lib/replace/config.m4 | 3 ++- source4/lib/replace/replace.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index a912675d0f..4dfeb5647a 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -15,4 +15,5 @@ if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) fi -AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq seteuid setresuid) +AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) +AC_CHECK_FUNCS(seteuid setresuid setegid setresgid) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index ae70634215..ef8e053257 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -515,3 +515,14 @@ int sys_waitpid(pid_t pid,int *status,int options) #endif } #endif + +#ifndef HAVE_SETEGID + int setegid(gid_t egid) +{ +#ifdef HAVE_SETRESGID + return setresgid(-1, egid, -1); +#else +# error "You need a setegid function" +#endif +} +#endif -- cgit From fc411bed80e3150a0d368daf9fb41f6c2aedf537 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 2 Sep 2005 11:35:58 +0000 Subject: r9949: Portability fixes for mingw32 (This used to be commit 994093b08ee463066c6bae494b10374bd700b0b0) --- source4/lib/replace/repdir/config.m4 | 4 +++- source4/lib/replace/win32/replace.h | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir/config.m4 b/source4/lib/replace/repdir/config.m4 index 0ef40ad8cb..02fb6e1816 100644 --- a/source4/lib/replace/repdir/config.m4 +++ b/source4/lib/replace/repdir/config.m4 @@ -1,6 +1,8 @@ AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[ AC_TRY_RUN([#include "${srcdir-.}/build/tests/os2_delete.c"], - samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=yes)]) + [samba_cv_HAVE_BROKEN_READDIR=no], + [samba_cv_HAVE_BROKEN_READDIR=yes], + [samba_cv_HAVE_BROKEN_READDIR="assuming not"])]) if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[ diff --git a/source4/lib/replace/win32/replace.h b/source4/lib/replace/win32/replace.h index 2c6d0e1a3f..94fa140681 100644 --- a/source4/lib/replace/win32/replace.h +++ b/source4/lib/replace/win32/replace.h @@ -140,7 +140,4 @@ #undef SE_GROUP_ENABLED_BY_DEFAULT #undef SE_GROUP_ENABLED -typedef uint32_t u_int32_t; -typedef uint16_t u_int16_t; - #endif /* _WIN32_REPLACE_H */ -- cgit From 5b02ee9b9d7037b385cf4f1c3eca81b28ff19690 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 20 Sep 2005 00:39:19 +0000 Subject: r10336: Add sconscript for a couple more subsystems. (This used to be commit 59d4450453c25f5cce9b67b808ff0c4433c1d194) --- source4/lib/replace/SConscript | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 source4/lib/replace/SConscript (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript new file mode 100644 index 0000000000..f8efcc55b9 --- /dev/null +++ b/source4/lib/replace/SConscript @@ -0,0 +1,11 @@ +Import('hostenv') + +conf = Configure(hostenv) +#FIXME: conf.CheckBrokenInetNtoa() +for f in ['strtoull','__strtoull','strtouq','strtoll','__strtoll','strtoq', + 'seteuid','setresuid','setegid','setresgid']: + conf.CheckFunc(f,'c') +conf.Finish() + +hostenv.StaticLibrary('repdir', ['repdir/repdir.c']) +hostenv.StaticLibrary('replace', ['replace.c', 'snprintf.c']) -- cgit From 6812c73534001d2dd05a9a74358d2b6d0029f1a7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 20 Sep 2005 11:59:03 +0000 Subject: r10348: Add scons scripts for remaining subsystems. Most subsystems build now, but final linking still fails (as does generating files asn1, et, idl and proto files) (This used to be commit 4f0d7f75b99c7f4388d8acb0838577d86baf68b5) --- source4/lib/replace/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript index f8efcc55b9..b63b544f8a 100644 --- a/source4/lib/replace/SConscript +++ b/source4/lib/replace/SConscript @@ -1,6 +1,6 @@ Import('hostenv') - conf = Configure(hostenv) + #FIXME: conf.CheckBrokenInetNtoa() for f in ['strtoull','__strtoull','strtouq','strtoll','__strtoll','strtoq', 'seteuid','setresuid','setegid','setresgid']: -- cgit From d191c7d9932b8e8ad96c4345a6ceca67326806ac Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 21 Sep 2005 05:39:18 +0000 Subject: r10377: Save configuration stuff to sconf.cache so it isn't annoyingly run at every single build. Run 'scons configure=1' or delete sconf.cache to force checks to be re-run. Jelmer, I think this stuff is cached in the .sconf_cache directory but the message is still displayed and it looks like it caches the compiled test object file not the actual result of the test. (This used to be commit 9d001dc083937bbf5642af90bc8a8b1a27825de0) --- source4/lib/replace/SConscript | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript index b63b544f8a..84088db162 100644 --- a/source4/lib/replace/SConscript +++ b/source4/lib/replace/SConscript @@ -1,11 +1,12 @@ Import('hostenv') -conf = Configure(hostenv) -#FIXME: conf.CheckBrokenInetNtoa() -for f in ['strtoull','__strtoull','strtouq','strtoll','__strtoll','strtoq', - 'seteuid','setresuid','setegid','setresgid']: - conf.CheckFunc(f,'c') -conf.Finish() +if hostenv['configure']: + conf = Configure(hostenv) + #FIXME: conf.CheckBrokenInetNtoa() + for f in ['strtoull','__strtoull','strtouq','strtoll','__strtoll','strtoq', + 'seteuid','setresuid','setegid','setresgid']: + conf.CheckFunc(f,'c') + conf.Finish() hostenv.StaticLibrary('repdir', ['repdir/repdir.c']) hostenv.StaticLibrary('replace', ['replace.c', 'snprintf.c']) -- cgit From f3b412fbd6dd94d64eb6a63d88baef2816891c29 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 23 Sep 2005 00:38:22 +0000 Subject: r10438: Move portability functions to lib/replace/; replace now simply ensures that a given set of (working) POSIX functions are available (without prefixes to their names, etc). See lib/replace/README for a list. Functions that behave different from their POSIX specification (such as sys_select, sys_read, etc) have kept the sys_ prefix. (This used to be commit 29919a71059b29fa27a49b1f5b84bb8881de65fc) --- source4/lib/replace/README | 54 +++++++++++++++++++++++++++ source4/lib/replace/SConscript | 2 +- source4/lib/replace/config.m4 | 84 +++++++++++++++++++++++++++++++++++++++++- source4/lib/replace/config.mk | 4 +- source4/lib/replace/dlfcn.c | 71 +++++++++++++++++++++++++++++++++++ source4/lib/replace/replace.c | 73 ++++++++++++++++++------------------ source4/lib/replace/replace.h | 22 +++++++++++ 7 files changed, 269 insertions(+), 41 deletions(-) create mode 100644 source4/lib/replace/README create mode 100644 source4/lib/replace/dlfcn.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README new file mode 100644 index 0000000000..74b5397949 --- /dev/null +++ b/source4/lib/replace/README @@ -0,0 +1,54 @@ +This subsystem ensures that we can always use a certain core set of +functions and types, that are either provided by the OS or by replacement +functions / definitions in this subsystem. The aim is to try to stick +to POSIX functions in here as much as possible. Convenience functions +that are available on no platform at all belong in different subsystems +(such as LIBUTIL). + +The following functions are guarenteed: + +ftruncate +strlcpy +strlcat +mktime +rename +innetgr +initgroups +memmove +strdup +inet_ntoa +setlinebuf +vsyslog +timegm +setenv +strtoull +strtoll +strndup +strnlen +waitpid +seteuid +setegid +asprintf +snprintf +vasprintf +vsnprintf +opendir +readdir +telldir +seekdir +closedir +dlopen +dlclose +dlsym +dlerror +chroot +bzero +strerror +errno +mkstemp (a secure one!) + +Prerequisites: +memset (for bzero) +syslog (for vsyslog) +setnetgrent, getnetgrent, endnetgrent (for innetgr) +mktemp (for mkstemp) diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript index 84088db162..982120e1bf 100644 --- a/source4/lib/replace/SConscript +++ b/source4/lib/replace/SConscript @@ -9,4 +9,4 @@ if hostenv['configure']: conf.Finish() hostenv.StaticLibrary('repdir', ['repdir/repdir.c']) -hostenv.StaticLibrary('replace', ['replace.c', 'snprintf.c']) +hostenv.StaticLibrary('replace', ['replace.c', 'snprintf.c','dlfcn.c']) diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 4dfeb5647a..88e3be5e94 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -15,5 +15,87 @@ if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) fi +dnl Provided by replace.c: +AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) -AC_CHECK_FUNCS(seteuid setresuid setegid setresgid) +AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) +AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename) +AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup) +AC_HAVE_DECL(setresuid, [#include ]) +AC_HAVE_DECL(setresgid, [#include ]) +AC_HAVE_DECL(errno, [#include ]) + +AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[ +AC_TRY_RUN([#include +#include +#include +#include +main() { + struct stat st; + char tpl[20]="/tmp/test.XXXXXX"; + int fd = mkstemp(tpl); + if (fd == -1) exit(1); + unlink(tpl); + if (fstat(fd, &st) != 0) exit(1); + if ((st.st_mode & 0777) != 0600) exit(1); + exit(0); +}], +samba_cv_HAVE_SECURE_MKSTEMP=yes, +samba_cv_HAVE_SECURE_MKSTEMP=no, +samba_cv_HAVE_SECURE_MKSTEMP=cross)]) +if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then + AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure]) +fi + +dnl Provided by snprintf.c: +AC_HAVE_DECL(asprintf, [#include ]) +AC_HAVE_DECL(vasprintf, [#include ]) +AC_HAVE_DECL(vsnprintf, [#include ]) +AC_HAVE_DECL(snprintf, [#include ]) +AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf) + +AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[ +AC_TRY_RUN([ +#include +#include +void foo(const char *format, ...) { + va_list ap; + int len; + char buf[20]; + long long l = 1234567890; + l *= 100; + + va_start(ap, format); + len = vsnprintf(buf, 0, format, ap); + va_end(ap); + if (len != 5) exit(1); + + va_start(ap, format); + len = vsnprintf(0, 0, format, ap); + va_end(ap); + if (len != 5) exit(1); + + if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); + + if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(1); + + exit(0); +} +main() { foo("hello"); } +], +samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)]) +if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then + AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf]) +fi + +dnl Provided by dlfcn.c: +AC_SEARCH_LIBS_EXT(dlopen, [dl], DL_LIBS) +SMB_EXT_LIB(DL,[${DL_LIBS}],[${DL_CFLAGS}],[${DL_CPPFLAGS}],[${DL_LDFLAGS}]) +SAVE_LIBS="$LIBS" +LIBS="$LIBS $DL_LIBS" +AC_CHECK_HEADERS(dlfcn.h) +AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose) +LIBS="$SAVE_LIBS" + +AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent],, + [AC_MSG_ERROR([Need syslog and memset])]) diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 16952ea32d..2658f0e96a 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -13,7 +13,9 @@ NOPROTO = YES [SUBSYSTEM::LIBREPLACE] INIT_OBJ_FILES = lib/replace/replace.o ADD_OBJ_FILES = \ - lib/replace/snprintf.o + lib/replace/snprintf.o \ + lib/replace/dlfcn.o +NOPROTO = YES REQUIRED_SUBSYSTEMS = REPLACE_READDIR # End SUBSYSTEM LIBREPLACE ############################## diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c new file mode 100644 index 0000000000..7a9e7230de --- /dev/null +++ b/source4/lib/replace/dlfcn.c @@ -0,0 +1,71 @@ +/* + Unix SMB/CIFS implementation. + Samba system utilities + Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Jeremy Allison 1998-2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* + Unix SMB/CIFS implementation. + Samba system utilities + Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Jeremy Allison 1998-2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +#ifndef HAVE_DLOPEN +void *dlopen(const char *name, int flags) +{ + return NULL; +} +#endif + +#ifndef HAVE_DLSYM +void *dlsym(void *handle, const char *symbol) +{ + return NULL; +} +#endif + +#ifndef HAVE_DLERROR +const char *dlerror(void) +{ + return "dynamic loading of objects not supported on this platform"; +} +#endif + +#ifndef HAVE_DLCLOSE +int dlclose(void *handle) +{ + return 0; +} +#endif diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index ef8e053257..aa79f23fd0 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -361,39 +361,6 @@ duplicate a string #endif /* HAVE_SYSLOG */ #endif /* HAVE_VSYSLOG */ -/******************************************************************* -yield the difference between *A and *B, in seconds, ignoring leap seconds -********************************************************************/ -static int tm_diff(struct tm *a, struct tm *b) -{ - int ay = a->tm_year + (1900 - 1); - int by = b->tm_year + (1900 - 1); - int intervening_leap_days = - (ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400); - int years = ay - by; - int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday); - int hours = 24*days + (a->tm_hour - b->tm_hour); - int minutes = 60*hours + (a->tm_min - b->tm_min); - int seconds = 60*minutes + (a->tm_sec - b->tm_sec); - - return seconds; -} - -/******************************************************************* - return the UTC offset in seconds west of UTC, or 0 if it cannot be determined - ******************************************************************/ -int get_time_zone(time_t t) -{ - struct tm *tm = gmtime(&t); - struct tm tm_utc; - if (!tm) - return 0; - tm_utc = *tm; - tm = localtime(&t); - if (!tm) - return 0; - return tm_diff(&tm_utc,tm); -} #ifndef HAVE_TIMEGM /* @@ -496,14 +463,12 @@ int get_time_zone(time_t t) } #endif -int sys_waitpid(pid_t pid,int *status,int options) +#ifndef HAVE_WAITPID +int waitpid(pid_t pid,int *status,int options) { -#ifdef HAVE_WAITPID - return waitpid(pid,status,options); -#else /* USE_WAITPID */ return wait4(pid, status, options, NULL); -#endif /* USE_WAITPID */ } +#endif #ifndef HAVE_SETEUID int seteuid(uid_t euid) @@ -526,3 +491,35 @@ int sys_waitpid(pid_t pid,int *status,int options) #endif } #endif + +/******************************************************************* +os/2 also doesn't have chroot +********************************************************************/ +#ifndef HAVE_CHROOT +int chroot(const char *dname) +{ + static int done; + if (!done) { + DEBUG(1,("WARNING: no chroot!\n")); + done=1; + } + errno = ENOSYS; + return -1; +} +#endif + +/***************************************************************** + Possibly replace mkstemp if it is broken. +*****************************************************************/ + +#ifndef HAVE_SECURE_MKSTEMP +int rep_mkstemp(char *template) +{ + /* have a reasonable go at emulating it. Hope that + the system mktemp() isn't completly hopeless */ + char *p = mktemp(template); + if (!p) + return -1; + return open(p, O_CREAT|O_EXCL|O_RDWR, 0600); +} +#endif diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index f85c8de634..f906e7a2f5 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -23,6 +23,10 @@ #ifndef _replace_h #define _replace_h +#if defined(_MSC_VER) || defined(__MINGW32__) +#include "lib/replace/win32/replace.h" +#endif + #ifdef __COMPAR_FN_T #define QSORT_CAST (__compar_fn_t) #endif @@ -31,6 +35,15 @@ #define QSORT_CAST (int (*)(const void *, const void *)) #endif +#ifndef HAVE_STRERROR +extern char *sys_errlist[]; +#define strerror(i) sys_errlist[i] +#endif + +#ifndef HAVE_ERRNO_DECL +extern int errno; +#endif + #ifndef HAVE_STRDUP char *strdup(const char *s); #endif @@ -136,4 +149,13 @@ typedef unsigned char u_int8_t; #define HAVE_SOCKLEN_T 1 #endif +#ifdef HAVE_DLFCN_H +#include +#endif + +#ifndef HAVE_SECURE_MKSTEMP +#define mkstemp(path) rep_mkstemp(path) +int rep_mkstemp(char *temp); +#endif + #endif -- cgit From aba4d018b4b9091789a47d1e40fc15c5e848794b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 23 Sep 2005 07:53:58 +0000 Subject: r10449: remove double copyright header metze (This used to be commit f6bd76fa154de6ed7f7ef3257be9572f13f3ec48) --- source4/lib/replace/dlfcn.c | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c index 7a9e7230de..6df57cd60c 100644 --- a/source4/lib/replace/dlfcn.c +++ b/source4/lib/replace/dlfcn.c @@ -19,27 +19,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* - Unix SMB/CIFS implementation. - Samba system utilities - Copyright (C) Andrew Tridgell 1992-1998 - Copyright (C) Jeremy Allison 1998-2002 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - #include "includes.h" #ifndef HAVE_DLOPEN -- cgit From b85f7857dc82ca1dbde1a91463cfe83cbcbee5f7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 23 Sep 2005 14:09:38 +0000 Subject: r10452: Couple of small scons updates - ignore .sconsign files (This used to be commit b2d2b4f23393c727ae3feeaf4b4b65bc03a673f7) --- source4/lib/replace/README | 3 +++ source4/lib/replace/config.m4 | 1 + 2 files changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 74b5397949..6575112eff 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -47,6 +47,9 @@ strerror errno mkstemp (a secure one!) +Types: +socklen_t + Prerequisites: memset (for bzero) syslog (for vsyslog) diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 88e3be5e94..3dbb5e4cf1 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -16,6 +16,7 @@ if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then fi dnl Provided by replace.c: +AC_HAVE_TYPE([socklen_t], [#include ]) AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) -- cgit From da46c9252ee887602b3e629065ca87b9ed11466f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 23 Sep 2005 15:08:17 +0000 Subject: r10453: Fix the build (This used to be commit 7be3ec4dbb919752477e1d995df9f7d295b67687) --- source4/lib/replace/config.m4 | 2 +- source4/lib/replace/replace.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 3dbb5e4cf1..ac4db9ed5b 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -16,7 +16,7 @@ if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then fi dnl Provided by replace.c: -AC_HAVE_TYPE([socklen_t], [#include ]) +AC_CHECK_TYPE([socklen_t], int) AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index f906e7a2f5..28a6392eb3 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -144,11 +144,6 @@ typedef unsigned short u_int16_t; typedef unsigned char u_int8_t; #endif -#ifndef HAVE_SOCKLEN_T -#define socklen_t int -#define HAVE_SOCKLEN_T 1 -#endif - #ifdef HAVE_DLFCN_H #include #endif -- cgit From 4be0ae794e4af2354d678fddd7bf1e822ffa9148 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 23 Sep 2005 16:32:52 +0000 Subject: r10456: More SCons fixes: - Add framework for fallback generating code - Move pread / pwrite replacement functions to libreplace - Support pidl builds correctly - Support asn1 builds correctly - Move OS-specific checks to lib/replace/SConscript (This used to be commit fbbfad0a1f7dedbf48e835a864f8285f283d72f3) --- source4/lib/replace/README | 2 ++ source4/lib/replace/SConscript | 28 ++++++++++++++++++++++++---- source4/lib/replace/config.m4 | 1 + source4/lib/replace/replace.c | 22 ++++++++++++++++++++++ 4 files changed, 49 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 6575112eff..eb3360b74a 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -46,6 +46,8 @@ bzero strerror errno mkstemp (a secure one!) +pread +pwrite Types: socklen_t diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript index 982120e1bf..a2b3a30e10 100644 --- a/source4/lib/replace/SConscript +++ b/source4/lib/replace/SConscript @@ -1,11 +1,31 @@ -Import('hostenv') +#!/usr/bin/env python +Import('hostenv defines') if hostenv['configure']: conf = Configure(hostenv) - #FIXME: conf.CheckBrokenInetNtoa() + for f in ['memset','syslog','setnetgrent','getnetgrent','endnetgrent', \ + 'mktemp']: + if not conf.CheckFunc(f,'c'): + print "Required function `%s' not found" % f + exit(1) + for f in ['strtoull','__strtoull','strtouq','strtoll','__strtoll','strtoq', - 'seteuid','setresuid','setegid','setresgid']: - conf.CheckFunc(f,'c') + 'seteuid','setresuid','setegid','setresgid','dlsym','dlopen', + 'dlerror','dlclose','waitpid','getcwd','strdup','strndup', + 'strnlen','strerror','bzero','chroot','strlcpy','strlcat', + 'memmove','vsnprintf','asprintf','snprintf','vasprintf', + 'innetgr','mktime','rename','ftruncate','chsize','setlinebuf', + 'setenv','vsyslog','pread','pwrite']: + if conf.CheckFunc(f,'c'): + defines['HAVE_' + f.upper()] = 1 + + for h in ['dlfcn.h']: + if conf.CheckCHeader('dlfcn.h'): + defines['HAVE_' + h.upper().replace('.','_').replace('/','_')] = 1 + + if not conf.CheckType('socklen_t'): + defines['socklen_t'] = 'int' + conf.Finish() hostenv.StaticLibrary('repdir', ['repdir/repdir.c']) diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index ac4db9ed5b..07fbed9d91 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -22,6 +22,7 @@ AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup) +AC_CHECK_FUNCS(pread pwrite) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index aa79f23fd0..c53b5a5727 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -523,3 +523,25 @@ int rep_mkstemp(char *template) return open(p, O_CREAT|O_EXCL|O_RDWR, 0600); } #endif + +#ifndef HAVE_PREAD +static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) +{ + if (lseek(__fd, __offset, SEEK_SET) != __offset) { + return -1; + } + return read(__fd, __buf, __nbytes); +} +#endif + +#ifndef HAVE_PWRITE +static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) +{ + if (lseek(__fd, __offset, SEEK_SET) != __offset) { + return -1; + } + return write(__fd, __buf, __nbytes); +} +#endif + + -- cgit From ebf07796086b1b9c03550326c3a3da437d4e7af3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 24 Sep 2005 08:24:55 +0000 Subject: r10472: Check for strndup (This used to be commit 8335aa056fd8a414feaffa707dc0bc20ac27388f) --- source4/lib/replace/config.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 07fbed9d91..26a2cae56d 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -22,7 +22,7 @@ AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite) +AC_CHECK_FUNCS(pread pwrite strndup) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) -- cgit From 70b52b02a77c695d32aa57daaeb5689cd6857eba Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 24 Sep 2005 14:58:18 +0000 Subject: r10476: Move some more types to libreplace. Fix missing strndup errors for heimdal (This used to be commit e09ffdfb1dba289b79ac7e5a638bf5322d45ddc0) --- source4/lib/replace/README | 4 ++++ source4/lib/replace/SConscript | 25 ++++++++++++++++++++++++- source4/lib/replace/config.m4 | 17 +++++++++++++++-- source4/lib/replace/replace.h | 12 ------------ 4 files changed, 43 insertions(+), 15 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index eb3360b74a..45c8bccf13 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -51,6 +51,10 @@ pwrite Types: socklen_t +u_int{8,16,32}_t +uint_t +uint{8,16,32,64}_t +int{8,16,32,64}_t Prerequisites: memset (for bzero) diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript index a2b3a30e10..60652b0b15 100644 --- a/source4/lib/replace/SConscript +++ b/source4/lib/replace/SConscript @@ -4,7 +4,7 @@ Import('hostenv defines') if hostenv['configure']: conf = Configure(hostenv) for f in ['memset','syslog','setnetgrent','getnetgrent','endnetgrent', \ - 'mktemp']: + 'mktemp', 'memcpy']: if not conf.CheckFunc(f,'c'): print "Required function `%s' not found" % f exit(1) @@ -26,6 +26,29 @@ if hostenv['configure']: if not conf.CheckType('socklen_t'): defines['socklen_t'] = 'int' + needed_types = { + 'uint_t': 'unsigned int', + 'int8_t': 'signed char', + 'uint8_t': 'unsigned char', + 'u_int8_t': 'unsigned char', + 'int16_t': 'short', + 'uint16_t': 'unsigned short', + 'u_int16_t': 'unsigned short', + 'int32_t': 'long', + 'uint32_t': 'unsigned long', + 'u_int32_t': 'unsigned long', + 'int64_t': 'long long', + 'uint64_t': 'unsigned long long', + } + + type_headers = """ +#include +#include +""" + for t in needed_types: + if not conf.CheckType(t,type_headers): + defines[t] = needed_types[t] + conf.Finish() hostenv.StaticLibrary('repdir', ['repdir/repdir.c']) diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 26a2cae56d..2b8d4ca3d1 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -1,3 +1,16 @@ +AC_CHECK_TYPE(uint_t, unsigned int) +AC_CHECK_TYPE(int8_t, signed char) +AC_CHECK_TYPE(uint8_t, unsigned char) +AC_CHECK_TYPE(int16_t, short) +AC_CHECK_TYPE(uint16_t, unsigned short) +AC_CHECK_TYPE(int32_t, long) +AC_CHECK_TYPE(uint32_t, unsigned long) +AC_CHECK_TYPE(int64_t, long long) +AC_CHECK_TYPE(uint64_t, unsigned long long) +AC_CHECK_TYPE(u_int32_t, unsigned long) +AC_CHECK_TYPE(u_int16_t, unsigned short) +AC_CHECK_TYPE(u_int8_t, unsigned char) + AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ #include @@ -99,5 +112,5 @@ AC_CHECK_HEADERS(dlfcn.h) AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose) LIBS="$SAVE_LIBS" -AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent],, - [AC_MSG_ERROR([Need syslog and memset])]) +AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, + [AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 28a6392eb3..3ad348517d 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -132,18 +132,6 @@ int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); typedef int (*comparison_fn_t)(const void *, const void *); #endif -#ifndef HAVE_U_INT32_T -typedef unsigned u_int32_t; -#endif - -#ifndef HAVE_U_INT16_T -typedef unsigned short u_int16_t; -#endif - -#ifndef HAVE_U_INT8_T -typedef unsigned char u_int8_t; -#endif - #ifdef HAVE_DLFCN_H #include #endif -- cgit From 3d4ea18d4dd9031adc16348c16595d6c216b2d84 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 24 Sep 2005 16:23:41 +0000 Subject: r10478: More work on proto headers; we now generate a couple of smaller ones that are then included by include/proto.h (This used to be commit 703ffbaaaca11f3d8781cfe9e7542fcaa626d991) --- source4/lib/replace/SConscript | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript index 60652b0b15..48abf2c081 100644 --- a/source4/lib/replace/SConscript +++ b/source4/lib/replace/SConscript @@ -19,6 +19,16 @@ if hostenv['configure']: if conf.CheckFunc(f,'c'): defines['HAVE_' + f.upper()] = 1 + # Check for errno declaration + if conf.TryCompile(""" +#include + +int main() { + int i = (int)errno; + return 0; +}""", '.c'): + defines['HAVE_ERRNO_DECL'] = 1 + for h in ['dlfcn.h']: if conf.CheckCHeader('dlfcn.h'): defines['HAVE_' + h.upper().replace('.','_').replace('/','_')] = 1 -- cgit From e337caeed1459f876449611ae1684616d0ea8f55 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Sep 2005 15:15:50 +0000 Subject: r10509: Some more sconscript fixes. Now getting to link stage for smbclient (This used to be commit 6df956edbab7ad5e72b2f20e74ab0f0d62528932) --- source4/lib/replace/SConscript | 11 ++++++++--- source4/lib/replace/win32/SConscript | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 source4/lib/replace/win32/SConscript (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript index 48abf2c081..47bfa481f2 100644 --- a/source4/lib/replace/SConscript +++ b/source4/lib/replace/SConscript @@ -1,6 +1,8 @@ #!/usr/bin/env python Import('hostenv defines') +rep_files = ['replace.c', 'snprintf.c','dlfcn.c'] + if hostenv['configure']: conf = Configure(hostenv) for f in ['memset','syslog','setnetgrent','getnetgrent','endnetgrent', \ @@ -33,7 +35,7 @@ int main() { if conf.CheckCHeader('dlfcn.h'): defines['HAVE_' + h.upper().replace('.','_').replace('/','_')] = 1 - if not conf.CheckType('socklen_t'): + if not conf.CheckType('socklen_t', "#include "): defines['socklen_t'] = 'int' needed_types = { @@ -59,7 +61,10 @@ int main() { if not conf.CheckType(t,type_headers): defines[t] = needed_types[t] + if not conf.TryRun(open("../../build/tests/os2_delete.c").read(), '.c'): + rep_files += ['repdir/repdir.c'] + conf.Finish() -hostenv.StaticLibrary('repdir', ['repdir/repdir.c']) -hostenv.StaticLibrary('replace', ['replace.c', 'snprintf.c','dlfcn.c']) +hostenv.StaticLibrary('replace', rep_files) +SConscript(dirs=['win32']) diff --git a/source4/lib/replace/win32/SConscript b/source4/lib/replace/win32/SConscript new file mode 100644 index 0000000000..a23fb6a878 --- /dev/null +++ b/source4/lib/replace/win32/SConscript @@ -0,0 +1,22 @@ +Import('hostenv defines') + +if hostenv['configure']: + conf = Configure(hostenv) + for h in ['direct.h','windows.h','winsock2.h','ws2tcpip.h']: + if conf.CheckCHeader(h): + defines['HAVE_' + h.upper().replace('.','_')] = 1 + conf.TryCompile(""" +#include +#ifdef HAVE_DIRECT_H +#include +#endif + +int main() +{ + mkdir("foo",0777); + return 0; +} +""", '.c') + + conf.Finish() + -- cgit From f801ad359290c51d3216c755fb2a8344babb484f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Sep 2005 15:59:43 +0000 Subject: r10510: Decrease the amount of data included by includes.h a bit (This used to be commit 03647e1321cf6c9bd6ced3945265f635e9468973) --- source4/lib/replace/SConscript | 1 + source4/lib/replace/config.m4 | 1 + source4/lib/replace/win32/replace.h | 12 ++++++++++++ 3 files changed, 14 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript index 47bfa481f2..f45d0e7d5a 100644 --- a/source4/lib/replace/SConscript +++ b/source4/lib/replace/SConscript @@ -51,6 +51,7 @@ int main() { 'u_int32_t': 'unsigned long', 'int64_t': 'long long', 'uint64_t': 'unsigned long long', + 'ssize_t': 'int' } type_headers = """ diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 2b8d4ca3d1..0b95079b24 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -10,6 +10,7 @@ AC_CHECK_TYPE(uint64_t, unsigned long long) AC_CHECK_TYPE(u_int32_t, unsigned long) AC_CHECK_TYPE(u_int16_t, unsigned short) AC_CHECK_TYPE(u_int8_t, unsigned char) +AC_CHECK_TYPE(ssize_t, int) AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ diff --git a/source4/lib/replace/win32/replace.h b/source4/lib/replace/win32/replace.h index 94fa140681..185d448d95 100644 --- a/source4/lib/replace/win32/replace.h +++ b/source4/lib/replace/win32/replace.h @@ -1,6 +1,18 @@ #ifndef _WIN32_REPLACE_H #define _WIN32_REPLACE_H +#ifdef HAVE_WINSOCK2_H +#include +#endif + +#ifdef HAVE_WS2TCPIP_H +#include +#endif + +#ifdef HAVE_WINDOWS_H +#include +#endif + /* Map BSD Socket errorcodes to the WSA errorcodes (if possible) */ #define EAFNOSUPPORT WSAEAFNOSUPPORT -- cgit From 691aff270bc2f0bfee0632d426e2f6ba06f69f89 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Sep 2005 00:11:21 +0000 Subject: r10521: Also check sys/socket.h for definition of socklen_t (needed for AIX) (This used to be commit 42eb14060d53dbcbc381ecc781f121279190b08e) --- source4/lib/replace/config.m4 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 0b95079b24..98c491fd38 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -30,7 +30,16 @@ if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then fi dnl Provided by replace.c: -AC_CHECK_TYPE([socklen_t], int) +AC_TRY_COMPILE([ +#include +#if STDC_HEADERS +#include +#include +#endif +#include ], +[socklen_t foo;],, +[AC_DEFINE(socklen_t, int,[Socket length type])]) + AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) -- cgit From a2dffe109bc989c5a610d610a2f1a31f10d65968 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 Sep 2005 02:36:56 +0000 Subject: r10523: fixed timegm() to not depend on get_time_zone(), so it works in lib/replace/ the old timegm() replacement was also broken (it returned the wrong value) (This used to be commit 342489a1d4d5cc4b16cf2e5ff7e671326f0cb3d5) --- source4/lib/replace/replace.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index c53b5a5727..5e60252a67 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -369,18 +369,8 @@ duplicate a string */ time_t timegm(struct tm *tm) { - struct tm tm2, tm3; - time_t t; - - tm2 = *tm; - - t = mktime(&tm2); - tm3 = *localtime(&t); - tm2 = *tm; - tm2.tm_isdst = tm3.tm_isdst; - t = mktime(&tm2); - t -= get_time_zone(t); - + time_t t = mktime(tm); + t -= mktime(gmtime(&t)) - (int)mktime(localtime(&t)); return t; } #endif -- cgit From 5058f4b9e82ca8b9f2405930db3a46b8c37f06ed Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Sep 2005 18:18:09 +0000 Subject: r10586: Add MergedObject() builder. Default to Library() rather then StaticLibrary() (This used to be commit b53313dc517986c69a4e4cb8fe3885b696f8faa1) --- source4/lib/replace/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript index f45d0e7d5a..cf28102175 100644 --- a/source4/lib/replace/SConscript +++ b/source4/lib/replace/SConscript @@ -67,5 +67,5 @@ int main() { conf.Finish() -hostenv.StaticLibrary('replace', rep_files) +hostenv.Library('replace', rep_files) SConscript(dirs=['win32']) -- cgit From ecbf28630ef0fbd91838001e03f8c6d29a8d4232 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Sep 2005 23:10:20 +0000 Subject: r10664: Include limits.h in replace.h for HOST_NAME_MAX (This used to be commit dc3dc796746de672dbf3ad0e4715e8b30ae4afb7) --- source4/lib/replace/replace.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 3ad348517d..572113af8c 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -80,6 +80,14 @@ unsigned long strtoul(const char *nptr, char **endptr, int base); int setenv(const char *name, const char *value, int overwrite); #endif +#ifndef HAVE_RENAME +int rename(const char *zfrom, const char *zto); +#endif + +#ifndef HAVE_FTRUNCATE +int ftruncate(int f,long l); +#endif + #ifndef HAVE_VASPRINTF_DECL int vasprintf(char **ptr, const char *format, va_list ap); #endif @@ -132,13 +140,26 @@ int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); typedef int (*comparison_fn_t)(const void *, const void *); #endif +/* Load header file for dynamic linking stuff */ #ifdef HAVE_DLFCN_H #include #endif +#ifndef RTLD_LAZY +#define RTLD_LAZY 0 +#endif + #ifndef HAVE_SECURE_MKSTEMP #define mkstemp(path) rep_mkstemp(path) int rep_mkstemp(char *temp); #endif +#ifdef HAVE_LIMITS_H +#include +#endif + +#ifndef HOST_NAME_MAX +#define HOST_NAME_MAX 64 +#endif + #endif -- cgit From 1584f64920431d15276dd44c59fc35dc5506c0e7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Oct 2005 12:30:34 +0000 Subject: r10896: added a strcasestr() replacement function (This used to be commit 4483d275e12006e5acc72ae143c0a01da01bd00d) --- source4/lib/replace/config.m4 | 2 +- source4/lib/replace/replace.c | 16 +++++++++++++++- source4/lib/replace/replace.h | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 98c491fd38..70d13e40fd 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -45,7 +45,7 @@ AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup) +AC_CHECK_FUNCS(pread pwrite strndup strcasestr) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 5e60252a67..d87a009e8c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -22,6 +22,7 @@ #include "system/wait.h" #include "system/time.h" #include "system/network.h" +#include "system/iconv.h" void replace_dummy(void); void replace_dummy(void) {} @@ -534,4 +535,17 @@ static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offs } #endif - +#ifndef HAVE_STRCASESTR +char *strcasestr(const char *haystack, const char *needle) +{ + const char *s; + size_t nlen = strlen(needle); + for (s=haystack;*s;s++) { + if (toupper(*needle) == toupper(*s) && + strncasecmp(s, needle, nlen) == 0) { + return discard_const_p(char, s); + } + } + return NULL; +} +#endif diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 572113af8c..e3eef56eeb 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -84,6 +84,10 @@ int setenv(const char *name, const char *value, int overwrite); int rename(const char *zfrom, const char *zto); #endif +#ifndef HAVE_STRCASESTR +char *strcasestr(const char *haystack, const char *needle); +#endif + #ifndef HAVE_FTRUNCATE int ftruncate(int f,long l); #endif -- cgit From 2ecb46d595b880c533e2dafea43baf02f009bec6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 14 Oct 2005 12:54:52 +0000 Subject: r11037: (This used to be commit 6913e338405a5aca5c70cf6e022532c596ed0a36) --- source4/lib/replace/SConscript | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript index cf28102175..948c33bdc0 100644 --- a/source4/lib/replace/SConscript +++ b/source4/lib/replace/SConscript @@ -1,5 +1,6 @@ #!/usr/bin/env python Import('hostenv defines') +conf = Configure(hostenv) rep_files = ['replace.c', 'snprintf.c','dlfcn.c'] -- cgit From cffd522b5c806508dfacfb10234e4c0a115c0a98 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 14 Oct 2005 14:02:47 +0000 Subject: r11052: bring samba4 uptodate with the samba4-winsrepl branch, before the bad merge metze (This used to be commit 471c0ca4abb17fb5f73c0efed195c67628c1c06e) --- source4/lib/replace/SConscript | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript index 948c33bdc0..cf28102175 100644 --- a/source4/lib/replace/SConscript +++ b/source4/lib/replace/SConscript @@ -1,6 +1,5 @@ #!/usr/bin/env python Import('hostenv defines') -conf = Configure(hostenv) rep_files = ['replace.c', 'snprintf.c','dlfcn.c'] -- cgit From f4d590662effeb80c2b55ae5ad869b4b7810cf08 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Oct 2005 10:04:57 +0000 Subject: r11214: Remove scons files (see http://lists.samba.org/archive/samba-technical/2005-October/043443.html) (This used to be commit 7fffc5c9178158249be632ac0ca179c13bd1f98f) --- source4/lib/replace/SConscript | 71 ------------------------------------ source4/lib/replace/win32/SConscript | 22 ----------- 2 files changed, 93 deletions(-) delete mode 100644 source4/lib/replace/SConscript delete mode 100644 source4/lib/replace/win32/SConscript (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript deleted file mode 100644 index cf28102175..0000000000 --- a/source4/lib/replace/SConscript +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python -Import('hostenv defines') - -rep_files = ['replace.c', 'snprintf.c','dlfcn.c'] - -if hostenv['configure']: - conf = Configure(hostenv) - for f in ['memset','syslog','setnetgrent','getnetgrent','endnetgrent', \ - 'mktemp', 'memcpy']: - if not conf.CheckFunc(f,'c'): - print "Required function `%s' not found" % f - exit(1) - - for f in ['strtoull','__strtoull','strtouq','strtoll','__strtoll','strtoq', - 'seteuid','setresuid','setegid','setresgid','dlsym','dlopen', - 'dlerror','dlclose','waitpid','getcwd','strdup','strndup', - 'strnlen','strerror','bzero','chroot','strlcpy','strlcat', - 'memmove','vsnprintf','asprintf','snprintf','vasprintf', - 'innetgr','mktime','rename','ftruncate','chsize','setlinebuf', - 'setenv','vsyslog','pread','pwrite']: - if conf.CheckFunc(f,'c'): - defines['HAVE_' + f.upper()] = 1 - - # Check for errno declaration - if conf.TryCompile(""" -#include - -int main() { - int i = (int)errno; - return 0; -}""", '.c'): - defines['HAVE_ERRNO_DECL'] = 1 - - for h in ['dlfcn.h']: - if conf.CheckCHeader('dlfcn.h'): - defines['HAVE_' + h.upper().replace('.','_').replace('/','_')] = 1 - - if not conf.CheckType('socklen_t', "#include "): - defines['socklen_t'] = 'int' - - needed_types = { - 'uint_t': 'unsigned int', - 'int8_t': 'signed char', - 'uint8_t': 'unsigned char', - 'u_int8_t': 'unsigned char', - 'int16_t': 'short', - 'uint16_t': 'unsigned short', - 'u_int16_t': 'unsigned short', - 'int32_t': 'long', - 'uint32_t': 'unsigned long', - 'u_int32_t': 'unsigned long', - 'int64_t': 'long long', - 'uint64_t': 'unsigned long long', - 'ssize_t': 'int' - } - - type_headers = """ -#include -#include -""" - for t in needed_types: - if not conf.CheckType(t,type_headers): - defines[t] = needed_types[t] - - if not conf.TryRun(open("../../build/tests/os2_delete.c").read(), '.c'): - rep_files += ['repdir/repdir.c'] - - conf.Finish() - -hostenv.Library('replace', rep_files) -SConscript(dirs=['win32']) diff --git a/source4/lib/replace/win32/SConscript b/source4/lib/replace/win32/SConscript deleted file mode 100644 index a23fb6a878..0000000000 --- a/source4/lib/replace/win32/SConscript +++ /dev/null @@ -1,22 +0,0 @@ -Import('hostenv defines') - -if hostenv['configure']: - conf = Configure(hostenv) - for h in ['direct.h','windows.h','winsock2.h','ws2tcpip.h']: - if conf.CheckCHeader(h): - defines['HAVE_' + h.upper().replace('.','_')] = 1 - conf.TryCompile(""" -#include -#ifdef HAVE_DIRECT_H -#include -#endif - -int main() -{ - mkdir("foo",0777); - return 0; -} -""", '.c') - - conf.Finish() - -- cgit From 4c5a4a7e0288e9ac0b2f795befd5684059e4c429 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 21 Oct 2005 16:29:54 +0000 Subject: r11244: Relative path names in .mk files (This used to be commit 24e10300906c380919d2d631bfb3b8fd6b3f54ba) --- source4/lib/replace/config.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 2658f0e96a..49133651b4 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -2,7 +2,7 @@ # Start SUBSYSTEM REPLACE_READDIR [SUBSYSTEM::REPLACE_READDIR] ADD_OBJ_FILES = \ - lib/replace/repdir/repdir.o + repdir/repdir.o NOPROTO = YES # End SUBSYSTEM REPLACE_READDIR ############################## @@ -11,10 +11,10 @@ NOPROTO = YES ############################## # Start SUBSYSTEM LIBREPLACE [SUBSYSTEM::LIBREPLACE] -INIT_OBJ_FILES = lib/replace/replace.o +INIT_OBJ_FILES = replace.o ADD_OBJ_FILES = \ - lib/replace/snprintf.o \ - lib/replace/dlfcn.o + snprintf.o \ + dlfcn.o NOPROTO = YES REQUIRED_SUBSYSTEMS = REPLACE_READDIR # End SUBSYSTEM LIBREPLACE -- cgit From 10ec7dd61f563cca0981d65ac3e84ed9f2bd1a12 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 27 Oct 2005 23:02:47 +0000 Subject: r11343: Remove dependency on DEBUG() (This used to be commit 407b5e615f80ab2f7a3d10bafd9284de7f02fe60) --- source4/lib/replace/replace.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index d87a009e8c..5d3ef52987 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -489,11 +489,6 @@ os/2 also doesn't have chroot #ifndef HAVE_CHROOT int chroot(const char *dname) { - static int done; - if (!done) { - DEBUG(1,("WARNING: no chroot!\n")); - done=1; - } errno = ENOSYS; return -1; } -- cgit From a4e7bf3a89a986f0055bb8b6c6890449ca405f39 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Oct 2005 21:13:30 +0000 Subject: r11382: Require number of required M4 macros Make MODULE handling a bit more like BINARY, LIBRARY and SUBSYSTEM Add some more PUBLIC_HEADERS (This used to be commit 875eb8f4cc658e6aebab070029fd499a726ad520) --- source4/lib/replace/repdir/config.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir/config.m4 b/source4/lib/replace/repdir/config.m4 index 02fb6e1816..b17c92e7d6 100644 --- a/source4/lib/replace/repdir/config.m4 +++ b/source4/lib/replace/repdir/config.m4 @@ -12,8 +12,8 @@ AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[ samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)]) fi -SMB_SUBSYSTEM_ENABLE(REPLACE_READDIR, NO) +SMB_ENABLE(REPLACE_READDIR, NO) if test x"$samba_cv_REPLACE_READDIR" = x"yes"; then AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) - SMB_SUBSYSTEM_ENABLE(REPLACE_READDIR, YES) + SMB_ENABLE(REPLACE_READDIR, YES) fi -- cgit From 931b1974a27b929b5b40d65d986f6381a0bc0daa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 19 Nov 2005 01:12:10 +0000 Subject: r11797: Added OpenSSH fix for "%.*s" format crash. From Darren Tucker Jeremy. (This used to be commit a2006c162833f8e0513c2f2744688960c04b7e67) --- source4/lib/replace/snprintf.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index adfd3c4d78..67b00b3d84 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -53,6 +53,12 @@ * got rid of fcvt code (twas buggy and made testing harder) * added C99 semantics * + * Darren Tucker (dtucker@zip.com.au) + * Fix bug allowing read overruns of the source string with "%.*s" + * Usually harmless unless the read runs outside the process' allocation + * (eg if your malloc does guard pages) in which case it will segfault. + * From OpenSSH. Also added test for same. + * **************************************************************/ #ifndef NO_CONFIG_H /* for some tests */ @@ -436,7 +442,7 @@ static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, value = ""; } - for (strln = 0; value[strln]; ++strln); /* strlen */ + for (strln = 0; strln < max && value[strln]; ++strln); /* strlen */ padlen = min - strln; if (padlen < 0) padlen = 0; @@ -851,6 +857,7 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) { char buf1[1024]; char buf2[1024]; + char *buf3; char *fp_fmt[] = { "%1.1f", "%-1.5f", @@ -959,6 +966,20 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) } } +#define BUFSZ 2048 + + if ((buf3 = malloc(BUFSZ)) == NULL) { + fail++; + } else { + num++; + memset(buf3, 'a', BUFSZ); + snprintf(buf1, sizeof(buf1), "%.*s", 1, buf3); + if (strcmp(buf1, "a") != 0) { + printf("length limit buf1 '%s' expected 'a'\n", buf1); + fail++; + } + } + printf ("%d tests failed out of %d.\n", fail, num); printf("seeing how many digits we support\n"); -- cgit From efe67458c17ffa52b48f979505caf11c2ac52c4e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 13 Dec 2005 19:38:12 +0000 Subject: r12216: Couple of small fixes: reduce include/includes.h a bit, simplify headers in build/smb_build/, remove unused pstring macros (This used to be commit 432296207400636dd81d0929ec7b1b4cebbcaa62) --- source4/lib/replace/README | 4 ++++ source4/lib/replace/replace.h | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 45c8bccf13..1e804d50e1 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -56,6 +56,10 @@ uint_t uint{8,16,32,64}_t int{8,16,32,64}_t +Constants: +PATH_NAME_MAX +UINT16_MAX + Prerequisites: memset (for bzero) syslog (for vsyslog) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index e3eef56eeb..fda494a444 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -166,4 +166,8 @@ int rep_mkstemp(char *temp); #define HOST_NAME_MAX 64 #endif +#ifndef UINT16_MAX +#define UINT16_MAX 65535 +#endif + #endif -- cgit From 64b611a18e2425994e611b0af21e9c4362f9f207 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 19 Dec 2005 17:10:18 +0000 Subject: r12364: add UINT32_MAX and UINT64_MAX replacement defines (hopefully fix the build on OpenBSD) metze (This used to be commit cbe06ade214bd29eab5c11fcd011a3c463bf78db) --- source4/lib/replace/README | 2 ++ source4/lib/replace/replace.h | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 1e804d50e1..80a2d5c163 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -59,6 +59,8 @@ int{8,16,32,64}_t Constants: PATH_NAME_MAX UINT16_MAX +UINT32_MAX +UINT64_MAX Prerequisites: memset (for bzero) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index fda494a444..0f1eb42ac0 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -170,4 +170,12 @@ int rep_mkstemp(char *temp); #define UINT16_MAX 65535 #endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef UINT64_MAX +#define UINT64_MAX ((uint64_t)-1) +#endif + #endif -- cgit From d8e35f882879e189f55b3bca818dd44cc5f0c6fa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Dec 2005 18:03:50 +0000 Subject: r12498: Eliminate INIT_OBJ_FILES and ADD_OBJ_FILES. We were not using the difference between these at all, and in the future the fact that INIT_OBJ_FILES include smb_build.h will be sufficient to have recompiles at the right time. (This used to be commit b24f2583edee38abafa58578d8b5c4b43e517def) --- source4/lib/replace/config.mk | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 49133651b4..7ed33b2dc0 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -1,7 +1,7 @@ ############################## # Start SUBSYSTEM REPLACE_READDIR [SUBSYSTEM::REPLACE_READDIR] -ADD_OBJ_FILES = \ +OBJ_FILES = \ repdir/repdir.o NOPROTO = YES # End SUBSYSTEM REPLACE_READDIR @@ -11,8 +11,7 @@ NOPROTO = YES ############################## # Start SUBSYSTEM LIBREPLACE [SUBSYSTEM::LIBREPLACE] -INIT_OBJ_FILES = replace.o -ADD_OBJ_FILES = \ +OBJ_FILES = replace.o \ snprintf.o \ dlfcn.o NOPROTO = YES -- cgit From 46aa296cc94933082dbb4b9b2b1ed210a600ad2d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Dec 2005 23:14:33 +0000 Subject: r12592: Remove some useless dependencies (This used to be commit ca8db1a0cd77682ac2c6dc4718f5d753a4fcc4db) --- source4/lib/replace/README | 2 + source4/lib/replace/config.m4 | 3 + source4/lib/replace/config.mk | 4 +- source4/lib/replace/getpass.c | 158 ++++++++++++++++++++++++++++++++++++++++ source4/lib/replace/getpass.m4 | 15 ++++ source4/lib/replace/readline.c | 119 ++++++++++++++++++++++++++++++ source4/lib/replace/readline.m4 | 72 ++++++++++++++++++ 7 files changed, 371 insertions(+), 2 deletions(-) create mode 100644 source4/lib/replace/getpass.c create mode 100644 source4/lib/replace/getpass.m4 create mode 100644 source4/lib/replace/readline.c create mode 100644 source4/lib/replace/readline.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 80a2d5c163..19364e2faa 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -48,6 +48,8 @@ errno mkstemp (a secure one!) pread pwrite +getpass +readline (the library) Types: socklen_t diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 70d13e40fd..379c14e776 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -124,3 +124,6 @@ LIBS="$SAVE_LIBS" AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) + +sinclude(lib/replace/readline.m4) +sinclude(lib/replace/getpass.m4) diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 7ed33b2dc0..459465c64f 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -7,13 +7,13 @@ NOPROTO = YES # End SUBSYSTEM REPLACE_READDIR ############################## - ############################## # Start SUBSYSTEM LIBREPLACE [SUBSYSTEM::LIBREPLACE] OBJ_FILES = replace.o \ snprintf.o \ - dlfcn.o + dlfcn.o \ + getpass.o NOPROTO = YES REQUIRED_SUBSYSTEMS = REPLACE_READDIR # End SUBSYSTEM LIBREPLACE diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c new file mode 100644 index 0000000000..4ffcde8dfd --- /dev/null +++ b/source4/lib/replace/getpass.c @@ -0,0 +1,158 @@ +/* Copyright (C) 1992-1998 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* Modified to use with samba by Jeremy Allison, 8th July 1995. */ + +#include "includes.h" +#include "system/terminal.h" +#include "system/wait.h" + +#ifdef REPLACE_GETPASS + +#ifdef SYSV_TERMIO + +/* SYSTEM V TERMIO HANDLING */ + +static struct termio t; + +#define ECHO_IS_ON(t) ((t).c_lflag & ECHO) +#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO) +#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO) + +#ifndef TCSAFLUSH +#define TCSAFLUSH 1 +#endif + +#ifndef TCSANOW +#define TCSANOW 0 +#endif + +static int tcgetattr(int fd, struct termio *_t) +{ + return ioctl(fd, TCGETA, _t); +} + +static int tcsetattr(int fd, int flags, struct termio *_t) +{ + if(flags & TCSAFLUSH) + ioctl(fd, TCFLSH, TCIOFLUSH); + return ioctl(fd, TCSETS, _t); +} + +#elif !defined(TCSAFLUSH) + +/* BSD TERMIO HANDLING */ + +static struct sgttyb t; + +#define ECHO_IS_ON(t) ((t).sg_flags & ECHO) +#define TURN_ECHO_OFF(t) ((t).sg_flags &= ~ECHO) +#define TURN_ECHO_ON(t) ((t).sg_flags |= ECHO) + +#define TCSAFLUSH 1 +#define TCSANOW 0 + +static int tcgetattr(int fd, struct sgttyb *_t) +{ + return ioctl(fd, TIOCGETP, (char *)_t); +} + +static int tcsetattr(int fd, int flags, struct sgttyb *_t) +{ + return ioctl(fd, TIOCSETP, (char *)_t); +} + +#else /* POSIX TERMIO HANDLING */ +#define ECHO_IS_ON(t) ((t).c_lflag & ECHO) +#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO) +#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO) + +static struct termios t; +#endif /* SYSV_TERMIO */ + +char *getsmbpass(const char *prompt) +{ + FILE *in, *out; + int echo_off; + static char buf[256]; + static size_t bufsize = sizeof(buf); + size_t nread; + + /* Catch problematic signals */ + CatchSignal(SIGINT, SIGNAL_CAST SIG_IGN); + + /* Try to write to and read from the terminal if we can. + If we can't open the terminal, use stderr and stdin. */ + + in = fopen ("/dev/tty", "w+"); + if (in == NULL) + { + in = stdin; + out = stderr; + } + else + out = in; + + setvbuf(in, NULL, _IONBF, 0); + + /* Turn echoing off if it is on now. */ + + if (tcgetattr (fileno (in), &t) == 0) + { + if (ECHO_IS_ON(t)) + { + TURN_ECHO_OFF(t); + echo_off = tcsetattr (fileno (in), TCSAFLUSH, &t) == 0; + TURN_ECHO_ON(t); + } + else + echo_off = 0; + } + else + echo_off = 0; + + /* Write the prompt. */ + fputs (prompt, out); + fflush (out); + + /* Read the password. */ + buf[0] = 0; + fgets(buf, bufsize, in); + nread = strlen(buf); + if (buf[nread - 1] == '\n') + buf[nread - 1] = '\0'; + + /* Restore echoing. */ + if (echo_off) + (void) tcsetattr (fileno (in), TCSANOW, &t); + + if (in != stdin) + /* We opened the terminal; now close it. */ + fclose (in); + + /* Catch problematic signals */ + CatchSignal(SIGINT, SIGNAL_CAST SIG_DFL); + + printf("\n"); + return buf; +} + +#else + void getsmbpasswd_dummy(void); + void getsmbpasswd_dummy(void) {;} +#endif diff --git a/source4/lib/replace/getpass.m4 b/source4/lib/replace/getpass.m4 new file mode 100644 index 0000000000..2bd9d7bc1a --- /dev/null +++ b/source4/lib/replace/getpass.m4 @@ -0,0 +1,15 @@ +AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[ +SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/smbwrapper" +AC_TRY_COMPILE([ +#define REPLACE_GETPASS 1 +#define NO_CONFIG_H 1 +#define main dont_declare_main +#include "${srcdir-.}/lib/cmdline/getsmbpass.c" +#undef main +],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no) +CPPFLAGS="$SAVE_CPPFLAGS" +]) +if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then + AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced]) +fi diff --git a/source4/lib/replace/readline.c b/source4/lib/replace/readline.c new file mode 100644 index 0000000000..52f45eb759 --- /dev/null +++ b/source4/lib/replace/readline.c @@ -0,0 +1,119 @@ +/* + Unix SMB/CIFS implementation. + Samba readline wrapper implementation + Copyright (C) Simo Sorce 2001 + Copyright (C) Andrew Tridgell 2001 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "pstring.h" + +#include +#include "system/readline.h" + +/**************************************************************************** + Display the prompt and wait for input. Call callback() regularly +****************************************************************************/ + +static char *smb_readline_replacement(const char *prompt, void (*callback)(void), + char **(completion_fn)(const char *text, int start, int end)) +{ + fd_set fds; + static pstring line; + struct timeval timeout; + int fd = STDIN_FILENO; + char *ret; + + do_debug("%s", prompt); + + while (1) { + timeout.tv_sec = 5; + timeout.tv_usec = 0; + + FD_ZERO(&fds); + FD_SET(fd,&fds); + + if (sys_select_intr(fd+1,&fds,NULL,NULL,&timeout) == 1) { + ret = x_fgets(line, sizeof(line), x_stdin); + return ret; + } + if (callback) + callback(); + } +} + +/**************************************************************************** + Display the prompt and wait for input. Call callback() regularly. +****************************************************************************/ + +char *smb_readline(const char *prompt, void (*callback)(void), + char **(completion_fn)(const char *text, int start, int end)) +{ +#if HAVE_LIBREADLINE + if (isatty(STDIN_FILENO)) { + char *ret; + + /* Aargh! Readline does bizzare things with the terminal width + that mucks up expect(1). Set CLI_NO_READLINE in the environment + to force readline not to be used. */ + + if (getenv("CLI_NO_READLINE")) + return smb_readline_replacement(prompt, callback, completion_fn); + + if (completion_fn) { + /* The callback prototype has changed slightly between + different versions of Readline, so the same function + works in all of them to date, but we get compiler + warnings in some. */ + rl_attempted_completion_function = RL_COMPLETION_CAST completion_fn; + } + + if (callback) + rl_event_hook = (Function *)callback; + ret = readline(prompt); + if (ret && *ret) + add_history(ret); + return ret; + } else +#endif + return smb_readline_replacement(prompt, callback, completion_fn); +} + +/**************************************************************************** + * return line buffer text + ****************************************************************************/ +const char *smb_readline_get_line_buffer(void) +{ +#if defined(HAVE_LIBREADLINE) + return rl_line_buffer; +#else + return NULL; +#endif +} + +/**************************************************************************** + * set completion append character + ***************************************************************************/ +void smb_readline_ca_char(char c) +{ +#if defined(HAVE_LIBREADLINE) + rl_completion_append_character = c; +#endif +} + + + diff --git a/source4/lib/replace/readline.m4 b/source4/lib/replace/readline.m4 new file mode 100644 index 0000000000..0d1aa60d17 --- /dev/null +++ b/source4/lib/replace/readline.m4 @@ -0,0 +1,72 @@ +############################################### +# Readline included by default unless explicitly asked not to +test "${with_readline+set}" != "set" && with_readline=yes + +# test for where we get readline() from +AC_MSG_CHECKING(whether to use readline) +AC_ARG_WITH(readline, +[ --with-readline[=DIR] Look for readline include/libs in DIR (default=auto) ], +[ case "$with_readline" in + yes) + AC_MSG_RESULT(yes) + + AC_CHECK_HEADERS(readline.h history.h readline/readline.h) + AC_CHECK_HEADERS(readline/history.h) + + AC_CHECK_HEADERS(readline.h readline/readline.h,[ + for termlib in ncurses curses termcap terminfo termlib tinfo; do + AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break]) + done + AC_CHECK_LIB(readline, rl_callback_handler_install, + [TERMLIBS="-lreadline $TERMLIBS" + AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline]) + break], [TERMLIBS=], $TERMLIBS)]) + ;; + no) + AC_MSG_RESULT(no) + ;; + *) + AC_MSG_RESULT(yes) + + # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at + # alternate readline path + _ldflags=${LDFLAGS} + _cppflags=${CPPFLAGS} + + # Add additional search path + LDFLAGS="-L$with_readline/lib $LDFLAGS" + CPPFLAGS="-I$with_readline/include $CPPFLAGS" + + AC_CHECK_HEADERS(readline.h history.h readline/readline.h) + AC_CHECK_HEADERS(readline/history.h) + + AC_CHECK_HEADERS(readline.h readline/readline.h,[ + for termlib in ncurses curses termcap terminfo termlib; do + AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break]) + done + AC_CHECK_LIB(readline, rl_callback_handler_install, + [TERMLDFLAGS="-L$with_readline/lib" + TERMCPPFLAGS="-I$with_readline/include" + LDFLAGS="-L$with_readline/lib $LDFLAGS" + CPPFLAGS="-I$with_readline/include $CPPFLAGS" + TERMLIBS="-lreadline $TERMLIBS" + AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline]) + break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)]) + + ;; + esac], + AC_MSG_RESULT(no) +) + +# The readline API changed slightly from readline3 to readline4, so +# code will generate warnings on one of them unless we have a few +# special cases. +AC_CHECK_LIB(readline, rl_completion_matches, + [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, + [Do we have rl_completion_matches?])], + [], + [$TERMLIBS]) + +SMB_EXT_LIB(READLINE, [${TERMLIBS}]) + +SMB_SUBSYSTEM(LIBREADLINE, [lib/replace/readline.o], [EXT_LIB_READLINE]) -- cgit From 5c8447773f306e302c7182611e4fc03978c340b6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 9 Jan 2006 21:44:30 +0000 Subject: r12801: Some more include/ cleanups (remove unused macros + move files to specific dirs) (This used to be commit 243cf760b077e155f5ac508aeebf819f7708a84e) --- source4/lib/replace/replace.h | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 0f1eb42ac0..63ec8cfd49 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -100,18 +100,6 @@ int vasprintf(char **ptr, const char *format, va_list ap); #define bzero(a,b) memset((a),'\0',(b)) #endif -#ifndef PRINTF_ATTRIBUTE -#if !defined(NO_PRINTF_ATTRIBUTE) && (__GNUC__ >= 3) -/** Use gcc attribute to check printf fns. a1 is the 1-based index of - * the parameter containing the format, and a2 the index of the first - * argument. Note that some gcc 2.x versions don't handle this - * properly **/ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#endif -#endif - /* add varargs prototypes with printf checking */ #ifndef HAVE_SNPRINTF_DECL int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4); -- cgit From 073866887d8f0ee50037bfe1779bc172d0b6c178 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 10 Jan 2006 07:08:27 +0000 Subject: r12814: we need this here too, as we'll include replace.h for building heimdal/* too, and for this we don't include includes.h (hopefully) fix the build on AIX metze (This used to be commit 32f2cf433f65aaa9bcc5e33958d6f9c72c7f13d9) --- source4/lib/replace/replace.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 63ec8cfd49..0f1eb42ac0 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -100,6 +100,18 @@ int vasprintf(char **ptr, const char *format, va_list ap); #define bzero(a,b) memset((a),'\0',(b)) #endif +#ifndef PRINTF_ATTRIBUTE +#if !defined(NO_PRINTF_ATTRIBUTE) && (__GNUC__ >= 3) +/** Use gcc attribute to check printf fns. a1 is the 1-based index of + * the parameter containing the format, and a2 the index of the first + * argument. Note that some gcc 2.x versions don't handle this + * properly **/ +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) +#else +#define PRINTF_ATTRIBUTE(a1, a2) +#endif +#endif + /* add varargs prototypes with printf checking */ #ifndef HAVE_SNPRINTF_DECL int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4); -- cgit From b8a9bec662d756788126824f7d5605b3b3656f83 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 7 Feb 2006 00:50:38 +0000 Subject: r13374: new revision of the snprintf replace code still missing a configure test to make us substitute our snprintf to system one when the system one does not have positional parameters support (This used to be commit 398f989d6580587eb1fa4fec0b1ed858b5cbe8e1) --- source4/lib/replace/snprintf.c | 898 ++++++++++++++++++++++++++++++----------- 1 file changed, 672 insertions(+), 226 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 67b00b3d84..379e15cf6d 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -1,3 +1,7 @@ +/* + * NOTE: If you change this file, please merge it into rsync, samba, etc. + */ + /* * Copyright Patrick Powell 1995 * This code is based on code written by Patrick Powell (papowell@astart.com) @@ -53,23 +57,69 @@ * got rid of fcvt code (twas buggy and made testing harder) * added C99 semantics * - * Darren Tucker (dtucker@zip.com.au) + * date: 2002/12/19 19:56:31; author: herb; state: Exp; lines: +2 -0 + * actually print args for %g and %e + * + * date: 2002/06/03 13:37:52; author: jmcd; state: Exp; lines: +8 -0 + * Since includes.h isn't included here, VA_COPY has to be defined here. I don't + * see any include file that is guaranteed to be here, so I'm defining it + * locally. Fixes AIX and Solaris builds. + * + * date: 2002/06/03 03:07:24; author: tridge; state: Exp; lines: +5 -13 + * put the ifdef for HAVE_VA_COPY in one place rather than in lots of + * functions + * + * date: 2002/05/17 14:51:22; author: jmcd; state: Exp; lines: +21 -4 + * Fix usage of va_list passed as an arg. Use __va_copy before using it + * when it exists. + * + * date: 2002/04/16 22:38:04; author: idra; state: Exp; lines: +20 -14 + * Fix incorrect zpadlen handling in fmtfp. + * Thanks to Ollie Oldham for spotting it. + * few mods to make it easier to compile the tests. + * addedd the "Ollie" test to the floating point ones. + * + * Martin Pool (mbp@samba.org) April 2003 + * Remove NO_CONFIG_H so that the test case can be built within a source + * tree with less trouble. + * Remove unnecessary SAFE_FREE() definition. + * + * Martin Pool (mbp@samba.org) May 2003 + * Put in a prototype for dummy_snprintf() to quiet compiler warnings. + * + * Move #endif to make sure VA_COPY, LDOUBLE, etc are defined even + * if the C library has some snprintf functions already. + * + * Darren Tucker (dtucker@zip.com.au) 2005 * Fix bug allowing read overruns of the source string with "%.*s" * Usually harmless unless the read runs outside the process' allocation * (eg if your malloc does guard pages) in which case it will segfault. * From OpenSSH. Also added test for same. * + * Simo Sorce (idra@samba.org) Jan 2006 + * + * Add support for position independent parameters + * fix fmtstr now it conforms to sprintf wrt min.max + * **************************************************************/ -#ifndef NO_CONFIG_H /* for some tests */ +#ifndef NO_CONFIG_H #include "config.h" #else #define NULL 0 -#endif +#endif #ifdef TEST_SNPRINTF /* need math library headers for testing */ -#include -#endif + +/* In test mode, we pretend that this system doesn't have any snprintf + * functions, regardless of what config.h says. */ +# undef HAVE_SNPRINTF +# undef HAVE_VSNPRINTF +# undef HAVE_C99_VSNPRINTF +# undef HAVE_ASPRINTF +# undef HAVE_VASPRINTF +# include +#endif /* TEST_SNPRINTF */ #ifdef HAVE_STRING_H #include @@ -87,23 +137,13 @@ #include #endif -#ifndef VA_COPY -#ifdef HAVE_VA_COPY -#define VA_COPY(dest, src) va_copy(dest, src) -#elif defined(HAVE___VA_COPY) -#define VA_COPY(dest, src) __va_copy(dest, src) -#else -#define VA_COPY(dest, src) (dest) = (src) -#endif -#endif - - #if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF) /* only include stdio.h if we are not re-defining snprintf or vsnprintf */ #include /* make the compiler happy with an empty file */ + void dummy_snprintf(void); void dummy_snprintf(void) {} -#else +#endif /* HAVE_SNPRINTF, etc */ #ifdef HAVE_LONG_DOUBLE #define LDOUBLE long double @@ -117,20 +157,16 @@ #define LLONG long #endif -/* free memory if the pointer is valid and zero the pointer */ -#ifndef SAFE_FREE -#define SAFE_FREE(x) do { if ((x) != NULL) {free((x)); (x)=NULL;} } while(0) +#ifndef VA_COPY +#ifdef HAVE_VA_COPY +#define VA_COPY(dest, src) va_copy(dest, src) +#else +#ifdef HAVE___VA_COPY +#define VA_COPY(dest, src) __va_copy(dest, src) +#else +#define VA_COPY(dest, src) (dest) = (src) +#endif #endif - -static size_t dopr(char *buffer, size_t maxlen, const char *format, - va_list args_in); -static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, - char *value, int flags, int min, int max); -static void fmtint(char *buffer, size_t *currlen, size_t maxlen, - long value, int base, int min, int max, int flags); -static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, - LDOUBLE fvalue, int min, int max, int flags); -static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); /* * dopr(): poor man's version of doprintf @@ -156,69 +192,147 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); #define DP_F_UNSIGNED (1 << 6) /* Conversion Flags */ -#define DP_C_SHORT 1 -#define DP_C_LONG 2 -#define DP_C_LDOUBLE 3 -#define DP_C_LLONG 4 +#define DP_C_CHAR 1 +#define DP_C_SHORT 2 +#define DP_C_LONG 3 +#define DP_C_LDOUBLE 4 +#define DP_C_LLONG 5 + +/* Chunk types */ +#define CNK_FMT_STR 0 +#define CNK_INT 1 +#define CNK_OCTAL 2 +#define CNK_UINT 3 +#define CNK_HEX 4 +#define CNK_FLOAT 5 +#define CNK_CHAR 6 +#define CNK_STRING 7 +#define CNK_PTR 8 +#define CNK_NUM 9 +#define CNK_PRCNT 10 #define char_to_int(p) ((p)- '0') #ifndef MAX #define MAX(p,q) (((p) >= (q)) ? (p) : (q)) #endif -static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args_in) -{ - char ch; +/* yes this really must be a ||. Don't muck with this (tridge) */ +#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) + +struct pr_chunk { + int type; /* chunk type */ + int num; /* parameter number */ + int min; + int max; + int flags; + int cflags; + int start; + int len; LLONG value; LDOUBLE fvalue; char *strvalue; - int min; - int max; + void *pnum; + struct pr_chunk *min_star; + struct pr_chunk *max_star; + struct pr_chunk *next; +}; + +struct pr_chunk_x { + struct pr_chunk **chunks; + int num; +}; + +static size_t dopr(char *buffer, size_t maxlen, const char *format, + va_list args_in); +static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max); +static void fmtint(char *buffer, size_t *currlen, size_t maxlen, + long value, int base, int min, int max, int flags); +static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags); +static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); +static struct pr_chunk *new_chunk(void); +static int add_cnk_list_entry(struct pr_chunk_x **list, + int max_num, struct pr_chunk *chunk); + +static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args_in) +{ + char ch; int state; - int flags; - int cflags; + int pflag; + int pnum; + int pfirst; size_t currlen; va_list args; + const char *base; + struct pr_chunk *chunks = NULL; + struct pr_chunk *cnk = NULL; + struct pr_chunk_x *clist = NULL; + int max_pos; + size_t ret = -1; VA_COPY(args, args_in); - + state = DP_S_DEFAULT; - currlen = flags = cflags = min = 0; - max = -1; + pfirst = 1; + pflag = 0; + pnum = 0; + + max_pos = 0; + base = format; ch = *format++; + /* retrieve the string structure as chunks */ while (state != DP_S_DONE) { if (ch == '\0') state = DP_S_DONE; switch(state) { case DP_S_DEFAULT: - if (ch == '%') + + if (cnk) { + cnk->next = new_chunk(); + cnk = cnk->next; + } else { + cnk = new_chunk(); + } + if (!cnk) goto done; + if (!chunks) chunks = cnk; + + if (ch == '%') { state = DP_S_FLAGS; - else - dopr_outch (buffer, &currlen, maxlen, ch); - ch = *format++; + ch = *format++; + } else { + cnk->type = CNK_FMT_STR; + cnk->start = format - base -1; + while ((ch != '\0') && (ch != '%')) ch = *format++; + cnk->len = format - base - cnk->start -1; + } break; case DP_S_FLAGS: switch (ch) { case '-': - flags |= DP_F_MINUS; + cnk->flags |= DP_F_MINUS; ch = *format++; break; case '+': - flags |= DP_F_PLUS; + cnk->flags |= DP_F_PLUS; ch = *format++; break; case ' ': - flags |= DP_F_SPACE; + cnk->flags |= DP_F_SPACE; ch = *format++; break; case '#': - flags |= DP_F_NUM; + cnk->flags |= DP_F_NUM; ch = *format++; break; case '0': - flags |= DP_F_ZERO; + cnk->flags |= DP_F_ZERO; + ch = *format++; + break; + case 'I': + /* internationalization not supported yet */ ch = *format++; break; default: @@ -228,13 +342,51 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args break; case DP_S_MIN: if (isdigit((unsigned char)ch)) { - min = 10*min + char_to_int (ch); + cnk->min = 10 * cnk->min + char_to_int (ch); + ch = *format++; + } else if (ch == '$') { + if (!pfirst && !pflag) { + /* parameters must be all positioned or none */ + goto done; + } + if (pfirst) { + pfirst = 0; + pflag = 1; + } + if (cnk->min == 0) /* what ?? */ + goto done; + cnk->num = cnk->min; + cnk->min = 0; ch = *format++; } else if (ch == '*') { - min = va_arg (args, int); + if (pfirst) pfirst = 0; + cnk->min_star = new_chunk(); + if (!cnk->min_star) /* out of memory :-( */ + goto done; + cnk->min_star->type = CNK_INT; + if (pflag) { + int num; + ch = *format++; + if (!isdigit((unsigned char)ch)) { + /* parameters must be all positioned or none */ + goto done; + } + for (num = 0; isdigit((unsigned char)ch); ch = *format++) { + num = 10 * num + char_to_int(ch); + } + cnk->min_star->num = num; + if (ch != '$') /* what ?? */ + goto done; + } else { + cnk->min_star->num = ++pnum; + } + max_pos = add_cnk_list_entry(&clist, max_pos, cnk->min_star); + if (max_pos == 0) /* out of memory :-( */ + goto done; ch = *format++; state = DP_S_DOT; } else { + if (pfirst) pfirst = 0; state = DP_S_DOT; } break; @@ -248,12 +400,45 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args break; case DP_S_MAX: if (isdigit((unsigned char)ch)) { - if (max < 0) - max = 0; - max = 10*max + char_to_int (ch); + if (cnk->max < 0) + cnk->max = 0; + cnk->max = 10 * cnk->max + char_to_int (ch); + ch = *format++; + } else if (ch == '$') { + if (!pfirst && !pflag) { + /* parameters must be all positioned or none */ + goto done; + } + if (cnk->max <= 0) /* what ?? */ + goto done; + cnk->num = cnk->max; + cnk->max = -1; ch = *format++; } else if (ch == '*') { - max = va_arg (args, int); + cnk->max_star = new_chunk(); + if (!cnk->max_star) /* out of memory :-( */ + goto done; + cnk->max_star->type = CNK_INT; + if (pflag) { + int num; + ch = *format++; + if (!isdigit((unsigned char)ch)) { + /* parameters must be all positioned or none */ + goto done; + } + for (num = 0; isdigit((unsigned char)ch); ch = *format++) { + num = 10 * num + char_to_int(ch); + } + cnk->max_star->num = num; + if (ch != '$') /* what ?? */ + goto done; + } else { + cnk->max_star->num = ++pnum; + } + max_pos = add_cnk_list_entry(&clist, max_pos, cnk->max_star); + if (max_pos == 0) /* out of memory :-( */ + goto done; + ch = *format++; state = DP_S_MOD; } else { @@ -263,19 +448,23 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args case DP_S_MOD: switch (ch) { case 'h': - cflags = DP_C_SHORT; + cnk->cflags = DP_C_SHORT; ch = *format++; + if (ch == 'h') { + cnk->cflags = DP_C_CHAR; + ch = *format++; + } break; case 'l': - cflags = DP_C_LONG; + cnk->cflags = DP_C_LONG; ch = *format++; if (ch == 'l') { /* It's a long long */ - cflags = DP_C_LLONG; + cnk->cflags = DP_C_LLONG; ch = *format++; } break; case 'L': - cflags = DP_C_LDOUBLE; + cnk->cflags = DP_C_LDOUBLE; ch = *format++; break; default: @@ -284,133 +473,64 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args state = DP_S_CONV; break; case DP_S_CONV: + if (cnk->num == 0) cnk->num = ++pnum; + max_pos = add_cnk_list_entry(&clist, max_pos, cnk); + if (max_pos == 0) /* out of memory :-( */ + goto done; + switch (ch) { case 'd': case 'i': - if (cflags == DP_C_SHORT) - value = va_arg (args, int); - else if (cflags == DP_C_LONG) - value = va_arg (args, long int); - else if (cflags == DP_C_LLONG) - value = va_arg (args, LLONG); - else - value = va_arg (args, int); - fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + cnk->type = CNK_INT; break; case 'o': - flags |= DP_F_UNSIGNED; - if (cflags == DP_C_SHORT) - value = va_arg (args, unsigned int); - else if (cflags == DP_C_LONG) - value = (long)va_arg (args, unsigned long int); - else if (cflags == DP_C_LLONG) - value = (long)va_arg (args, unsigned LLONG); - else - value = (long)va_arg (args, unsigned int); - fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); + cnk->type = CNK_OCTAL; + cnk->flags |= DP_F_UNSIGNED; break; case 'u': - flags |= DP_F_UNSIGNED; - if (cflags == DP_C_SHORT) - value = va_arg (args, unsigned int); - else if (cflags == DP_C_LONG) - value = (long)va_arg (args, unsigned long int); - else if (cflags == DP_C_LLONG) - value = (LLONG)va_arg (args, unsigned LLONG); - else - value = (long)va_arg (args, unsigned int); - fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + cnk->type = CNK_UINT; + cnk->flags |= DP_F_UNSIGNED; break; case 'X': - flags |= DP_F_UP; + cnk->flags |= DP_F_UP; case 'x': - flags |= DP_F_UNSIGNED; - if (cflags == DP_C_SHORT) - value = va_arg (args, unsigned int); - else if (cflags == DP_C_LONG) - value = (long)va_arg (args, unsigned long int); - else if (cflags == DP_C_LLONG) - value = (LLONG)va_arg (args, unsigned LLONG); - else - value = (long)va_arg (args, unsigned int); - fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); - break; - case 'f': - if (cflags == DP_C_LDOUBLE) - fvalue = va_arg (args, LDOUBLE); - else - fvalue = va_arg (args, double); - /* um, floating point? */ - fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + cnk->type = CNK_HEX; + cnk->flags |= DP_F_UNSIGNED; break; + case 'A': + /* hex float not supported yet */ case 'E': - flags |= DP_F_UP; - case 'e': - if (cflags == DP_C_LDOUBLE) - fvalue = va_arg (args, LDOUBLE); - else - fvalue = va_arg (args, double); - fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); - break; case 'G': - flags |= DP_F_UP; + case 'F': + cnk->flags |= DP_F_UP; + case 'a': + /* hex float not supported yet */ + case 'e': + case 'f': case 'g': - if (cflags == DP_C_LDOUBLE) - fvalue = va_arg (args, LDOUBLE); - else - fvalue = va_arg (args, double); - fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + cnk->type = CNK_FLOAT; break; case 'c': - dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); + cnk->type = CNK_CHAR; break; case 's': - strvalue = va_arg (args, char *); - if (!strvalue) strvalue = "(NULL)"; - if (max == -1) { - max = strlen(strvalue); - } - if (min > 0 && max >= 0 && min > max) max = min; - fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); + cnk->type = CNK_STRING; break; case 'p': - strvalue = va_arg (args, void *); - fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); + cnk->type = CNK_PTR; break; case 'n': - if (cflags == DP_C_SHORT) { - short int *num; - num = va_arg (args, short int *); - *num = currlen; - } else if (cflags == DP_C_LONG) { - long int *num; - num = va_arg (args, long int *); - *num = (long int)currlen; - } else if (cflags == DP_C_LLONG) { - LLONG *num; - num = va_arg (args, LLONG *); - *num = (LLONG)currlen; - } else { - int *num; - num = va_arg (args, int *); - *num = currlen; - } + cnk->type = CNK_NUM; break; case '%': - dopr_outch (buffer, &currlen, maxlen, ch); - break; - case 'w': - /* not supported yet, treat as next char */ - ch = *format++; + cnk->type = CNK_PRCNT; break; default: - /* Unknown, skip */ - break; + /* Unknown, bail out*/ + goto done; } ch = *format++; state = DP_S_DEFAULT; - flags = cflags = min = 0; - max = -1; break; case DP_S_DONE: break; @@ -419,14 +539,227 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args break; /* some picky compilers need this */ } } + + /* retieve the format arguments */ + for (pnum = 0; pnum < max_pos; pnum++) { + int i; + + if (clist[pnum].num == 0) { + /* ignoring a parameter should not be permitted + * all parameters must be matched at least once + * BUT seem some system ignore this rule ... + * at least my glibc based system does --SSS + */ +#ifdef DEBUG_SNPRINTF + printf("parameter at position %d not used\n", pnum+1); +#endif + /* eat the parameter */ + va_arg (args, int); + continue; + } + for (i = 1; i < clist[pnum].num; i++) { + if (clist[pnum].chunks[0]->type != clist[pnum].chunks[i]->type) { + /* nooo noo no! + * all the references to a parameter + * must be of the same type + */ + goto done; + } + } + cnk = clist[pnum].chunks[0]; + switch (cnk->type) { + case CNK_INT: + if (cnk->cflags == DP_C_SHORT) + cnk->value = va_arg (args, int); + else if (cnk->cflags == DP_C_LONG) + cnk->value = va_arg (args, long int); + else if (cnk->cflags == DP_C_LLONG) + cnk->value = va_arg (args, LLONG); + else + cnk->value = va_arg (args, int); + + for (i = 1; i < clist[pnum].num; i++) { + clist[pnum].chunks[i]->value = cnk->value; + } + break; + + case CNK_OCTAL: + case CNK_UINT: + case CNK_HEX: + if (cnk->cflags == DP_C_SHORT) + cnk->value = va_arg (args, unsigned int); + else if (cnk->cflags == DP_C_LONG) + cnk->value = (long)va_arg (args, unsigned long int); + else if (cnk->cflags == DP_C_LLONG) + cnk->value = (LLONG)va_arg (args, unsigned LLONG); + else + cnk->value = (long)va_arg (args, unsigned int); + + for (i = 1; i < clist[pnum].num; i++) { + clist[pnum].chunks[i]->value = cnk->value; + } + break; + + case CNK_FLOAT: + if (cnk->cflags == DP_C_LDOUBLE) + cnk->fvalue = va_arg (args, LDOUBLE); + else + cnk->fvalue = va_arg (args, double); + + for (i = 1; i < clist[pnum].num; i++) { + clist[pnum].chunks[i]->fvalue = cnk->fvalue; + } + break; + + case CNK_CHAR: + cnk->value = va_arg (args, int); + + for (i = 1; i < clist[pnum].num; i++) { + clist[pnum].chunks[i]->value = cnk->value; + } + break; + + case CNK_STRING: + cnk->strvalue = va_arg (args, char *); + if (!cnk->strvalue) cnk->strvalue = "(NULL)"; + + for (i = 1; i < clist[pnum].num; i++) { + clist[pnum].chunks[i]->strvalue = cnk->strvalue; + } + break; + + case CNK_PTR: + cnk->strvalue = va_arg (args, void *); + for (i = 1; i < clist[pnum].num; i++) { + clist[pnum].chunks[i]->strvalue = cnk->strvalue; + } + break; + + case CNK_NUM: + if (cnk->cflags == DP_C_CHAR) + cnk->pnum = va_arg (args, char *); + else if (cnk->cflags == DP_C_SHORT) + cnk->pnum = va_arg (args, short int *); + else if (cnk->cflags == DP_C_LONG) + cnk->pnum = va_arg (args, long int *); + else if (cnk->cflags == DP_C_LLONG) + cnk->pnum = va_arg (args, LLONG *); + else + cnk->pnum = va_arg (args, int *); + + for (i = 1; i < clist[pnum].num; i++) { + clist[pnum].chunks[i]->pnum = cnk->pnum; + } + break; + + case CNK_PRCNT: + break; + + default: + /* what ?? */ + goto done; + } + } + /* print out the actual string from chunks */ + currlen = 0; + cnk = chunks; + while (cnk) { + int len, min, max; + + if (cnk->min_star) min = cnk->min_star->value; + else min = cnk->min; + if (cnk->max_star) max = cnk->max_star->value; + else max = cnk->max; + + switch (cnk->type) { + + case CNK_FMT_STR: + if (maxlen != 0 && maxlen > currlen) { + if (maxlen > (currlen + cnk->len)) len = cnk->len; + else len = maxlen - currlen; + + memcpy(&(buffer[currlen]), &(base[cnk->start]), len); + } + currlen += cnk->len; + + break; + + case CNK_INT: + case CNK_UINT: + fmtint (buffer, &currlen, maxlen, cnk->value, 10, min, max, cnk->flags); + break; + + case CNK_OCTAL: + fmtint (buffer, &currlen, maxlen, cnk->value, 8, min, max, cnk->flags); + break; + + case CNK_HEX: + fmtint (buffer, &currlen, maxlen, cnk->value, 16, min, max, cnk->flags); + break; + + case CNK_FLOAT: + fmtfp (buffer, &currlen, maxlen, cnk->fvalue, min, max, cnk->flags); + break; + + case CNK_CHAR: + dopr_outch (buffer, &currlen, maxlen, cnk->value); + break; + + case CNK_STRING: + if (max == -1) { + max = strlen(cnk->strvalue); + } + fmtstr (buffer, &currlen, maxlen, cnk->strvalue, cnk->flags, min, max); + break; + + case CNK_PTR: + fmtint (buffer, &currlen, maxlen, (long)(cnk->strvalue), 16, min, max, cnk->flags); + break; + + case CNK_NUM: + if (cnk->cflags == DP_C_CHAR) + *((char *)(cnk->pnum)) = (char)currlen; + else if (cnk->cflags == DP_C_SHORT) + *((short int *)(cnk->pnum)) = (short int)currlen; + else if (cnk->cflags == DP_C_LONG) + *((long int *)(cnk->pnum)) = (long int)currlen; + else if (cnk->cflags == DP_C_LLONG) + *((LLONG *)(cnk->pnum)) = (LLONG)currlen; + else + *((int *)(cnk->pnum)) = (int)currlen; + break; + + case CNK_PRCNT: + dopr_outch (buffer, &currlen, maxlen, '%'); + break; + + default: + /* what ?? */ + goto done; + } + cnk = cnk->next; + } if (maxlen != 0) { if (currlen < maxlen - 1) buffer[currlen] = '\0'; else if (maxlen > 0) buffer[maxlen - 1] = '\0'; } - - return currlen; + ret = currlen; + +done: + while (chunks) { + cnk = chunks->next; + free(chunks); + chunks = cnk; + } + if (clist) { + for (pnum = 0; pnum < max_pos; pnum++) { + if (clist[pnum].chunks) free(clist[pnum].chunks); + } + free(clist); + } + return ret; } static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, @@ -449,19 +782,17 @@ static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justify */ - while ((padlen > 0) && (cnt < max)) { + while (padlen > 0) { dopr_outch (buffer, currlen, maxlen, ' '); --padlen; - ++cnt; } while (*value && (cnt < max)) { dopr_outch (buffer, currlen, maxlen, *value++); ++cnt; } - while ((padlen < 0) && (cnt < max)) { + while (padlen < 0) { dopr_outch (buffer, currlen, maxlen, ' '); ++padlen; - ++cnt; } } @@ -632,7 +963,7 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, int padlen = 0; /* amount to pad */ int zpadlen = 0; int caps = 0; - int index; + int idx; double intpart; double fracpart; double temp; @@ -666,11 +997,11 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, #endif /* - * Sorry, we only support 16 digits past the decimal because of our + * Sorry, we only support 9 digits past the decimal because of our * conversion method */ - if (max > 16) - max = 16; + if (max > 9) + max = 9; /* We "cheat" by converting the fractional part to integer by * multiplying by a factor of 10 @@ -691,11 +1022,11 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, do { temp = intpart*0.1; my_modf(temp, &intpart); - index = (int) ((temp -intpart +0.05)* 10.0); - /* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */ - /* printf ("%llf, %f, %x\n", temp, intpart, index); */ + idx = (int) ((temp -intpart +0.05)* 10.0); + /* idx = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */ + /* printf ("%llf, %f, %x\n", temp, intpart, idx); */ iconvert[iplace++] = - (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; + (caps? "0123456789ABCDEF":"0123456789abcdef")[idx]; } while (intpart && (iplace < 311)); if (iplace == 311) iplace--; iconvert[iplace] = 0; @@ -706,11 +1037,11 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, do { temp = fracpart*0.1; my_modf(temp, &fracpart); - index = (int) ((temp -fracpart +0.05)* 10.0); - /* index = (int) ((((temp/10) -fracpart) +0.05) *10); */ - /* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */ + idx = (int) ((temp -fracpart +0.05)* 10.0); + /* idx = (int) ((((temp/10) -fracpart) +0.05) *10); */ + /* printf ("%lf, %lf, %ld\n", temp, fracpart, idx ); */ fconvert[fplace++] = - (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; + (caps? "0123456789ABCDEF":"0123456789abcdef")[idx]; } while(fracpart && (fplace < 311)); if (fplace == 311) fplace--; } @@ -780,24 +1111,97 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) (*currlen)++; } -/* yes this really must be a ||. Don't muck with this (tridge) */ -#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) - int vsnprintf (char *str, size_t count, const char *fmt, va_list args) +static struct pr_chunk *new_chunk(void) { + struct pr_chunk *new = (struct pr_chunk *)malloc(sizeof(struct pr_chunk)); + + if (!new) return NULL; + + new->type = 0; + new->num = 0; + new->min = 0; + new->min_star = NULL; + new->max = -1; + new->max_star = NULL; + new->flags = 0; + new->cflags = 0; + new->start = 0; + new->len = 0; + new->value = 0; + new->fvalue = 0; + new->strvalue = NULL; + new->pnum = NULL; + new->next = NULL; +} + +static int add_cnk_list_entry(struct pr_chunk_x **list, + int max_num, struct pr_chunk *chunk) { + struct pr_chunk_x *l; + struct pr_chunk **c; + int max; + int cnum; + int i, pos; + + if (chunk->num > max_num) { + max = chunk->num; + + if (*list == NULL) { + l = (struct pr_chunk_x *)malloc(sizeof(struct pr_chunk_x) * max); + pos = 0; + } else { + l = (struct pr_chunk_x *)realloc(*list, sizeof(struct pr_chunk_x) * max); + pos = max_num; + } + if (l == NULL) { + for (i = 0; i < max; i++) { + if ((*list)[i].chunks) free((*list)[i].chunks); + } + return 0; + } + for (i = pos; i < max; i++) { + l[i].chunks = NULL; + l[i].num = 0; + } + } else { + l = *list; + max = max_num; + } + + i = chunk->num - 1; + cnum = l[i].num + 1; + if (l[i].chunks == NULL) { + c = (struct pr_chunk **)malloc(sizeof(struct pr_chunk *) * cnum); + } else { + c = (struct pr_chunk **)realloc(l[i].chunks, sizeof(struct pr_chunk *) * cnum); + } + if (c == NULL) { + for (i = 0; i < max; i++) { + if (l[i].chunks) free(l[i].chunks); + } + return 0; + } + c[l[i].num] = chunk; + l[i].chunks = c; + l[i].num = cnum; + + *list = l; + return max; +} + + int smb_vsnprintf (char *str, size_t count, const char *fmt, va_list args) { return dopr(str, count, fmt, args); } +#define vsnprintf smb_vsnprintf #endif -/* yes this really must be a ||. Don't muck wiith this (tridge) +/* yes this really must be a ||. Don't muck with this (tridge) * * The logic for these two is that we need our own definition if the * OS *either* has no definition of *sprintf, or if it does have one - * that doesn't work properly according to the autoconf test. Perhaps - * these should really be smb_snprintf to avoid conflicts with buggy - * linkers? -- mbp + * that doesn't work properly according to the autoconf test. */ -#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_SNPRINTF) - int snprintf(char *str,size_t count,const char *fmt,...) +#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF) +int smb_snprintf(char *str,size_t count,const char *fmt,...) { size_t ret; va_list ap; @@ -807,6 +1211,7 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) va_end(ap); return ret; } +#define snprintf smb_snprintf #endif #endif @@ -873,11 +1278,13 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) "%3.2f", "%.0f", "%f", - "-16.16f", + "%-8.8f", + "%-9.9f", NULL }; - double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, - 0.9996, 1.996, 4.136, 5.030201, 0}; + double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 203.9, 0.96, 0.996, + 0.9996, 1.996, 4.136, 5.030201, 0.00205, + /* END LIST */ 0}; char *int_fmt[] = { "%-1.5d", "%1.5d", @@ -891,14 +1298,16 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) "%d", NULL }; - long int_nums[] = { -1, 134, 91340, 341, 0203, 0}; + long int_nums[] = { -1, 134, 91340, 341, 0203, 0, 1234567890}; char *str_fmt[] = { - "10.5s", - "5.10s", - "10.1s", - "0.10s", - "10.0s", - "1.10s", + "%10.5s", + "%-10.5s", + "%5.10s", + "%-5.10s", + "%10.1s", + "%0.10s", + "%10.0s", + "%1.10s", "%s", "%.1s", "%.10s", @@ -909,21 +1318,20 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) int x, y; int fail = 0; int num = 0; + int l1, l2; printf ("Testing snprintf format codes against system sprintf...\n"); for (x = 0; fp_fmt[x] ; x++) { for (y = 0; fp_nums[y] != 0 ; y++) { - int l1 = snprintf(NULL, 0, fp_fmt[x], fp_nums[y]); - int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]); + buf1[0] = buf2[0] = '\0'; + l1 = snprintf(NULL, 0, fp_fmt[x], fp_nums[y]); + l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]); sprintf (buf2, fp_fmt[x], fp_nums[y]); - if (strcmp (buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", - fp_fmt[x], buf1, buf2); - fail++; - } - if (l1 != l2) { - printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, fp_fmt[x]); + buf1[1023] = buf1[1023] = '\0'; + if (strcmp (buf1, buf2) || (l1 != l2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", + fp_fmt[x], l1, buf1, l2, buf2); fail++; } num++; @@ -932,16 +1340,14 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) for (x = 0; int_fmt[x] ; x++) { for (y = 0; int_nums[y] != 0 ; y++) { - int l1 = snprintf(NULL, 0, int_fmt[x], int_nums[y]); - int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]); + buf1[0] = buf2[0] = '\0'; + l1 = snprintf(NULL, 0, int_fmt[x], int_nums[y]); + l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]); sprintf (buf2, int_fmt[x], int_nums[y]); - if (strcmp (buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", - int_fmt[x], buf1, buf2); - fail++; - } - if (l1 != l2) { - printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, int_fmt[x]); + buf1[1023] = buf1[1023] = '\0'; + if (strcmp (buf1, buf2) || (l1 != l2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", + int_fmt[x], l1, buf1, l2, buf2); fail++; } num++; @@ -950,16 +1356,14 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) for (x = 0; str_fmt[x] ; x++) { for (y = 0; str_vals[y] != 0 ; y++) { - int l1 = snprintf(NULL, 0, str_fmt[x], str_vals[y]); - int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]); + buf1[0] = buf2[0] = '\0'; + l1 = snprintf(NULL, 0, str_fmt[x], str_vals[y]); + l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]); sprintf (buf2, str_fmt[x], str_vals[y]); - if (strcmp (buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", - str_fmt[x], buf1, buf2); - fail++; - } - if (l1 != l2) { - printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, str_fmt[x]); + buf1[1023] = buf1[1023] = '\0'; + if (strcmp (buf1, buf2) || (l1 != l2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", + str_fmt[x], l1, buf1, l2, buf2); fail++; } num++; @@ -968,18 +1372,60 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) #define BUFSZ 2048 + buf1[0] = buf2[0] = '\0'; if ((buf3 = malloc(BUFSZ)) == NULL) { fail++; } else { num++; memset(buf3, 'a', BUFSZ); snprintf(buf1, sizeof(buf1), "%.*s", 1, buf3); + buf1[1023] = '\0'; if (strcmp(buf1, "a") != 0) { printf("length limit buf1 '%s' expected 'a'\n", buf1); fail++; } + } + + buf1[0] = buf2[0] = '\0'; + l1 = snprintf(buf1, sizeof(buf1), "%4$*1$d %2$s %3$*1$.*1$f", 3, "pos test", 12.3456, 9); + l2 = sprintf(buf2, "%4$*1$d %2$s %3$*1$.*1$f", 3, "pos test", 12.3456, 9); + buf1[1023] = buf1[1023] = '\0'; + if (strcmp(buf1, buf2) || (l1 != l2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", + "%4$*1$d %2$s %3$*1$.*1$f", l1, buf1, l2, buf2); + fail++; + } + + buf1[0] = buf2[0] = '\0'; + l1 = snprintf(buf1, sizeof(buf1), "%4$*4$d %2$s %3$*4$.*4$f", 3, "pos test", 12.3456, 9); + l2 = sprintf(buf2, "%4$*4$d %2$s %3$*4$.*4$f", 3, "pos test", 12.3456, 9); + buf1[1023] = buf1[1023] = '\0'; + if (strcmp(buf1, buf2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", + "%4$*1$d %2$s %3$*1$.*1$f", l1, buf1, l2, buf2); + fail++; + } +#if 0 + buf1[0] = buf2[0] = '\0'; + l1 = snprintf(buf1, sizeof(buf1), "%lld", (LLONG)1234567890); + l2 = sprintf(buf2, "%lld", (LLONG)1234567890); + buf1[1023] = buf1[1023] = '\0'; + if (strcmp(buf1, buf2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", + "%lld", l1, buf1, l2, buf2); + fail++; } + buf1[0] = buf2[0] = '\0'; + l1 = snprintf(buf1, sizeof(buf1), "%Lf", (LDOUBLE)890.1234567890123); + l2 = sprintf(buf2, "%Lf", (LDOUBLE)890.1234567890123); + buf1[1023] = buf1[1023] = '\0'; + if (strcmp(buf1, buf2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", + "%Lf", l1, buf1, l2, buf2); + fail++; + } +#endif printf ("%d tests failed out of %d.\n", fail, num); printf("seeing how many digits we support\n"); @@ -999,4 +1445,4 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) return 0; } -#endif /* SNPRINTF_TEST */ +#endif /* TEST_SNPRINTF */ -- cgit From 4c78d1bfa21947f649b061279e7388c478f77fe0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 9 Feb 2006 00:50:48 +0000 Subject: r13401: remove the rename of the snprintf functions that simo accidentially included in his last commit (This used to be commit 487b374b4359b2cb5f4e249e595c43bfa568a853) --- source4/lib/replace/snprintf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 379e15cf6d..f3eac1b9b5 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -1187,11 +1187,10 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, return max; } - int smb_vsnprintf (char *str, size_t count, const char *fmt, va_list args) + int vsnprintf (char *str, size_t count, const char *fmt, va_list args) { return dopr(str, count, fmt, args); } -#define vsnprintf smb_vsnprintf #endif /* yes this really must be a ||. Don't muck with this (tridge) @@ -1201,7 +1200,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, * that doesn't work properly according to the autoconf test. */ #if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF) -int smb_snprintf(char *str,size_t count,const char *fmt,...) + int snprintf(char *str,size_t count,const char *fmt,...) { size_t ret; va_list ap; @@ -1211,7 +1210,6 @@ int smb_snprintf(char *str,size_t count,const char *fmt,...) va_end(ap); return ret; } -#define snprintf smb_snprintf #endif #endif -- cgit From 595702c9faff4baf148901847a45b5a197ce92d5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 20 Feb 2006 20:40:51 +0000 Subject: r13577: Move some (possibly system-defined) defines to replace.h (This used to be commit 2b3d56e153b229119fddfa7b378f4d671ee0092c) --- source4/lib/replace/replace.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 0f1eb42ac0..24876ffd4e 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -162,6 +162,14 @@ int rep_mkstemp(char *temp); #include #endif +/* The extra casts work around common compiler bugs. */ +#define _TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +/* The outer cast is needed to work around a bug in Cray C 5.0.3.0. + It is necessary at least when t == time_t. */ +#define _TYPE_MINIMUM(t) ((t) (_TYPE_SIGNED (t) \ + ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) +#define _TYPE_MAXIMUM(t) ((t) (~ (t) 0 - _TYPE_MINIMUM (t))) + #ifndef HOST_NAME_MAX #define HOST_NAME_MAX 64 #endif @@ -178,4 +186,12 @@ int rep_mkstemp(char *temp); #define UINT64_MAX ((uint64_t)-1) #endif +#ifndef CHAR_BIT +#define CHAR_BIT 8 +#endif + +#ifndef INT32_MAX +#define INT32_MAX _TYPE_MAXIMUM(int32_t) +#endif + #endif -- cgit From 4b476ff4fbbba72d9497f6544c1f1fca9ff3a0ae Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 21 Feb 2006 16:03:58 +0000 Subject: r13592: Incredible how bugs like this can sweep in even after peer review and testing ... (This used to be commit 8483f61a1df0c80f3385b1ab5a2628c2a97d41a2) --- source4/lib/replace/snprintf.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index f3eac1b9b5..41f1084fd6 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -1112,25 +1112,28 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) } static struct pr_chunk *new_chunk(void) { - struct pr_chunk *new = (struct pr_chunk *)malloc(sizeof(struct pr_chunk)); - - if (!new) return NULL; - - new->type = 0; - new->num = 0; - new->min = 0; - new->min_star = NULL; - new->max = -1; - new->max_star = NULL; - new->flags = 0; - new->cflags = 0; - new->start = 0; - new->len = 0; - new->value = 0; - new->fvalue = 0; - new->strvalue = NULL; - new->pnum = NULL; - new->next = NULL; + struct pr_chunk *new_c = (struct pr_chunk *)malloc(sizeof(struct pr_chunk)); + + if (!new_c) + return NULL; + + new_c->type = 0; + new_c->num = 0; + new_c->min = 0; + new_c->min_star = NULL; + new_c->max = -1; + new_c->max_star = NULL; + new_c->flags = 0; + new_c->cflags = 0; + new_c->start = 0; + new_c->len = 0; + new_c->value = 0; + new_c->fvalue = 0; + new_c->strvalue = NULL; + new_c->pnum = NULL; + new_c->next = NULL; + + return new_c; } static int add_cnk_list_entry(struct pr_chunk_x **list, -- cgit From 33647bd841c1c74e7dc50e93379e372056ac2df1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 12 Mar 2006 13:36:08 +0000 Subject: r14240: fix summary output (step 2) we now need to explicit enable external libraries in *.m4 files again... metze (This used to be commit ca809a7910b16a248fffddc640298bbe4cdedc01) --- source4/lib/replace/readline.m4 | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/readline.m4 b/source4/lib/replace/readline.m4 index 0d1aa60d17..8248a1d900 100644 --- a/source4/lib/replace/readline.m4 +++ b/source4/lib/replace/readline.m4 @@ -2,6 +2,7 @@ # Readline included by default unless explicitly asked not to test "${with_readline+set}" != "set" && with_readline=yes +EXTERNAL_READLINE=no # test for where we get readline() from AC_MSG_CHECKING(whether to use readline) AC_ARG_WITH(readline, @@ -19,7 +20,7 @@ AC_ARG_WITH(readline, done AC_CHECK_LIB(readline, rl_callback_handler_install, [TERMLIBS="-lreadline $TERMLIBS" - AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline]) + EXTERNAL_READLINE=yes break], [TERMLIBS=], $TERMLIBS)]) ;; no) @@ -50,7 +51,7 @@ AC_ARG_WITH(readline, LDFLAGS="-L$with_readline/lib $LDFLAGS" CPPFLAGS="-I$with_readline/include $CPPFLAGS" TERMLIBS="-lreadline $TERMLIBS" - AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline]) + EXTERNAL_READLINE=yes break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)]) ;; @@ -67,6 +68,18 @@ AC_CHECK_LIB(readline, rl_completion_matches, [], [$TERMLIBS]) -SMB_EXT_LIB(READLINE, [${TERMLIBS}]) - -SMB_SUBSYSTEM(LIBREADLINE, [lib/replace/readline.o], [EXT_LIB_READLINE]) +AC_MSG_CHECKING(whether to use extern readline) +if test x"$EXTERNAL_READLINE" = x"yes"; then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline]) + SMB_SUBSYSTEM(LIBREADLINE, + [lib/replace/readline.o], + [EXT_LIB_READLINE]) + SMB_EXT_LIB(READLINE, [${TERMLIBS}]) + SMB_EXT_LIB_ENABLE(READLINE,YES) +else + SMB_SUBSYSTEM(LIBREADLINE, + [lib/replace/readline.o], + []) + AC_MSG_RESULT(no) +fi -- cgit From 7a121583b496a8fc0c1fcf44504d814700273e40 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 13 Mar 2006 22:36:07 +0000 Subject: r14349: Kill proto.h! Prototypes are now spread over multiple headers, usually one per subsystem. This change is required to allow proper header dependencies later on, without recompiling Samba each time the mtime of any source file changes. (This used to be commit 3da79bf909f801386a52e6013db399c384d0401c) --- source4/lib/replace/config.mk | 4 ++++ source4/lib/replace/readline.m4 | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 459465c64f..386029a7eb 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -18,3 +18,7 @@ NOPROTO = YES REQUIRED_SUBSYSTEMS = REPLACE_READDIR # End SUBSYSTEM LIBREPLACE ############################## + +[SUBSYSTEM::SMBREADLINE] +OBJ_FILES = readline.o +PRIVATE_PROTO_HEADER = readline.h diff --git a/source4/lib/replace/readline.m4 b/source4/lib/replace/readline.m4 index 8248a1d900..2e42befd6f 100644 --- a/source4/lib/replace/readline.m4 +++ b/source4/lib/replace/readline.m4 @@ -72,14 +72,10 @@ AC_MSG_CHECKING(whether to use extern readline) if test x"$EXTERNAL_READLINE" = x"yes"; then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline]) - SMB_SUBSYSTEM(LIBREADLINE, - [lib/replace/readline.o], - [EXT_LIB_READLINE]) + SMB_SUBSYSTEM(LIBREADLINE, [], [SMBREADLINE EXT_LIB_READLINE]) SMB_EXT_LIB(READLINE, [${TERMLIBS}]) SMB_EXT_LIB_ENABLE(READLINE,YES) else - SMB_SUBSYSTEM(LIBREADLINE, - [lib/replace/readline.o], - []) + SMB_SUBSYSTEM(LIBREADLINE, [], [SMBREADLINE]) AC_MSG_RESULT(no) fi -- cgit From 9eb691c4c5aa4435fe5ecb0a68fac07a567afa18 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 15 Mar 2006 14:05:09 +0000 Subject: r14445: add FILE_NOTIFY_CHANGE_STREAM_* flags from: http://ubiqx.org/cifs/rfc-draft/draft-leach-cifs-v1-spec-02.html#s4.3.7 tridge: there's also the buffering documented... metze (This used to be commit f1bdca23838d23fbad7f1576c182688b7cd9b73d) --- source4/lib/replace/win32/replace.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/win32/replace.h b/source4/lib/replace/win32/replace.h index 185d448d95..9901e72f6e 100644 --- a/source4/lib/replace/win32/replace.h +++ b/source4/lib/replace/win32/replace.h @@ -67,6 +67,7 @@ #undef FILE_FILE_COMPRESSION #undef FILE_VOLUME_QUOTAS #undef FILE_VOLUME_IS_COMPRESSED +#undef FILE_NOTIFY_CHANGE_FILE_NAME #undef FILE_NOTIFY_CHANGE_DIR_NAME #undef FILE_NOTIFY_CHANGE_ATTRIBUTES #undef FILE_NOTIFY_CHANGE_SIZE @@ -75,7 +76,10 @@ #undef FILE_NOTIFY_CHANGE_CREATION #undef FILE_NOTIFY_CHANGE_EA #undef FILE_NOTIFY_CHANGE_SECURITY -#undef FILE_NOTIFY_CHANGE_FILE_NAME +#undef FILE_NOTIFY_CHANGE_STREAM_NAME +#undef FILE_NOTIFY_CHANGE_STREAM_SIZE +#undef FILE_NOTIFY_CHANGE_STREAM_WRITE +#undef FILE_NOTIFY_CHANGE_NAME #undef PRINTER_ATTRIBUTE_QUEUED #undef PRINTER_ATTRIBUTE_DIRECT -- cgit From 71b4fd97922933b24424924acee606389bfecb2d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 13:56:14 +0000 Subject: r14477: Remove the NOPROTO property - it's no longer used as proto.h is gone. (This used to be commit 9c37f847d32d2f327a88c53a90af0c73126b76be) --- source4/lib/replace/config.mk | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 386029a7eb..002fd3b1c4 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -3,7 +3,6 @@ [SUBSYSTEM::REPLACE_READDIR] OBJ_FILES = \ repdir/repdir.o -NOPROTO = YES # End SUBSYSTEM REPLACE_READDIR ############################## @@ -14,7 +13,6 @@ OBJ_FILES = replace.o \ snprintf.o \ dlfcn.o \ getpass.o -NOPROTO = YES REQUIRED_SUBSYSTEMS = REPLACE_READDIR # End SUBSYSTEM LIBREPLACE ############################## -- cgit From 45e4982ccaecf2fc3ca6716767a8e343625a280d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 30 Mar 2006 11:20:47 +0000 Subject: r14816: Simplify test for comparison_fn_t (This used to be commit 594215d1176b23596549fd4e4098d42ef41f7d0d) --- source4/lib/replace/config.m4 | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 379c14e776..873e7b2bca 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -11,6 +11,8 @@ AC_CHECK_TYPE(u_int32_t, unsigned long) AC_CHECK_TYPE(u_int16_t, unsigned short) AC_CHECK_TYPE(u_int8_t, unsigned char) AC_CHECK_TYPE(ssize_t, int) +AC_CHECK_TYPE(comparison_fn_t, +[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ -- cgit From c50125f6ef127db020bc0fcfdca8ed0b24e4f018 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 31 Mar 2006 23:28:18 +0000 Subject: r14844: Support a stdbool.h replacement in lib/replace/ (This used to be commit bccfddcafa1fdb56392e2301bbd404964ad9f7c3) --- source4/lib/replace/README | 1 + source4/lib/replace/config.m4 | 3 +++ source4/lib/replace/replace.h | 17 +++++++++++++++++ 3 files changed, 21 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 19364e2faa..a789f66b81 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -52,6 +52,7 @@ getpass readline (the library) Types: +bool socklen_t u_int{8,16,32}_t uint_t diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 873e7b2bca..3c11ac1476 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -1,3 +1,4 @@ +AC_CHECK_HEADERS([stdint.h inttypes.h]) AC_CHECK_TYPE(uint_t, unsigned int) AC_CHECK_TYPE(int8_t, signed char) AC_CHECK_TYPE(uint8_t, unsigned char) @@ -127,5 +128,7 @@ LIBS="$SAVE_LIBS" AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) +AC_CHECK_HEADERS(stdbool.h) + sinclude(lib/replace/readline.m4) sinclude(lib/replace/getpass.m4) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 24876ffd4e..20b73e5b84 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -35,6 +35,14 @@ #define QSORT_CAST (int (*)(const void *, const void *)) #endif +#ifdef HAVE_STDINT_H +#include +#endif + +#ifdef HAVE_INTTYPES_H +#include +#endif + #ifndef HAVE_STRERROR extern char *sys_errlist[]; #define strerror(i) sys_errlist[i] @@ -194,4 +202,13 @@ int rep_mkstemp(char *temp); #define INT32_MAX _TYPE_MAXIMUM(int32_t) #endif +#ifdef HAVE_STDBOOL_H +#include +#else +#define __bool_true_false_are_defined +typedef bool int; +#define false (0) +#define true (1) +#endif + #endif -- cgit From 69979ddc6e6a5b36f710ec6155b50c00568f68cf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Apr 2006 15:26:59 +0000 Subject: r14998: Remove unused autoconf test, move others to proper places (This used to be commit bfa396a16056f54163c514da8b34aaf229653765) --- source4/lib/replace/config.m4 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 3c11ac1476..99cecc630e 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -132,3 +132,24 @@ AC_CHECK_HEADERS(stdbool.h) sinclude(lib/replace/readline.m4) sinclude(lib/replace/getpass.m4) + +dnl VA_COPY +AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[ +AC_TRY_LINK([#include +va_list ap1,ap2;], [va_copy(ap1,ap2);], +samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)]) +if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then + AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) +fi + +if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then +AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[ +AC_TRY_LINK([#include +va_list ap1,ap2;], [__va_copy(ap1,ap2);], +samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)]) +if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then + AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available]) +fi +fi + + -- cgit From 4a61e4901ebc751fea57880424f9045e3bdf238e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Apr 2006 16:05:21 +0000 Subject: r14999: Remove more unused autoconf code Simplify va_copy() replacement code a bit (This used to be commit a5c87360a7f14a90b831ea372277f4f89ee4c5f1) --- source4/lib/replace/replace.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 20b73e5b84..f68c5b23a9 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -134,18 +134,16 @@ int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); #define slprintf snprintf -#ifdef HAVE_VA_COPY -#define VA_COPY(dest, src) va_copy(dest, src) -#elif defined(HAVE___VA_COPY) -#define VA_COPY(dest, src) __va_copy(dest, src) +#ifndef HAVE_VA_COPY +#ifdef HAVE___VA_COPY +#define va_copy(dest, src) __va_copy(dest, src) #else -#define VA_COPY(dest, src) (dest) = (src) +#define va_copy(dest, src) (dest) = (src) +#endif #endif -#if defined(HAVE_VOLATILE) -#define VOLATILE volatile -#else -#define VOLATILE +#ifndef HAVE_VOLATILE +#define volatile #endif #ifndef HAVE_COMPARISON_FN_T -- cgit From 4ab73d6045aacd354894fe5edf0c5cfc75784064 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Apr 2006 16:25:53 +0000 Subject: r15000: Move some more autoconf tests out of build/m4/rewrite.m4 Guarantee availability of __FUNCTION__ in libreplace (This used to be commit 76b1576541210f2bb306ae17e0876b254e8dcead) --- source4/lib/replace/README | 4 ++++ source4/lib/replace/config.m4 | 8 +++++++- source4/lib/replace/replace.h | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index a789f66b81..841bcf4b8d 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -65,6 +65,10 @@ UINT16_MAX UINT32_MAX UINT64_MAX +Macros: +va_copy +__FUNCTION__ + Prerequisites: memset (for bzero) syslog (for vsyslog) diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 99cecc630e..fb6e791353 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -152,4 +152,10 @@ if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then fi fi - +dnl __FUNCTION__ macro +AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[ +AC_TRY_COMPILE([#include ], [printf("%s\n", __FUNCTION__);], +samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)]) +if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then + AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro]) +fi diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index f68c5b23a9..814936c49f 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -209,4 +209,8 @@ typedef bool int; #define true (1) #endif +#ifndef HAVE_FUNCTION_MACRO +#define __FUNCTION__ ("") +#endif + #endif -- cgit From e2e3a8e007ac2a9533f4205622a6e17d57845fcc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Apr 2006 14:09:07 +0000 Subject: r15200: Move MIN/MAX macros to libreplace as some systems have them in sys/param.h (This used to be commit 3f0396aade82a92a375275059baf8500de1b23f0) --- source4/lib/replace/README | 2 ++ source4/lib/replace/config.m4 | 2 ++ source4/lib/replace/replace.h | 14 ++++++++++++++ 3 files changed, 18 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 841bcf4b8d..a3e9d87072 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -68,6 +68,8 @@ UINT64_MAX Macros: va_copy __FUNCTION__ +MIN +MAX Prerequisites: memset (for bzero) diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index fb6e791353..ada9566b58 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -159,3 +159,5 @@ samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)]) if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro]) fi + +AC_CHECK_HEADERS([sys/param.h]) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 814936c49f..218fd4cb2a 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -213,4 +213,18 @@ typedef bool int; #define __FUNCTION__ ("") #endif +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +#ifndef MAX +#define MAX(a,b) ((a)>(b)?(a):(b)) +#endif + + + #endif -- cgit From 94af743baab2e32912bbc6f48e9ea54bda818593 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Apr 2006 14:52:37 +0000 Subject: r15203: Allow system 'bool' type to be defined in another header then stdbool.h (This used to be commit a5a648de94014b13da3af8dfac06380c9ec26c53) --- source4/lib/replace/config.m4 | 9 +++++++++ source4/lib/replace/replace.h | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index ada9566b58..bac38f6439 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -130,6 +130,15 @@ AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, AC_CHECK_HEADERS(stdbool.h) +AC_CHECK_TYPE(bool, +[AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],, +[ +AC_INCLUDES_DEFAULT +#ifdef HAVE_STDBOOL_H +#include +#endif] +) + sinclude(lib/replace/readline.m4) sinclude(lib/replace/getpass.m4) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 218fd4cb2a..bc1be38de0 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -202,7 +202,9 @@ int rep_mkstemp(char *temp); #ifdef HAVE_STDBOOL_H #include -#else +#endif + +#ifndef HAVE_BOOL #define __bool_true_false_are_defined typedef bool int; #define false (0) -- cgit From 69b51f702af1ded825d5c17bdb97014cac12e752 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Apr 2006 15:47:59 +0000 Subject: r15207: Introduce PRIVATE_DEPENDENCIES and PUBLIC_DEPENDENCIES as replacement for REQUIRED_SUBSYSTEMS. (This used to be commit adc8a019b6da256f104abed1b82bfde6998a2ac9) --- source4/lib/replace/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 002fd3b1c4..bc1301984a 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -13,7 +13,7 @@ OBJ_FILES = replace.o \ snprintf.o \ dlfcn.o \ getpass.o -REQUIRED_SUBSYSTEMS = REPLACE_READDIR +PUBLIC_DEPENDENCIES = REPLACE_READDIR # End SUBSYSTEM LIBREPLACE ############################## -- cgit From 847e80dee9c405f021c67d5ffb09804751ea2be7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Apr 2006 22:50:19 +0000 Subject: r15224: Check whether -MT is actually supported by the compiler before using automatic dependencies (This used to be commit 6598efc6b302984d0b26b0c76a4b7107f5feba21) --- source4/lib/replace/replace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index bc1be38de0..9be365d4da 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -109,7 +109,7 @@ int vasprintf(char **ptr, const char *format, va_list ap); #endif #ifndef PRINTF_ATTRIBUTE -#if !defined(NO_PRINTF_ATTRIBUTE) && (__GNUC__ >= 3) +#if __GNUC__ >= 3 /** Use gcc attribute to check printf fns. a1 is the 1-based index of * the parameter containing the format, and a2 the index of the first * argument. Note that some gcc 2.x versions don't handle this -- cgit From 6bbd3b3360e3bc4c1d39f6d3d5d5082fd9b060eb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Apr 2006 07:56:31 +0000 Subject: r15226: Fix order of typedef specification - caught by kblin (This used to be commit d5d03cdd2398467ecee71bae37238c375baa2395) --- source4/lib/replace/replace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 9be365d4da..77f42acc97 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -206,7 +206,7 @@ int rep_mkstemp(char *temp); #ifndef HAVE_BOOL #define __bool_true_false_are_defined -typedef bool int; +typedef int bool; #define false (0) #define true (1) #endif -- cgit From 0d5587b5d128d9dd502a3b78c02fb986b33d92c4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 26 Apr 2006 12:22:54 +0000 Subject: r15274: Drop default EXT_LIB_ prefix for external libraries. Fixes issues with local (empty) libpopt.a overriding global one (This used to be commit 2f06305e53478e5030c24550954f221a9a97c83f) --- source4/lib/replace/readline.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/readline.m4 b/source4/lib/replace/readline.m4 index 2e42befd6f..b71ced7eb7 100644 --- a/source4/lib/replace/readline.m4 +++ b/source4/lib/replace/readline.m4 @@ -72,9 +72,9 @@ AC_MSG_CHECKING(whether to use extern readline) if test x"$EXTERNAL_READLINE" = x"yes"; then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline]) - SMB_SUBSYSTEM(LIBREADLINE, [], [SMBREADLINE EXT_LIB_READLINE]) - SMB_EXT_LIB(READLINE, [${TERMLIBS}]) - SMB_EXT_LIB_ENABLE(READLINE,YES) + SMB_SUBSYSTEM(LIBREADLINE, [], [SMBREADLINE EXT_READLINE]) + SMB_EXT_LIB(EXT_READLINE, [${TERMLIBS}]) + SMB_ENABLE(EXT_READLINE,YES) else SMB_SUBSYSTEM(LIBREADLINE, [], [SMBREADLINE]) AC_MSG_RESULT(no) -- cgit From 81d3f8e8a1fe075b99c51fee895da94536f4c972 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 26 Apr 2006 14:20:46 +0000 Subject: r15280: - remove the 2nd check for __FUNCTION__ - fallback to __func__ if __FUNCTION__ isn't there metze (This used to be commit 6c5a2b08ca2f0db6b39808740a06ed165e8b9ade) --- source4/lib/replace/config.m4 | 8 ++++++++ source4/lib/replace/replace.h | 4 ++++ 2 files changed, 12 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index bac38f6439..bf46bdcc58 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -167,6 +167,14 @@ AC_TRY_COMPILE([#include ], [printf("%s\n", __FUNCTION__);], samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)]) if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro]) +else + dnl __func__ macro + AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[ + AC_TRY_COMPILE([#include ], [printf("%s\n", __func__);], + samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)]) + if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then + AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro]) + fi fi AC_CHECK_HEADERS([sys/param.h]) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 77f42acc97..d0575f4b60 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -212,8 +212,12 @@ typedef int bool; #endif #ifndef HAVE_FUNCTION_MACRO +#ifdef HAVE_func_MACRO +#define __FUNCTION__ __func__ +#else #define __FUNCTION__ ("") #endif +#endif #ifdef HAVE_SYS_PARAM_H #include -- cgit From 8d137d97858a618c8c5451bb7b11fb95990540c8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 27 Apr 2006 16:05:05 +0000 Subject: r15295: Fix some dependencies Move unistr-specific code to lib/charset/. Remove _m from some places where it's not needed. (This used to be commit 03224e112424968fc3f547c6159c7ccae2d1aa5b) --- source4/lib/replace/config.mk | 4 ---- source4/lib/replace/readline.m4 | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index bc1301984a..4fd5402f61 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -16,7 +16,3 @@ OBJ_FILES = replace.o \ PUBLIC_DEPENDENCIES = REPLACE_READDIR # End SUBSYSTEM LIBREPLACE ############################## - -[SUBSYSTEM::SMBREADLINE] -OBJ_FILES = readline.o -PRIVATE_PROTO_HEADER = readline.h diff --git a/source4/lib/replace/readline.m4 b/source4/lib/replace/readline.m4 index b71ced7eb7..34b538f10a 100644 --- a/source4/lib/replace/readline.m4 +++ b/source4/lib/replace/readline.m4 @@ -72,10 +72,10 @@ AC_MSG_CHECKING(whether to use extern readline) if test x"$EXTERNAL_READLINE" = x"yes"; then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline]) - SMB_SUBSYSTEM(LIBREADLINE, [], [SMBREADLINE EXT_READLINE]) - SMB_EXT_LIB(EXT_READLINE, [${TERMLIBS}]) - SMB_ENABLE(EXT_READLINE,YES) + SMB_SUBSYSTEM(SMBREADLINE, [lib/replace/readline.o], [READLINE]) + SMB_EXT_LIB(READLINE, [${TERMLIBS}]) + SMB_ENABLE(READLINE,YES) else - SMB_SUBSYSTEM(LIBREADLINE, [], [SMBREADLINE]) + SMB_SUBSYSTEM(SMBREADLINE, [lib/replace/readline.o], []) AC_MSG_RESULT(no) fi -- cgit From 4818967242c7f502661193428f6217e8caa43e20 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Apr 2006 00:03:52 +0000 Subject: r15303: Re-add SMB readline replacement header (This used to be commit 40fb796ad25dc8b53d9f7c66324712b7ff4fc071) --- source4/lib/replace/readline.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 source4/lib/replace/readline.h (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/readline.h b/source4/lib/replace/readline.h new file mode 100644 index 0000000000..cde2b47a24 --- /dev/null +++ b/source4/lib/replace/readline.h @@ -0,0 +1,9 @@ +#ifndef __SMBREADLINE_H__ +#define __SMBREADLINE_H__ + +char *smb_readline(const char *prompt, void (*callback)(void), + char **(completion_fn)(const char *text, int start, int end)); +const char *smb_readline_get_line_buffer(void); +void smb_readline_ca_char(char c); + +#endif /* __SMBREADLINE_H__ */ -- cgit From e572bbb94cb8a23d366647bcf584cc75029e8def Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 29 Apr 2006 12:39:19 +0000 Subject: r15321: Reduce the size of rewrite.m4 a bit more (This used to be commit c83e4b166534278c335254aa8890a50635bbf1b7) --- source4/lib/replace/config.m4 | 3 ++- source4/lib/replace/replace.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index bf46bdcc58..12e3607bb4 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -81,6 +81,7 @@ AC_HAVE_DECL(vasprintf, [#include ]) AC_HAVE_DECL(vsnprintf, [#include ]) AC_HAVE_DECL(snprintf, [#include ]) AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf) +AC_CHECK_HEADERS(strings.h) AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[ AC_TRY_RUN([ @@ -177,4 +178,4 @@ else fi fi -AC_CHECK_HEADERS([sys/param.h]) +AC_CHECK_HEADERS([sys/param.h limits.h]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 5d3ef52987..90f05d6c90 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -22,6 +22,7 @@ #include "system/wait.h" #include "system/time.h" #include "system/network.h" +#include "system/filesys.h" #include "system/iconv.h" void replace_dummy(void); -- cgit From e595ede02fe9c80a88b5a7da4721c3c01808c276 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 May 2006 13:20:05 +0000 Subject: r15375: Rename readline.h to smbreadline.h avoid clashes with system header. (This used to be commit ccc3d8a95441e7a7015f0cf0e622ec9e38347d33) --- source4/lib/replace/readline.h | 9 --------- source4/lib/replace/smbreadline.h | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 source4/lib/replace/readline.h create mode 100644 source4/lib/replace/smbreadline.h (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/readline.h b/source4/lib/replace/readline.h deleted file mode 100644 index cde2b47a24..0000000000 --- a/source4/lib/replace/readline.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __SMBREADLINE_H__ -#define __SMBREADLINE_H__ - -char *smb_readline(const char *prompt, void (*callback)(void), - char **(completion_fn)(const char *text, int start, int end)); -const char *smb_readline_get_line_buffer(void); -void smb_readline_ca_char(char c); - -#endif /* __SMBREADLINE_H__ */ diff --git a/source4/lib/replace/smbreadline.h b/source4/lib/replace/smbreadline.h new file mode 100644 index 0000000000..cde2b47a24 --- /dev/null +++ b/source4/lib/replace/smbreadline.h @@ -0,0 +1,9 @@ +#ifndef __SMBREADLINE_H__ +#define __SMBREADLINE_H__ + +char *smb_readline(const char *prompt, void (*callback)(void), + char **(completion_fn)(const char *text, int start, int end)); +const char *smb_readline_get_line_buffer(void); +void smb_readline_ca_char(char c); + +#endif /* __SMBREADLINE_H__ */ -- cgit From 66a4c270d49bc3807b547ff17423b9d661eb3983 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 May 2006 14:33:48 +0000 Subject: r15377: Remove sys_select() code as it's no longer used. (This used to be commit 68004f68a364ce826ed8cbed0977e631ca60594d) --- source4/lib/replace/readline.c | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/readline.c b/source4/lib/replace/readline.c index 52f45eb759..78febf5000 100644 --- a/source4/lib/replace/readline.c +++ b/source4/lib/replace/readline.c @@ -25,6 +25,51 @@ #include #include "system/readline.h" +/******************************************************************* + Similar to sys_select() but catch EINTR and continue. + This is what sys_select() used to do in Samba. +********************************************************************/ + +int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval) +{ + int ret; + fd_set *readfds2, readfds_buf, *writefds2, writefds_buf, *errorfds2, errorfds_buf; + struct timeval tval2, *ptval; + + readfds2 = (readfds ? &readfds_buf : NULL); + writefds2 = (writefds ? &writefds_buf : NULL); + errorfds2 = (errorfds ? &errorfds_buf : NULL); + ptval = (tval ? &tval2 : NULL); + + do { + if (readfds) + readfds_buf = *readfds; + if (writefds) + writefds_buf = *writefds; + if (errorfds) + errorfds_buf = *errorfds; + if (tval) + tval2 = *tval; + + /* We must use select and not sys_select here. If we use + sys_select we'd lose the fact a signal occurred when sys_select + read a byte from the pipe. Fix from Mark Weaver + + */ + + ret = select(maxfd, readfds2, writefds2, errorfds2, ptval); + } while (ret == -1 && errno == EINTR); + + if (readfds) + *readfds = readfds_buf; + if (writefds) + *writefds = writefds_buf; + if (errorfds) + *errorfds = errorfds_buf; + + return ret; +} + /**************************************************************************** Display the prompt and wait for input. Call callback() regularly ****************************************************************************/ -- cgit From ec83aa3fda3de99e1a58292af1302c42376c8739 Mon Sep 17 00:00:00 2001 From: Paul Green Date: Mon, 1 May 2006 20:57:15 +0000 Subject: r15382: Use grp.h in this block; it has been cleaned out of the other headers that formerly included it for us. Paul (This used to be commit a4d706cf26382820b58940458f8873a4f8f79612) --- source4/lib/replace/replace.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 90f05d6c90..415ea2f129 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -200,6 +200,9 @@ Corrections by richard.kettlewell@kewill.com errno = ENOSYS; return -1; #else /* HAVE_SETGROUPS */ + +#include + gid_t *grouplst = NULL; int max_gr = groups_max(); int ret; -- cgit From 72a5cbadc1498b58bc7873a450de4b50e322a676 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 3 May 2006 09:07:38 +0000 Subject: r15406: Move 'smbreadline' out of libreplace as it doesn't replace functionality not available on some platforms but is a Samba-specific library. (This used to be commit e9d3660fa6678424e5159708a1aa572824926c8e) --- source4/lib/replace/README | 1 + source4/lib/replace/config.m4 | 1 - source4/lib/replace/readline.c | 164 -------------------------------------- source4/lib/replace/readline.m4 | 81 ------------------- source4/lib/replace/smbreadline.h | 9 --- 5 files changed, 1 insertion(+), 255 deletions(-) delete mode 100644 source4/lib/replace/readline.c delete mode 100644 source4/lib/replace/readline.m4 delete mode 100644 source4/lib/replace/smbreadline.h (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index a3e9d87072..9760c75b80 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -50,6 +50,7 @@ pread pwrite getpass readline (the library) +inet_ntoa Types: bool diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 12e3607bb4..aec9f5805c 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -140,7 +140,6 @@ AC_INCLUDES_DEFAULT #endif] ) -sinclude(lib/replace/readline.m4) sinclude(lib/replace/getpass.m4) dnl VA_COPY diff --git a/source4/lib/replace/readline.c b/source4/lib/replace/readline.c deleted file mode 100644 index 78febf5000..0000000000 --- a/source4/lib/replace/readline.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Samba readline wrapper implementation - Copyright (C) Simo Sorce 2001 - Copyright (C) Andrew Tridgell 2001 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "pstring.h" - -#include -#include "system/readline.h" - -/******************************************************************* - Similar to sys_select() but catch EINTR and continue. - This is what sys_select() used to do in Samba. -********************************************************************/ - -int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval) -{ - int ret; - fd_set *readfds2, readfds_buf, *writefds2, writefds_buf, *errorfds2, errorfds_buf; - struct timeval tval2, *ptval; - - readfds2 = (readfds ? &readfds_buf : NULL); - writefds2 = (writefds ? &writefds_buf : NULL); - errorfds2 = (errorfds ? &errorfds_buf : NULL); - ptval = (tval ? &tval2 : NULL); - - do { - if (readfds) - readfds_buf = *readfds; - if (writefds) - writefds_buf = *writefds; - if (errorfds) - errorfds_buf = *errorfds; - if (tval) - tval2 = *tval; - - /* We must use select and not sys_select here. If we use - sys_select we'd lose the fact a signal occurred when sys_select - read a byte from the pipe. Fix from Mark Weaver - - */ - - ret = select(maxfd, readfds2, writefds2, errorfds2, ptval); - } while (ret == -1 && errno == EINTR); - - if (readfds) - *readfds = readfds_buf; - if (writefds) - *writefds = writefds_buf; - if (errorfds) - *errorfds = errorfds_buf; - - return ret; -} - -/**************************************************************************** - Display the prompt and wait for input. Call callback() regularly -****************************************************************************/ - -static char *smb_readline_replacement(const char *prompt, void (*callback)(void), - char **(completion_fn)(const char *text, int start, int end)) -{ - fd_set fds; - static pstring line; - struct timeval timeout; - int fd = STDIN_FILENO; - char *ret; - - do_debug("%s", prompt); - - while (1) { - timeout.tv_sec = 5; - timeout.tv_usec = 0; - - FD_ZERO(&fds); - FD_SET(fd,&fds); - - if (sys_select_intr(fd+1,&fds,NULL,NULL,&timeout) == 1) { - ret = x_fgets(line, sizeof(line), x_stdin); - return ret; - } - if (callback) - callback(); - } -} - -/**************************************************************************** - Display the prompt and wait for input. Call callback() regularly. -****************************************************************************/ - -char *smb_readline(const char *prompt, void (*callback)(void), - char **(completion_fn)(const char *text, int start, int end)) -{ -#if HAVE_LIBREADLINE - if (isatty(STDIN_FILENO)) { - char *ret; - - /* Aargh! Readline does bizzare things with the terminal width - that mucks up expect(1). Set CLI_NO_READLINE in the environment - to force readline not to be used. */ - - if (getenv("CLI_NO_READLINE")) - return smb_readline_replacement(prompt, callback, completion_fn); - - if (completion_fn) { - /* The callback prototype has changed slightly between - different versions of Readline, so the same function - works in all of them to date, but we get compiler - warnings in some. */ - rl_attempted_completion_function = RL_COMPLETION_CAST completion_fn; - } - - if (callback) - rl_event_hook = (Function *)callback; - ret = readline(prompt); - if (ret && *ret) - add_history(ret); - return ret; - } else -#endif - return smb_readline_replacement(prompt, callback, completion_fn); -} - -/**************************************************************************** - * return line buffer text - ****************************************************************************/ -const char *smb_readline_get_line_buffer(void) -{ -#if defined(HAVE_LIBREADLINE) - return rl_line_buffer; -#else - return NULL; -#endif -} - -/**************************************************************************** - * set completion append character - ***************************************************************************/ -void smb_readline_ca_char(char c) -{ -#if defined(HAVE_LIBREADLINE) - rl_completion_append_character = c; -#endif -} - - - diff --git a/source4/lib/replace/readline.m4 b/source4/lib/replace/readline.m4 deleted file mode 100644 index 34b538f10a..0000000000 --- a/source4/lib/replace/readline.m4 +++ /dev/null @@ -1,81 +0,0 @@ -############################################### -# Readline included by default unless explicitly asked not to -test "${with_readline+set}" != "set" && with_readline=yes - -EXTERNAL_READLINE=no -# test for where we get readline() from -AC_MSG_CHECKING(whether to use readline) -AC_ARG_WITH(readline, -[ --with-readline[=DIR] Look for readline include/libs in DIR (default=auto) ], -[ case "$with_readline" in - yes) - AC_MSG_RESULT(yes) - - AC_CHECK_HEADERS(readline.h history.h readline/readline.h) - AC_CHECK_HEADERS(readline/history.h) - - AC_CHECK_HEADERS(readline.h readline/readline.h,[ - for termlib in ncurses curses termcap terminfo termlib tinfo; do - AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break]) - done - AC_CHECK_LIB(readline, rl_callback_handler_install, - [TERMLIBS="-lreadline $TERMLIBS" - EXTERNAL_READLINE=yes - break], [TERMLIBS=], $TERMLIBS)]) - ;; - no) - AC_MSG_RESULT(no) - ;; - *) - AC_MSG_RESULT(yes) - - # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at - # alternate readline path - _ldflags=${LDFLAGS} - _cppflags=${CPPFLAGS} - - # Add additional search path - LDFLAGS="-L$with_readline/lib $LDFLAGS" - CPPFLAGS="-I$with_readline/include $CPPFLAGS" - - AC_CHECK_HEADERS(readline.h history.h readline/readline.h) - AC_CHECK_HEADERS(readline/history.h) - - AC_CHECK_HEADERS(readline.h readline/readline.h,[ - for termlib in ncurses curses termcap terminfo termlib; do - AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break]) - done - AC_CHECK_LIB(readline, rl_callback_handler_install, - [TERMLDFLAGS="-L$with_readline/lib" - TERMCPPFLAGS="-I$with_readline/include" - LDFLAGS="-L$with_readline/lib $LDFLAGS" - CPPFLAGS="-I$with_readline/include $CPPFLAGS" - TERMLIBS="-lreadline $TERMLIBS" - EXTERNAL_READLINE=yes - break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)]) - - ;; - esac], - AC_MSG_RESULT(no) -) - -# The readline API changed slightly from readline3 to readline4, so -# code will generate warnings on one of them unless we have a few -# special cases. -AC_CHECK_LIB(readline, rl_completion_matches, - [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, - [Do we have rl_completion_matches?])], - [], - [$TERMLIBS]) - -AC_MSG_CHECKING(whether to use extern readline) -if test x"$EXTERNAL_READLINE" = x"yes"; then - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline]) - SMB_SUBSYSTEM(SMBREADLINE, [lib/replace/readline.o], [READLINE]) - SMB_EXT_LIB(READLINE, [${TERMLIBS}]) - SMB_ENABLE(READLINE,YES) -else - SMB_SUBSYSTEM(SMBREADLINE, [lib/replace/readline.o], []) - AC_MSG_RESULT(no) -fi diff --git a/source4/lib/replace/smbreadline.h b/source4/lib/replace/smbreadline.h deleted file mode 100644 index cde2b47a24..0000000000 --- a/source4/lib/replace/smbreadline.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __SMBREADLINE_H__ -#define __SMBREADLINE_H__ - -char *smb_readline(const char *prompt, void (*callback)(void), - char **(completion_fn)(const char *text, int start, int end)); -const char *smb_readline_get_line_buffer(void); -void smb_readline_ca_char(char c); - -#endif /* __SMBREADLINE_H__ */ -- cgit From 172a83d72491f90f6191be1040ef8b2e1789bd2e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 13 May 2006 19:14:12 +0000 Subject: r15573: Fix build of systems that have iconv headers in non-standard locations Split of system/locale.h header from system/iconv.h Previously, iconv wasn't being used on these systems (This used to be commit aa6d66fda69779d1c2948a1aca85dbd5208f1cba) --- source4/lib/replace/replace.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 415ea2f129..337a54f24f 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -23,7 +23,6 @@ #include "system/time.h" #include "system/network.h" #include "system/filesys.h" -#include "system/iconv.h" void replace_dummy(void); void replace_dummy(void) {} -- cgit From 7403d50358b0f4ba77831bcf15b557162ea1082a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 13 May 2006 19:25:04 +0000 Subject: r15575: Fix getpass test (This used to be commit 5205faf898ad70790e1b09bb394622d81a56a9b4) --- source4/lib/replace/getpass.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.m4 b/source4/lib/replace/getpass.m4 index 2bd9d7bc1a..d66be30564 100644 --- a/source4/lib/replace/getpass.m4 +++ b/source4/lib/replace/getpass.m4 @@ -5,7 +5,7 @@ AC_TRY_COMPILE([ #define REPLACE_GETPASS 1 #define NO_CONFIG_H 1 #define main dont_declare_main -#include "${srcdir-.}/lib/cmdline/getsmbpass.c" +#include "${srcdir-.}/lib/replace/getpass.c" #undef main ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no) CPPFLAGS="$SAVE_CPPFLAGS" -- cgit From 96a858b5cd6243c15fb9649956d2f7718521661b Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 19 May 2006 18:37:35 +0000 Subject: r15719: Fix build on systems (AIX) that don't have vsyslog or strcasestr, with --enable-developer on. syslog() and toupper() required more includes. Someone more familiar with samba4 builds should verify this, please. (This used to be commit d28f49fc6d3b7ee1b7077e2d35b2aee54d2d1469) --- source4/lib/replace/replace.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 337a54f24f..f72394cb0f 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -19,10 +19,12 @@ */ #include "includes.h" +#include "system/locale.h" #include "system/wait.h" #include "system/time.h" #include "system/network.h" #include "system/filesys.h" +#include "system/syslog.h" void replace_dummy(void); void replace_dummy(void) {} -- cgit From 548927d79b48906b2caf3fc7b5c83ed075973170 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 24 May 2006 17:21:37 +0000 Subject: r15868: Add replacement macro for __STRING() (This used to be commit 3780e0580b7173f20fed550db3412ab3b3b12fbf) --- source4/lib/replace/README | 1 + source4/lib/replace/replace.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 9760c75b80..c0c2cdd91d 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -69,6 +69,7 @@ UINT64_MAX Macros: va_copy __FUNCTION__ +__STRING MIN MAX diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index d0575f4b60..62adc1e5d8 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -231,6 +231,8 @@ typedef int bool; #define MAX(a,b) ((a)>(b)?(a):(b)) #endif - +#ifndef __STRING +#define __STRING(x) #x +#endif #endif -- cgit From 01b8c1913d75a9b74a1a4bf3e7d8a80f18db0b2d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 25 May 2006 02:09:00 +0000 Subject: r15879: strtok_r() replacement, for solaris (This used to be commit df5bd916db3cfbd6c145177fd8992261f03a5cbc) --- source4/lib/replace/config.m4 | 2 +- source4/lib/replace/replace.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index aec9f5805c..2cee65e6a6 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -48,7 +48,7 @@ AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strcasestr) +AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index f72394cb0f..38a3d517df 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -549,3 +549,30 @@ char *strcasestr(const char *haystack, const char *needle) return NULL; } #endif + +#ifndef HAVE_STRTOK_R +/* based on GLIBC version, copyright Free Software Foundation */ +char *strtok_r(char *s, const char *delim, char **save_ptr) +{ + char *token; + + if (s == NULL) s = *save_ptr; + + s += strspn(s, delim); + if (*s == '\0') { + *save_ptr = s; + return NULL; + } + + token = s; + s = strpbrk(token, delim); + if (s == NULL) { + *save_ptr = token + strlen(token); + } else { + *s = '\0'; + *save_ptr = s + 1; + } + + return token; +} +#endif -- cgit From aa01252bb35a6e13d0050efc1b3ccb9a80a827a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 25 May 2006 13:23:24 +0000 Subject: r15882: I forgot to add in this prototype for strtok_r() (This used to be commit 971cead2ad66fca55a32639090d97b8186c1dae7) --- source4/lib/replace/replace.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 62adc1e5d8..7a1c4b5ce7 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -96,6 +96,10 @@ int rename(const char *zfrom, const char *zto); char *strcasestr(const char *haystack, const char *needle); #endif +#ifndef HAVE_STRTOK_R +char *strtok_r(char *s, const char *delim, char **save_ptr); +#endif + #ifndef HAVE_FTRUNCATE int ftruncate(int f,long l); #endif -- cgit From 33ffb31a498186131224ddab11291d81ec0da2a8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 26 May 2006 02:25:00 +0000 Subject: r15896: we're getting a lot of crashes on the build farm due to people assuming that printf("%s", NULL) is OK. The problem is that it is ok with recent versions of glibc, so the bug isn't noticed by most developers. This configure change ensures that we replace snprintf() if it doesn't handle NULL strings. Then we just need to make sure we use d_printf() instead of printf() in torture tests to display possibly NULL strings. (This used to be commit dcce824080f3437c835b32381b73380fab720554) --- source4/lib/replace/config.m4 | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 2cee65e6a6..b925dd52ea 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -107,6 +107,7 @@ void foo(const char *format, ...) { if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(1); + if (snprintf(buf, 20, "%s", 0) < 3) exit(1); exit(0); } -- cgit From 0a1a19d9d95b5adbe6c3dd3ed689ce7e3b43ab12 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 30 May 2006 05:57:43 +0000 Subject: r15953: our timegm() replacement still doesn't work, so grab the one from Heimdal which does work. This should fix most of the rest of the failures on solaris (This used to be commit acfaa98b5ea686feb81350baf09b3f4480f96edc) --- source4/lib/replace/config.mk | 1 + source4/lib/replace/replace.c | 13 -------- source4/lib/replace/replace.h | 4 +++ source4/lib/replace/timegm.c | 72 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 13 deletions(-) create mode 100644 source4/lib/replace/timegm.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 4fd5402f61..7ec1eaffa2 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -11,6 +11,7 @@ OBJ_FILES = \ [SUBSYSTEM::LIBREPLACE] OBJ_FILES = replace.o \ snprintf.o \ + timegm.o \ dlfcn.o \ getpass.o PUBLIC_DEPENDENCIES = REPLACE_READDIR diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 38a3d517df..6f51bd2e99 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -368,19 +368,6 @@ duplicate a string #endif /* HAVE_VSYSLOG */ -#ifndef HAVE_TIMEGM -/* - yes, I know this looks insane, but its really needed. The function in the - Linux timegm() manpage does not work on solaris. -*/ - time_t timegm(struct tm *tm) -{ - time_t t = mktime(tm); - t -= mktime(gmtime(&t)) - (int)mktime(localtime(&t)); - return t; -} -#endif - #ifndef HAVE_SETENV int setenv(const char *name, const char *value, int overwrite) { diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 7a1c4b5ce7..f9d67fb2ec 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -112,6 +112,10 @@ int vasprintf(char **ptr, const char *format, va_list ap); #define bzero(a,b) memset((a),'\0',(b)) #endif +#ifndef HAVE_TIMEGM +time_t timegm(struct tm *tm); +#endif + #ifndef PRINTF_ATTRIBUTE #if __GNUC__ >= 3 /** Use gcc attribute to check printf fns. a1 is the 1-based index of diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c new file mode 100644 index 0000000000..f2741e0eff --- /dev/null +++ b/source4/lib/replace/timegm.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1997 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + adapted for Samba4 by Andrew Tridgell +*/ + +#include "includes.h" +#include "system/time.h" + +#ifndef HAVE_TIMEGM + +static int is_leap(unsigned y) +{ + y += 1900; + return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0); +} + +time_t timegm(struct tm *tm) +{ + static const unsigned ndays[2][12] ={ + {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, + {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; + time_t res = 0; + unsigned i; + + for (i = 70; i < tm->tm_year; ++i) + res += is_leap(i) ? 366 : 365; + + for (i = 0; i < tm->tm_mon; ++i) + res += ndays[is_leap(tm->tm_year)][i]; + res += tm->tm_mday - 1; + res *= 24; + res += tm->tm_hour; + res *= 60; + res += tm->tm_min; + res *= 60; + res += tm->tm_sec; + return res; +} + +#endif /* HAVE_TIMEGM */ -- cgit From 49b29f67d4b7aa25b2df3c73ea58004f82f78088 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 31 May 2006 17:34:04 +0000 Subject: r15986: Declare struct tm (This used to be commit 139d9369dc1b7daaf980a0c95b0921388ec39913) --- source4/lib/replace/replace.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index f9d67fb2ec..8beb43bfa4 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -113,6 +113,7 @@ int vasprintf(char **ptr, const char *format, va_list ap); #endif #ifndef HAVE_TIMEGM +struct tm; time_t timegm(struct tm *tm); #endif -- cgit From b17ee8feb75123a2334510db4015b355565013eb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 2 Jun 2006 07:52:05 +0000 Subject: r16001: we don't use u_intX_t any more metze (This used to be commit e0e4f86b30185e01975eff91c2ce7ab7ca5353c1) --- source4/lib/replace/README | 6 ++---- source4/lib/replace/config.m4 | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index c0c2cdd91d..0101b80913 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -55,16 +55,14 @@ inet_ntoa Types: bool socklen_t -u_int{8,16,32}_t uint_t uint{8,16,32,64}_t int{8,16,32,64}_t Constants: PATH_NAME_MAX -UINT16_MAX -UINT32_MAX -UINT64_MAX +UINT{16,32,64}_MAX +INT32_MAX Macros: va_copy diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index b925dd52ea..fb9814004e 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -8,9 +8,6 @@ AC_CHECK_TYPE(int32_t, long) AC_CHECK_TYPE(uint32_t, unsigned long) AC_CHECK_TYPE(int64_t, long long) AC_CHECK_TYPE(uint64_t, unsigned long long) -AC_CHECK_TYPE(u_int32_t, unsigned long) -AC_CHECK_TYPE(u_int16_t, unsigned short) -AC_CHECK_TYPE(u_int8_t, unsigned char) AC_CHECK_TYPE(ssize_t, int) AC_CHECK_TYPE(comparison_fn_t, [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) -- cgit From c62d1d21ab0f3ff34c1c695ff2132b5a9ff25eaa Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 2 Jun 2006 12:51:42 +0000 Subject: r16003: Tru64 doesn't have strtoll/strtoull but the size of 'long' is equal to the size of 'long long' so we can use strtol/strtoul Patch from Bjoern Jacke, thanks! (I only added the SIZEOF_LONG == SIZEOF_LONG_LONG) metze (This used to be commit 2bda7b63be1257210601dac3e2b1070f48d765b4) --- source4/lib/replace/replace.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 6f51bd2e99..02c3d04163 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -394,6 +394,8 @@ duplicate a string return strtouq(str, endptr, base); #elif defined(HAVE___STRTOULL) return __strtoull(str, endptr, base); +#elif SIZEOF_LONG == SIZEOF_LONG_LONG + return (unsigned long long int) strtoul(str, endptr, base); #else # error "You need a strtoull function" #endif @@ -407,6 +409,8 @@ duplicate a string return strtoq(str, endptr, base); #elif defined(HAVE___STRTOLL) return __strtoll(str, endptr, base); +#elif SIZEOF_LONG == SIZEOF_LONG_LONG + return (long long int) strtol(str, endptr, base); #else # error "You need a strtoll function" #endif -- cgit From 2176bcc3ab226c49aaa223c6cf58fb07222d8519 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 2 Jun 2006 20:55:17 +0000 Subject: r16012: do the type checks before anythingelse metze (This used to be commit 092e52c51884706317564a5a5397f137689d78cb) --- source4/lib/replace/config.m4 | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index fb9814004e..4948f91163 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -12,6 +12,18 @@ AC_CHECK_TYPE(ssize_t, int) AC_CHECK_TYPE(comparison_fn_t, [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) +AC_CHECK_HEADERS(stdbool.h) + +AC_CHECK_TYPE(bool, +[AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],, +[ +AC_INCLUDES_DEFAULT +#ifdef HAVE_STDBOOL_H +#include +#endif] +) + + AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ #include @@ -127,17 +139,6 @@ LIBS="$SAVE_LIBS" AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) -AC_CHECK_HEADERS(stdbool.h) - -AC_CHECK_TYPE(bool, -[AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],, -[ -AC_INCLUDES_DEFAULT -#ifdef HAVE_STDBOOL_H -#include -#endif] -) - sinclude(lib/replace/getpass.m4) dnl VA_COPY -- cgit From ff2041c955e9152bd286ab6ea534b8445caab574 Mon Sep 17 00:00:00 2001 From: James Peach Date: Tue, 27 Jun 2006 05:49:09 +0000 Subject: r16556: Add mkdtemp to libreplace. This is apparantly available on Linux and BSD systems, but it's not everywhere. (This used to be commit b3d2512ed4fc8c378607bcc2dc241a1f77ab7197) --- source4/lib/replace/README | 3 ++- source4/lib/replace/config.m4 | 2 +- source4/lib/replace/replace.c | 15 +++++++++++++++ source4/lib/replace/replace.h | 4 ++++ 4 files changed, 22 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 0101b80913..271713247a 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -45,6 +45,7 @@ chroot bzero strerror errno +mkdtemp mkstemp (a secure one!) pread pwrite @@ -75,4 +76,4 @@ Prerequisites: memset (for bzero) syslog (for vsyslog) setnetgrent, getnetgrent, endnetgrent (for innetgr) -mktemp (for mkstemp) +mktemp (for mkstemp and mkdtemp) diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 4948f91163..8b71372262 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -57,7 +57,7 @@ AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r) +AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 02c3d04163..989c0947c3 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -506,6 +506,21 @@ int rep_mkstemp(char *template) } #endif +#ifndef HAVE_MKDTEMP +char * mkdtemp(char *template) +{ + char *dname; + + if (dname = mktemp(template)) { + if (mkdir(dname, 0700) >= 0) { + return dname; + } + } + + return NULL; +} +#endif + #ifndef HAVE_PREAD static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) { diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 8beb43bfa4..e59ba43206 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -173,6 +173,10 @@ typedef int (*comparison_fn_t)(const void *, const void *); int rep_mkstemp(char *temp); #endif +#ifndef HAVE_MKDTEMP +char *mkdtemp(char *template); +#endif + #ifdef HAVE_LIMITS_H #include #endif -- cgit From 691e5e5fdcd273ae5d25ba0d129c6b2192249e81 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 21 Aug 2006 07:41:17 +0000 Subject: r17658: several replacement snprintf() fixes. 1) when running the testsuite, actually test against the system sprintf(), not against ourselves (doh!) 2) fix the buffer termination to terminate buf2 as well 3) fix handling of %llu, and add a simple test This fixes a bug with password expiry on solaris (This used to be commit ad539ec11401732d1da0abd8eef1fe849a216c21) --- source4/lib/replace/snprintf.c | 55 ++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 15 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 41f1084fd6..e315a9f99a 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -247,7 +247,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max); static void fmtint(char *buffer, size_t *currlen, size_t maxlen, - long value, int base, int min, int max, int flags); + LLONG value, int base, int min, int max, int flags); static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags); static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); @@ -799,10 +799,10 @@ static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, /* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ static void fmtint(char *buffer, size_t *currlen, size_t maxlen, - long value, int base, int min, int max, int flags) + LLONG value, int base, int min, int max, int flags) { int signvalue = 0; - unsigned long uvalue; + unsigned LLONG uvalue; char convert[20]; int place = 0; int spadlen = 0; /* amount to space pad */ @@ -920,7 +920,7 @@ static LLONG ROUND(LDOUBLE value) static double my_modf(double x0, double *iptr) { int i; - long l; + LLONG l; double x = x0; double f = 1.0; @@ -1299,7 +1299,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, "%d", NULL }; - long int_nums[] = { -1, 134, 91340, 341, 0203, 0, 1234567890}; + long int_nums[] = { -1, 134, 91340, 341, 0203, 1234567890, 0}; char *str_fmt[] = { "%10.5s", "%-10.5s", @@ -1316,6 +1316,13 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, NULL }; char *str_vals[] = {"hello", "a", "", "a longer string", NULL}; +#ifdef HAVE_LONG_LONG + char *ll_fmt[] = { + "%llu", + NULL + }; + LLONG ll_nums[] = { 134, 91340, 341, 0203, 1234567890, 128006186140000000LL, 0}; +#endif int x, y; int fail = 0; int num = 0; @@ -1327,9 +1334,9 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, for (y = 0; fp_nums[y] != 0 ; y++) { buf1[0] = buf2[0] = '\0'; l1 = snprintf(NULL, 0, fp_fmt[x], fp_nums[y]); - l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]); + l2 = sprintf(buf1, fp_fmt[x], fp_nums[y]); sprintf (buf2, fp_fmt[x], fp_nums[y]); - buf1[1023] = buf1[1023] = '\0'; + buf1[1023] = buf2[1023] = '\0'; if (strcmp (buf1, buf2) || (l1 != l2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", fp_fmt[x], l1, buf1, l2, buf2); @@ -1343,9 +1350,9 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, for (y = 0; int_nums[y] != 0 ; y++) { buf1[0] = buf2[0] = '\0'; l1 = snprintf(NULL, 0, int_fmt[x], int_nums[y]); - l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]); + l2 = sprintf(buf1, int_fmt[x], int_nums[y]); sprintf (buf2, int_fmt[x], int_nums[y]); - buf1[1023] = buf1[1023] = '\0'; + buf1[1023] = buf2[1023] = '\0'; if (strcmp (buf1, buf2) || (l1 != l2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", int_fmt[x], l1, buf1, l2, buf2); @@ -1359,9 +1366,9 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, for (y = 0; str_vals[y] != 0 ; y++) { buf1[0] = buf2[0] = '\0'; l1 = snprintf(NULL, 0, str_fmt[x], str_vals[y]); - l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]); + l2 = sprintf(buf1, str_fmt[x], str_vals[y]); sprintf (buf2, str_fmt[x], str_vals[y]); - buf1[1023] = buf1[1023] = '\0'; + buf1[1023] = buf2[1023] = '\0'; if (strcmp (buf1, buf2) || (l1 != l2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", str_fmt[x], l1, buf1, l2, buf2); @@ -1371,6 +1378,24 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, } } +#ifdef HAVE_LONG_LONG + for (x = 0; ll_fmt[x] ; x++) { + for (y = 0; ll_nums[y] != 0 ; y++) { + buf1[0] = buf2[0] = '\0'; + l1 = snprintf(NULL, 0, ll_fmt[x], ll_nums[y]); + l2 = sprintf(buf1, ll_fmt[x], ll_nums[y]); + sprintf (buf2, ll_fmt[x], ll_nums[y]); + buf1[1023] = buf2[1023] = '\0'; + if (strcmp (buf1, buf2) || (l1 != l2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", + ll_fmt[x], l1, buf1, l2, buf2); + fail++; + } + num++; + } + } +#endif + #define BUFSZ 2048 buf1[0] = buf2[0] = '\0'; @@ -1390,7 +1415,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, buf1[0] = buf2[0] = '\0'; l1 = snprintf(buf1, sizeof(buf1), "%4$*1$d %2$s %3$*1$.*1$f", 3, "pos test", 12.3456, 9); l2 = sprintf(buf2, "%4$*1$d %2$s %3$*1$.*1$f", 3, "pos test", 12.3456, 9); - buf1[1023] = buf1[1023] = '\0'; + buf1[1023] = buf2[1023] = '\0'; if (strcmp(buf1, buf2) || (l1 != l2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", "%4$*1$d %2$s %3$*1$.*1$f", l1, buf1, l2, buf2); @@ -1400,7 +1425,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, buf1[0] = buf2[0] = '\0'; l1 = snprintf(buf1, sizeof(buf1), "%4$*4$d %2$s %3$*4$.*4$f", 3, "pos test", 12.3456, 9); l2 = sprintf(buf2, "%4$*4$d %2$s %3$*4$.*4$f", 3, "pos test", 12.3456, 9); - buf1[1023] = buf1[1023] = '\0'; + buf1[1023] = buf2[1023] = '\0'; if (strcmp(buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", "%4$*1$d %2$s %3$*1$.*1$f", l1, buf1, l2, buf2); @@ -1410,7 +1435,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, buf1[0] = buf2[0] = '\0'; l1 = snprintf(buf1, sizeof(buf1), "%lld", (LLONG)1234567890); l2 = sprintf(buf2, "%lld", (LLONG)1234567890); - buf1[1023] = buf1[1023] = '\0'; + buf1[1023] = buf2[1023] = '\0'; if (strcmp(buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", "%lld", l1, buf1, l2, buf2); @@ -1420,7 +1445,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, buf1[0] = buf2[0] = '\0'; l1 = snprintf(buf1, sizeof(buf1), "%Lf", (LDOUBLE)890.1234567890123); l2 = sprintf(buf2, "%Lf", (LDOUBLE)890.1234567890123); - buf1[1023] = buf1[1023] = '\0'; + buf1[1023] = buf2[1023] = '\0'; if (strcmp(buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", "%Lf", l1, buf1, l2, buf2); -- cgit From 09129c73d7b7fc97478fe642dc43f7e5ce9a2ba9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 23 Aug 2006 11:32:29 +0000 Subject: r17750: these have moved to ldb/replace/ now (This used to be commit ac178b52935d7629f8583092e833b74093ca70e1) --- source4/lib/replace/config.m4 | 11 ++----- source4/lib/replace/config.mk | 1 - source4/lib/replace/replace.c | 44 -------------------------- source4/lib/replace/timegm.c | 72 ------------------------------------------- 4 files changed, 2 insertions(+), 126 deletions(-) delete mode 100644 source4/lib/replace/timegm.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 8b71372262..0fda967c54 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -1,16 +1,10 @@ AC_CHECK_HEADERS([stdint.h inttypes.h]) AC_CHECK_TYPE(uint_t, unsigned int) -AC_CHECK_TYPE(int8_t, signed char) -AC_CHECK_TYPE(uint8_t, unsigned char) AC_CHECK_TYPE(int16_t, short) AC_CHECK_TYPE(uint16_t, unsigned short) AC_CHECK_TYPE(int32_t, long) AC_CHECK_TYPE(uint32_t, unsigned long) -AC_CHECK_TYPE(int64_t, long long) -AC_CHECK_TYPE(uint64_t, unsigned long long) AC_CHECK_TYPE(ssize_t, int) -AC_CHECK_TYPE(comparison_fn_t, -[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) AC_CHECK_HEADERS(stdbool.h) @@ -53,10 +47,9 @@ AC_TRY_COMPILE([ [AC_DEFINE(socklen_t, int,[Socket length type])]) AC_CHECK_HEADERS(sys/syslog.h syslog.h) -AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) -AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename) -AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup) +AC_CHECK_FUNCS(setenv vsyslog setlinebuf mktime ftruncate chsize rename) +AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 7ec1eaffa2..4fd5402f61 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -11,7 +11,6 @@ OBJ_FILES = \ [SUBSYSTEM::LIBREPLACE] OBJ_FILES = replace.o \ snprintf.o \ - timegm.o \ dlfcn.o \ getpass.o PUBLIC_DEPENDENCIES = REPLACE_READDIR diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 989c0947c3..b74cd7f95a 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -387,37 +387,6 @@ duplicate a string #endif -#ifndef HAVE_STRTOULL - unsigned long long int strtoull(const char *str, char **endptr, int base) -{ -#ifdef HAVE_STRTOUQ - return strtouq(str, endptr, base); -#elif defined(HAVE___STRTOULL) - return __strtoull(str, endptr, base); -#elif SIZEOF_LONG == SIZEOF_LONG_LONG - return (unsigned long long int) strtoul(str, endptr, base); -#else -# error "You need a strtoull function" -#endif -} -#endif - -#ifndef HAVE_STRTOLL - long long int strtoll(const char *str, char **endptr, int base) -{ -#ifdef HAVE_STRTOQ - return strtoq(str, endptr, base); -#elif defined(HAVE___STRTOLL) - return __strtoll(str, endptr, base); -#elif SIZEOF_LONG == SIZEOF_LONG_LONG - return (long long int) strtol(str, endptr, base); -#else -# error "You need a strtoll function" -#endif -} -#endif - - #ifndef HAVE_STRNDUP /** Some platforms don't have strndup. @@ -437,19 +406,6 @@ duplicate a string } #endif -#ifndef HAVE_STRNLEN -/** - Some platforms don't have strnlen -**/ - size_t strnlen(const char *s, size_t n) -{ - int i; - for (i=0; s[i] && itm_year; ++i) - res += is_leap(i) ? 366 : 365; - - for (i = 0; i < tm->tm_mon; ++i) - res += ndays[is_leap(tm->tm_year)][i]; - res += tm->tm_mday - 1; - res *= 24; - res += tm->tm_hour; - res *= 60; - res += tm->tm_min; - res *= 60; - res += tm->tm_sec; - return res; -} - -#endif /* HAVE_TIMEGM */ -- cgit From fe791078b71cc103de10fc7c82302ea8ee19e447 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 23 Aug 2006 23:21:29 +0000 Subject: r17763: moved setenv to ldb/replace/ (This used to be commit ed2dbc4dfe4556831c809dab24e3833cd2018138) --- source4/lib/replace/config.m4 | 2 +- source4/lib/replace/replace.c | 19 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 0fda967c54..93f0bb34a7 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -48,7 +48,7 @@ AC_TRY_COMPILE([ AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) -AC_CHECK_FUNCS(setenv vsyslog setlinebuf mktime ftruncate chsize rename) +AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) AC_HAVE_DECL(setresuid, [#include ]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b74cd7f95a..b8f4bc1c3c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -368,25 +368,6 @@ duplicate a string #endif /* HAVE_VSYSLOG */ -#ifndef HAVE_SETENV - int setenv(const char *name, const char *value, int overwrite) -{ - char *p = NULL; - int ret = -1; - - asprintf(&p, "%s=%s", name, value); - - if (overwrite || getenv(name)) { - if (p) ret = putenv(p); - } else { - ret = 0; - } - - return ret; -} -#endif - - #ifndef HAVE_STRNDUP /** Some platforms don't have strndup. -- cgit From 168e9ec2315bf22a56b5b139e36f8b1f3a23a9a1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 24 Aug 2006 10:51:34 +0000 Subject: r17789: remove compiler warnings metze (This used to be commit dec228be4d4a68e2a6794ad4e7a9224e040fa7f2) --- source4/lib/replace/snprintf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index e315a9f99a..4b64e53148 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -145,6 +145,9 @@ void dummy_snprintf(void) {} #endif /* HAVE_SNPRINTF, etc */ +/* yes this really must be a ||. Don't muck with this (tridge) */ +#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) + #ifdef HAVE_LONG_DOUBLE #define LDOUBLE long double #else @@ -216,9 +219,6 @@ #define MAX(p,q) (((p) >= (q)) ? (p) : (q)) #endif -/* yes this really must be a ||. Don't muck with this (tridge) */ -#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) - struct pr_chunk { int type; /* chunk type */ int num; /* parameter number */ -- cgit From 1d8fa3ccac93d5307cbf63f7f02c46ae6ec268d8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 24 Aug 2006 10:55:17 +0000 Subject: r17790: replace uses -ldl and should directly depend on it metze (This used to be commit 560a3058e53479133015d1b0a7cd149393c45438) --- source4/lib/replace/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 4fd5402f61..9f6bc0ce53 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -13,6 +13,6 @@ OBJ_FILES = replace.o \ snprintf.o \ dlfcn.o \ getpass.o -PUBLIC_DEPENDENCIES = REPLACE_READDIR +PUBLIC_DEPENDENCIES = REPLACE_READDIR DL # End SUBSYSTEM LIBREPLACE ############################## -- cgit From d3c55f028e4160506538c9e1c57d3a6e22701a3c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 26 Aug 2006 16:19:22 +0000 Subject: r17840: A step towards building on Solaris which appears not to have strnlen. Volker (This used to be commit ebf75c6196afdd4bfa4f11bb1d45d385ab0babed) --- source4/lib/replace/config.m4 | 2 +- source4/lib/replace/replace.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 93f0bb34a7..adaba74568 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -50,7 +50,7 @@ AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) +AC_CHECK_FUNCS(pread pwrite strndup strnlen strcasestr strtok_r mkdtemp) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b8f4bc1c3c..1cf91751b3 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -387,6 +387,20 @@ duplicate a string } #endif +#ifndef HAVE_STRNLEN +/** + Some platforms don't have strnlen +**/ + + size_t strnlen(const char *s, size_t n) +{ + size_t i; + for (i=0; i Date: Sat, 26 Aug 2006 16:44:10 +0000 Subject: r17841: Revert 17840, libldb.a defines strnlen. Sorry for the noise (This used to be commit 1de34590821b0c076bf8d48cbdae97f33275647e) --- source4/lib/replace/config.m4 | 2 +- source4/lib/replace/replace.c | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index adaba74568..93f0bb34a7 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -50,7 +50,7 @@ AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strnlen strcasestr strtok_r mkdtemp) +AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 1cf91751b3..b8f4bc1c3c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -387,20 +387,6 @@ duplicate a string } #endif -#ifndef HAVE_STRNLEN -/** - Some platforms don't have strnlen -**/ - - size_t strnlen(const char *s, size_t n) -{ - size_t i; - for (i=0; i Date: Sat, 26 Aug 2006 17:19:58 +0000 Subject: r17842: After talking to Simo, apply the next attempt to resolve the strnlen problem. Timegm is the same. Simo says this is just a workaround, but it helps for now. Feel free to revert. Volker (This used to be commit fd166ca0c079d83081bc1d631fe40b965c7873d4) --- source4/lib/replace/config.m4 | 2 +- source4/lib/replace/replace.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 93f0bb34a7..adaba74568 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -50,7 +50,7 @@ AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) +AC_CHECK_FUNCS(pread pwrite strndup strnlen strcasestr strtok_r mkdtemp) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b8f4bc1c3c..f8bd62109d 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -387,6 +387,20 @@ duplicate a string } #endif +#ifndef HAVE_STRNLEN +/** + Some platforms don't have strnlen +**/ + + size_t strnlen(const char *s, size_t n) +{ + size_t i; + for (i=0; itm_year; ++i) + res += is_leap(i) ? 366 : 365; + + for (i = 0; i < tm->tm_mon; ++i) + res += ndays[is_leap(tm->tm_year)][i]; + res += tm->tm_mday - 1; + res *= 24; + res += tm->tm_hour; + res *= 60; + res += tm->tm_min; + res *= 60; + res += tm->tm_sec; + return res; +} +#endif -- cgit From 1bdf6692092f84aa28fc237a89c14d836b2cde87 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 27 Aug 2006 10:46:19 +0000 Subject: r17849: Next round for RPC-SAMBA3-SHARESEC (This used to be commit e17371b7f970fe4cc91f8034c18292cc3c22f161) --- source4/lib/replace/snprintf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 4b64e53148..37ca048b6c 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -589,11 +589,11 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args if (cnk->cflags == DP_C_SHORT) cnk->value = va_arg (args, unsigned int); else if (cnk->cflags == DP_C_LONG) - cnk->value = (long)va_arg (args, unsigned long int); + cnk->value = (unsigned long)va_arg (args, unsigned long int); else if (cnk->cflags == DP_C_LLONG) cnk->value = (LLONG)va_arg (args, unsigned LLONG); else - cnk->value = (long)va_arg (args, unsigned int); + cnk->value = (unsigned long)va_arg (args, unsigned int); for (i = 1; i < clist[pnum].num; i++) { clist[pnum].chunks[i]->value = cnk->value; -- cgit From 6f7dd6ca075f223abe8c7b19b5377321f38b092c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 28 Aug 2006 14:38:47 +0000 Subject: r17884: Shape up the snprintf fix after Metzes comments (This used to be commit 66b6456eee579623b64c649356ab0175c46f5789) --- source4/lib/replace/snprintf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 37ca048b6c..eaa5eec405 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -589,11 +589,11 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args if (cnk->cflags == DP_C_SHORT) cnk->value = va_arg (args, unsigned int); else if (cnk->cflags == DP_C_LONG) - cnk->value = (unsigned long)va_arg (args, unsigned long int); + cnk->value = (unsigned long int)va_arg (args, unsigned long int); else if (cnk->cflags == DP_C_LLONG) cnk->value = (LLONG)va_arg (args, unsigned LLONG); else - cnk->value = (unsigned long)va_arg (args, unsigned int); + cnk->value = (unsigned int)va_arg (args, unsigned int); for (i = 1; i < clist[pnum].num; i++) { clist[pnum].chunks[i]->value = cnk->value; -- cgit From 0bb1c2da0e4164b448c6b7cc988f59b59225802c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 1 Sep 2006 12:37:17 +0000 Subject: r17992: reverted r17842 This needs more consideration, as the patch removed the copyright notice and license from the timegm.c code. Volker, when you get a minute can you let me know what problem this patch fixed so I can find a different approach? (This used to be commit 5b9b9dd5303300778bb9e6d0479ab03fdd70c67d) --- source4/lib/replace/config.m4 | 2 +- source4/lib/replace/replace.c | 46 ------------------------------------------- 2 files changed, 1 insertion(+), 47 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index adaba74568..93f0bb34a7 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -50,7 +50,7 @@ AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strnlen strcasestr strtok_r mkdtemp) +AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index f8bd62109d..b8f4bc1c3c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -387,20 +387,6 @@ duplicate a string } #endif -#ifndef HAVE_STRNLEN -/** - Some platforms don't have strnlen -**/ - - size_t strnlen(const char *s, size_t n) -{ - size_t i; - for (i=0; itm_year; ++i) - res += is_leap(i) ? 366 : 365; - - for (i = 0; i < tm->tm_mon; ++i) - res += ndays[is_leap(tm->tm_year)][i]; - res += tm->tm_mday - 1; - res *= 24; - res += tm->tm_hour; - res *= 60; - res += tm->tm_min; - res *= 60; - res += tm->tm_sec; - return res; -} -#endif -- cgit From 515067a02eb03242411c8af4642265784af8d177 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 3 Sep 2006 16:33:12 +0000 Subject: r18018: Fix the build on OpenBSD. No license problem this time, I've written strnlen from scratch. Volker (This used to be commit 2a7cdf52e4113db30a7a8b180c68cec736f6c186) --- source4/lib/replace/replace.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b8f4bc1c3c..4048fe558e 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -367,7 +367,23 @@ duplicate a string #endif /* HAVE_SYSLOG */ #endif /* HAVE_VSYSLOG */ - +#ifndef HAVE_STRNLEN +/** + Some platforms don't have strnlen +**/ + size_t strnlen(const char *s, size_t max) +{ + size_t len; + + for (len = 0; len < max; len++) { + if (s[len] == '\0') { + break; + } + } + return len; +} +#endif + #ifndef HAVE_STRNDUP /** Some platforms don't have strndup. -- cgit From 38fdde5d9bf15b10caa60ee216d278ba8d870c2e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 4 Sep 2006 12:21:42 +0000 Subject: r18031: Merge my replace fixes: * libreplace can now build stand-alone * add stub testsuite for libreplace * make talloc/tdb/ldb use libreplace (This used to be commit fe7ca4b1454e01a33ed0d53791ebffdd349298b4) --- source4/lib/replace/Makefile.in | 37 ++++ source4/lib/replace/README | 9 +- source4/lib/replace/autogen.sh | 10 + source4/lib/replace/config.m4 | 18 ++ source4/lib/replace/config.mk | 1 + source4/lib/replace/configure.ac | 52 +++++ source4/lib/replace/dlfcn.c | 31 +-- source4/lib/replace/getpass.c | 35 +++- source4/lib/replace/repdir/repdir.c | 28 +-- source4/lib/replace/replace.c | 200 ++++++++++++++----- source4/lib/replace/replace.h | 105 ++++++---- source4/lib/replace/replace.m4 | 58 ++++++ source4/lib/replace/snprintf.c | 6 +- source4/lib/replace/test/testsuite.c | 366 +++++++++++++++++++++++++++++++++++ source4/lib/replace/timegm.c | 72 +++++++ 15 files changed, 916 insertions(+), 112 deletions(-) create mode 100644 source4/lib/replace/Makefile.in create mode 100755 source4/lib/replace/autogen.sh create mode 100644 source4/lib/replace/configure.ac create mode 100644 source4/lib/replace/replace.m4 create mode 100644 source4/lib/replace/test/testsuite.c create mode 100644 source4/lib/replace/timegm.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in new file mode 100644 index 0000000000..916b5df3d9 --- /dev/null +++ b/source4/lib/replace/Makefile.in @@ -0,0 +1,37 @@ +CC = @CC@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +includedir = @includedir@ +libdir = @libdir@ +VPATH = @srcdir@ +srcdir = @srcdir@ +builddir = @builddir@ +INSTALL = @INSTALL@ + +OBJS = dlfcn.o getpass.o replace.o snprintf.o + +all: libreplace.a + +install: all + $(INSTALL) libreplace.a $(libdir) + +libreplace.a: $(OBJS) + ar -rv $@ $(OBJS) + @-ranlib $@ + +test: testsuite + ./testsuite + +TEST_OBJS = test/testsuite.o + +testsuite: libreplace.a $(TEST_OBJS) + $(CC) -o testsuite $(TEST_OBJS) + +.c.o: + @echo Compiling $*.c + @mkdir -p `dirname $@` + $(CC) $(CFLAGS) -c $< -o $@ + +clean: + rm -f *.o diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 271713247a..fd630ddc45 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -2,10 +2,10 @@ This subsystem ensures that we can always use a certain core set of functions and types, that are either provided by the OS or by replacement functions / definitions in this subsystem. The aim is to try to stick to POSIX functions in here as much as possible. Convenience functions -that are available on no platform at all belong in different subsystems +that are available on no platform at all belong in other subsystems (such as LIBUTIL). -The following functions are guarenteed: +The following functions are guaranteed: ftruncate strlcpy @@ -21,8 +21,6 @@ setlinebuf vsyslog timegm setenv -strtoull -strtoll strndup strnlen waitpid @@ -52,6 +50,8 @@ pwrite getpass readline (the library) inet_ntoa +strtoll +strtoull Types: bool @@ -59,6 +59,7 @@ socklen_t uint_t uint{8,16,32,64}_t int{8,16,32,64}_t +intptr_t Constants: PATH_NAME_MAX diff --git a/source4/lib/replace/autogen.sh b/source4/lib/replace/autogen.sh new file mode 100755 index 0000000000..5b4c37cf96 --- /dev/null +++ b/source4/lib/replace/autogen.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +rm -rf autom4te.cache + +autoheader || exit 1 +autoconf || exit 1 + +echo "Now run ./configure and then make." +exit 0 + diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 93f0bb34a7..c2e0e5e6f4 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -1,8 +1,11 @@ AC_CHECK_HEADERS([stdint.h inttypes.h]) AC_CHECK_TYPE(uint_t, unsigned int) +AC_CHECK_TYPE(uint8_t, unsigned char) +AC_CHECK_TYPE(int8_t, char) AC_CHECK_TYPE(int16_t, short) AC_CHECK_TYPE(uint16_t, unsigned short) AC_CHECK_TYPE(int32_t, long) +AC_CHECK_TYPE(intptr_t, unsigned long long) AC_CHECK_TYPE(uint32_t, unsigned long) AC_CHECK_TYPE(ssize_t, int) @@ -170,3 +173,18 @@ else fi AC_CHECK_HEADERS([sys/param.h limits.h]) + +AC_CHECK_TYPE(comparison_fn_t, +[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) + +AC_CHECK_FUNCS(timegm strnlen setenv) +AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) + +AC_TRY_CPP([ +#define eprintf(...) fprintf(stderr, __VA_ARGS__) +eprintf("bla", "bar"); +], [], [AC_MSG_ERROR([__VA_ARGS__ is required])]) + +# Check prerequisites +AC_CHECK_FUNCS([memset printf syslog], [], + [ AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 9f6bc0ce53..49a1e7fe1b 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -9,6 +9,7 @@ OBJ_FILES = \ ############################## # Start SUBSYSTEM LIBREPLACE [SUBSYSTEM::LIBREPLACE] +CFLAGS = -Ilib/replace OBJ_FILES = replace.o \ snprintf.o \ dlfcn.o \ diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac new file mode 100644 index 0000000000..a05a9cbfe7 --- /dev/null +++ b/source4/lib/replace/configure.ac @@ -0,0 +1,52 @@ +AC_DEFUN([SMB_EXT_LIB], [echo -n ""]) +AC_DEFUN([SMB_ENABLE], [echo -n ""]) + +dnl see if a declaration exists for a function or variable +dnl defines HAVE_function_DECL if it exists +dnl AC_HAVE_DECL(var, includes) +AC_DEFUN(AC_HAVE_DECL, +[ + AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[ + AC_TRY_COMPILE([$2],[int i = (int)$1], + ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)]) + if test x"$ac_cv_have_$1_decl" = x"yes"; then + AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available]) + fi +]) + +dnl AC_SEARCH_LIBS_EXT(FUNCTION, SEARCH-LIBS, EXT_LIBS, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +dnl [OTHER-LIBRARIES]) +dnl -------------------------------------------------------- +dnl Search for a library defining FUNC, if it's not already available. +AC_DEFUN([AC_SEARCH_LIBS_EXT], +[AC_CACHE_CHECK([for library containing $1], [ac_cv_search_ext_$1], +[ +ac_func_search_ext_save_LIBS=$LIBS +ac_cv_search_ext_$1=no +AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], + [ac_cv_search_ext_$1="none required"]) +if test "$ac_cv_search_ext_$1" = no; then + for ac_lib in $2; do + LIBS="-l$ac_lib $$3 $6 $ac_func_search_save_ext_LIBS" + AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], + [ac_cv_search_ext_$1="-l$ac_lib" +break]) + done +fi +LIBS=$ac_func_search_ext_save_LIBS]) +AS_IF([test "$ac_cv_search_ext_$1" != no], + [test "$ac_cv_search_ext_$1" = "none required" || $3="$ac_cv_search_ext_$1 $$3" + $4], + [$5])dnl +]) + +AC_PREREQ(2.50) +AC_INIT(dlfcn.c) +AC_CONFIG_SRCDIR([dlfcn.c]) +AC_CONFIG_HEADER(replace_config.h) +AC_PROG_INSTALL +sinclude(config.m4) +sinclude(win32/config.m4) +sinclude(repdir/config.m4) +AC_OUTPUT(Makefile) diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c index 6df57cd60c..79005c0d2b 100644 --- a/source4/lib/replace/dlfcn.c +++ b/source4/lib/replace/dlfcn.c @@ -3,23 +3,28 @@ Samba system utilities Copyright (C) Andrew Tridgell 1992-1998 Copyright (C) Jeremy Allison 1998-2002 + + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "includes.h" +#include "replace.h" +#include #ifndef HAVE_DLOPEN void *dlopen(const char *name, int flags) diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 4ffcde8dfd..1aac7c61ab 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -18,9 +18,38 @@ Cambridge, MA 02139, USA. */ /* Modified to use with samba by Jeremy Allison, 8th July 1995. */ -#include "includes.h" -#include "system/terminal.h" -#include "system/wait.h" +#include "replace.h" +#include + +#if defined(HAVE_TERMIOS_H) +/* POSIX terminal handling. */ +#include +#elif defined(HAVE_TERMIO_H) +/* Older SYSV terminal handling - don't use if we can avoid it. */ +#include +#elif defined(HAVE_SYS_TERMIO_H) +/* Older SYSV terminal handling - don't use if we can avoid it. */ +#include +#endif + +#ifdef HAVE_SYS_WAIT_H +#include +#endif + +/* + * Define additional missing types + */ +#ifndef HAVE_SIG_ATOMIC_T_TYPE +typedef int sig_atomic_t; +#endif + +#ifndef SIGCLD +#define SIGCLD SIGCHLD +#endif + +#ifndef SIGNAL_CAST +#define SIGNAL_CAST (RETSIGTYPE (*)(int)) +#endif #ifdef REPLACE_GETPASS diff --git a/source4/lib/replace/repdir/repdir.c b/source4/lib/replace/repdir/repdir.c index b536ed6587..07b9568dc1 100644 --- a/source4/lib/replace/repdir/repdir.c +++ b/source4/lib/replace/repdir/repdir.c @@ -2,20 +2,24 @@ Unix SMB/CIFS implementation. Copyright (C) Andrew Tridgell 2005 + + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* a replacement for opendir/readdir/telldir/seekdir/closedir for BSD systems diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 4048fe558e..5333c6a9fe 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -2,38 +2,41 @@ Unix SMB/CIFS implementation. replacement routines for broken systems Copyright (C) Andrew Tridgell 1992-1998 + + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "includes.h" -#include "system/locale.h" -#include "system/wait.h" -#include "system/time.h" -#include "system/network.h" -#include "system/filesys.h" -#include "system/syslog.h" +#include "replace.h" + +#include +#include +#include +#include - void replace_dummy(void); - void replace_dummy(void) {} +void replace_dummy(void); +void replace_dummy(void) {} #ifndef HAVE_FTRUNCATE /******************************************************************* ftruncate for operating systems that don't have it ********************************************************************/ - int ftruncate(int f,off_t l) +int rep_ftruncate(int f, off_t l) { #ifdef HAVE_CHSIZE return chsize(f,l); @@ -53,7 +56,7 @@ ftruncate for operating systems that don't have it #ifndef HAVE_STRLCPY /* like strncpy but does not 0 fill the buffer and always null terminates. bufsize is the size of the destination buffer */ - size_t strlcpy(char *d, const char *s, size_t bufsize) +size_t rep_strlcpy(char *d, const char *s, size_t bufsize) { size_t len = strlen(s); size_t ret = len; @@ -69,7 +72,7 @@ ftruncate for operating systems that don't have it /* like strncat but does not 0 fill the buffer and always null terminates. bufsize is the length of the buffer, which should be one more than the maximum resulting string length */ - size_t strlcat(char *d, const char *s, size_t bufsize) +size_t rep_strlcat(char *d, const char *s, size_t bufsize) { size_t len1 = strlen(d); size_t len2 = strlen(s); @@ -97,7 +100,7 @@ Corrections by richard.kettlewell@kewill.com #define HOUR 60*MINUTE #define DAY 24*HOUR #define YEAR 365*DAY - time_t mktime(struct tm *t) +time_t rep_mktime(struct tm *t) { struct tm *u; time_t epoch = 0; @@ -149,7 +152,7 @@ Corrections by richard.kettlewell@kewill.com #ifndef HAVE_RENAME /* Rename a file. (from libiberty in GNU binutils) */ - int rename(const char *zfrom, const char *zto) +int rep_rename(const char *zfrom, const char *zto) { if (link (zfrom, zto) < 0) { @@ -169,7 +172,8 @@ Corrections by richard.kettlewell@kewill.com /* * Search for a match in a netgroup. This replaces it on broken systems. */ - int innetgr(const char *group,const char *host,const char *user,const char *dom) +int rep_innetgr(const char *group, const char *host, const char *user, + const char *dom) { char *hst, *usr, *dm; @@ -194,7 +198,7 @@ Corrections by richard.kettlewell@kewill.com /**************************************************************************** some systems don't have an initgroups call ****************************************************************************/ - int initgroups(char *name, gid_t id) +int rep_initgroups(char *name, gid_t id) { #ifndef HAVE_SETGROUPS /* yikes! no SETGROUPS or INITGROUPS? how can this work? */ @@ -246,7 +250,7 @@ Corrections by richard.kettlewell@kewill.com /* This is needed due to needing the nap() function but we don't want to include the Xenix libraries since that will break other things... BTW: system call # 0x0c28 is the same as calling nap() */ - long nap(long milliseconds) { +long nap(long milliseconds) { return syscall(0x0c28, milliseconds); } #endif @@ -259,7 +263,7 @@ this is only used if the machine does not have it's own memmove(). this is not the fastest algorithm in town, but it will do for our needs. ********************************************************************/ - void *memmove(void *dest,const void *src,int size) +void *rep_memmove(void *dest,const void *src,int size) { unsigned long d,s; int i; @@ -317,7 +321,7 @@ needs. /**************************************************************************** duplicate a string ****************************************************************************/ - char *strdup(const char *s) +char *rep_strdup(const char *s) { size_t len; char *ret; @@ -335,7 +339,7 @@ duplicate a string #ifndef WITH_PTHREADS /* REWRITE: not thread safe */ #ifdef REPLACE_INET_NTOA - char *rep_inet_ntoa(struct in_addr ip) +char *rep_inet_ntoa(struct in_addr ip) { uint8_t *p = (uint8_t *)&ip.s_addr; static char buf[18]; @@ -347,7 +351,7 @@ duplicate a string #endif #ifndef HAVE_SETLINEBUF - int setlinebuf(FILE *stream) +int rep_setlinebuf(FILE *stream) { return setvbuf(stream, (char *)NULL, _IOLBF, 0); } @@ -355,7 +359,7 @@ duplicate a string #ifndef HAVE_VSYSLOG #ifdef HAVE_SYSLOG - void vsyslog (int facility_priority, char *format, va_list arglist) +void rep_vsyslog (int facility_priority, char *format, va_list arglist) { char *msg = NULL; vasprintf(&msg, format, arglist); @@ -388,7 +392,7 @@ duplicate a string /** Some platforms don't have strndup. **/ - char *strndup(const char *s, size_t n) +char *rep_strndup(const char *s, size_t n) { char *ret; @@ -404,14 +408,14 @@ duplicate a string #endif #ifndef HAVE_WAITPID -int waitpid(pid_t pid,int *status,int options) +int rep_waitpid(pid_t pid,int *status,int options) { return wait4(pid, status, options, NULL); } #endif #ifndef HAVE_SETEUID - int seteuid(uid_t euid) +int rep_seteuid(uid_t euid) { #ifdef HAVE_SETRESUID return setresuid(-1, euid, -1); @@ -422,7 +426,7 @@ int waitpid(pid_t pid,int *status,int options) #endif #ifndef HAVE_SETEGID - int setegid(gid_t egid) +int rep_setegid(gid_t egid) { #ifdef HAVE_SETRESGID return setresgid(-1, egid, -1); @@ -436,7 +440,7 @@ int waitpid(pid_t pid,int *status,int options) os/2 also doesn't have chroot ********************************************************************/ #ifndef HAVE_CHROOT -int chroot(const char *dname) +int rep_chroot(const char *dname) { errno = ENOSYS; return -1; @@ -460,7 +464,7 @@ int rep_mkstemp(char *template) #endif #ifndef HAVE_MKDTEMP -char * mkdtemp(char *template) +char *rep_mkdtemp(char *template) { char *dname; @@ -475,7 +479,7 @@ char * mkdtemp(char *template) #endif #ifndef HAVE_PREAD -static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) +static ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) { if (lseek(__fd, __offset, SEEK_SET) != __offset) { return -1; @@ -485,7 +489,7 @@ static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) #endif #ifndef HAVE_PWRITE -static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) +static ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) { if (lseek(__fd, __offset, SEEK_SET) != __offset) { return -1; @@ -495,7 +499,7 @@ static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offs #endif #ifndef HAVE_STRCASESTR -char *strcasestr(const char *haystack, const char *needle) +char *rep_strcasestr(const char *haystack, const char *needle) { const char *s; size_t nlen = strlen(needle); @@ -511,7 +515,7 @@ char *strcasestr(const char *haystack, const char *needle) #ifndef HAVE_STRTOK_R /* based on GLIBC version, copyright Free Software Foundation */ -char *strtok_r(char *s, const char *delim, char **save_ptr) +char *rep_strtok_r(char *s, const char *delim, char **save_ptr) { char *token; @@ -535,3 +539,111 @@ char *strtok_r(char *s, const char *delim, char **save_ptr) return token; } #endif + +#ifndef HAVE_STRNLEN +/** + Some platforms don't have strnlen +**/ +size_t rep_strnlen(const char *s, size_t n) +{ + int i; + for (i=0; s[i] && itm_year; ++i) + res += is_leap(i) ? 366 : 365; + + for (i = 0; i < tm->tm_mon; ++i) + res += ndays[is_leap(tm->tm_year)][i]; + res += tm->tm_mday - 1; + res *= 24; + res += tm->tm_hour; + res *= 60; + res += tm->tm_min; + res *= 60; + res += tm->tm_sec; + return res; +} +#endif diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index e59ba43206..827777983f 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -4,25 +4,39 @@ macros to go along with the lib/replace/ portability layer code Copyright (C) Andrew Tridgell 2005 + Copyright (C) Jelmer Vernooij 2006 + + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _replace_h #define _replace_h +#ifdef _SAMBA_BUILD_ +#include "config.h" +#else +#include "replace_config.h" +#endif /* _SAMBA_BUILD_ */ + +#include +#include + #if defined(_MSC_VER) || defined(__MINGW32__) #include "lib/replace/win32/replace.h" #endif @@ -53,59 +67,78 @@ extern int errno; #endif #ifndef HAVE_STRDUP -char *strdup(const char *s); +#define strdup rep_strdup +char *rep_strdup(const char *s); #endif #ifndef HAVE_MEMMOVE -void *memmove(void *dest,const void *src,int size); +#define memmove rep_memmove +void *rep_memmove(void *dest,const void *src,int size); #endif #ifndef HAVE_MKTIME -time_t mktime(struct tm *t); +#define mktime rep_mktime +time_t rep_mktime(struct tm *t); #endif #ifndef HAVE_STRLCPY -size_t strlcpy(char *d, const char *s, size_t bufsize); +#define strlcpy rep_strlcpy +size_t rep_strlcpy(char *d, const char *s, size_t bufsize); #endif #ifndef HAVE_STRLCAT -size_t strlcat(char *d, const char *s, size_t bufsize); +#define strlcat rep_strlcat +size_t rep_strlcat(char *d, const char *s, size_t bufsize); #endif #ifndef HAVE_STRNDUP -char *strndup(const char *s, size_t n); +#define strndup rep_strndup +char *rep_strndup(const char *s, size_t n); #endif #ifndef HAVE_STRNLEN -size_t strnlen(const char *s, size_t n); -#endif - -#ifndef HAVE_STRTOUL -unsigned long strtoul(const char *nptr, char **endptr, int base); +#define strnlen rep_strnlen +size_t rep_strnlen(const char *s, size_t n); #endif #ifndef HAVE_SETENV -int setenv(const char *name, const char *value, int overwrite); +#define setenv rep_setenv +int rep_setenv(const char *name, const char *value, int overwrite); #endif #ifndef HAVE_RENAME -int rename(const char *zfrom, const char *zto); +#define rename rep_rename +int rep_rename(const char *zfrom, const char *zto); #endif #ifndef HAVE_STRCASESTR -char *strcasestr(const char *haystack, const char *needle); +#define strcasestr rep_strcasestr +char *rep_strcasestr(const char *haystack, const char *needle); #endif #ifndef HAVE_STRTOK_R -char *strtok_r(char *s, const char *delim, char **save_ptr); +#define strtok_r rep_strtok_r +char *rep_strtok_r(char *s, const char *delim, char **save_ptr); +#endif + +#ifndef HAVE_STRTOLL +#define strtoll rep_strtoll +long long int rep_strtoll(const char *str, char **endptr, int base); +#endif + +#ifndef HAVE_STRTOULL +#define strtoull rep_strtoull +unsigned long long int rep_strtoull(const char *str, char **endptr, int base); #endif #ifndef HAVE_FTRUNCATE -int ftruncate(int f,long l); +#define ftruncate rep_ftruncate +int rep_ftruncate(int f,long l); #endif #ifndef HAVE_VASPRINTF_DECL -int vasprintf(char **ptr, const char *format, va_list ap); +#define vasprintf rep_vasprintf +int rep_vasprintf(char **ptr, const char *format, va_list ap); #endif #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET) @@ -114,7 +147,8 @@ int vasprintf(char **ptr, const char *format, va_list ap); #ifndef HAVE_TIMEGM struct tm; -time_t timegm(struct tm *tm); +#define timegm rep_timegm +time_t rep_timegm(struct tm *tm); #endif #ifndef PRINTF_ATTRIBUTE @@ -131,10 +165,12 @@ time_t timegm(struct tm *tm); /* add varargs prototypes with printf checking */ #ifndef HAVE_SNPRINTF_DECL -int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4); +#define snprintf rep_snprintf +int rep_snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4); #endif #ifndef HAVE_ASPRINTF_DECL -int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); +#define asprintf rep_asprintf +int rep_asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); #endif @@ -174,7 +210,8 @@ int rep_mkstemp(char *temp); #endif #ifndef HAVE_MKDTEMP -char *mkdtemp(char *template); +#define mkdtemp rep_mkdtemp +char *rep_mkdtemp(char *template); #endif #ifdef HAVE_LIMITS_H @@ -248,4 +285,6 @@ typedef int bool; #define __STRING(x) #x #endif + + #endif diff --git a/source4/lib/replace/replace.m4 b/source4/lib/replace/replace.m4 new file mode 100644 index 0000000000..829f4db6f6 --- /dev/null +++ b/source4/lib/replace/replace.m4 @@ -0,0 +1,58 @@ +dnl Try to find a replacement library +dnl Will define HAVE_REPLACE_H if replace.h can be found +AC_DEFUN([SMB_LIBREPLACE], [ +AC_ARG_WITH(libreplace, +[ --with-libreplace Specify location to libreplace], +[ + # Check whether libreplace can actually be found in this location + if ! test -f "$withval/replace.h" + then + AC_MSG_ERROR([Unable to find replace.h in $withval]) + fi + replacedir=$withval +], +[ + # Check if we can find libreplace in a common location + for dir in . replace ../replace + do + AC_MSG_CHECKING([for libreplace in $dir]) + if test -f "$dir/replace.h" + then + replacedir="$dir" + AC_MSG_RESULT(yes) + break + fi + AC_MSG_RESULT(no) + done +]) + +AC_SUBST(REPLACE_LIBS) + +if test "$replacedir" != "" +then + REPLACE_LIBS="$replacedir/libreplace.a" + CFLAGS="$CFLAGS -I$replacedir" + AC_DEFINE(HAVE_REPLACE_H, 1, + [Whether replace.h is present and should be used]) +fi +]) + +dnl Try to find the specified functions in the system, or +dnl in Samba's replacement library. In the future, this may also +dnl try to find these functions in libroken or GNUlib if libreplace can't be +dnl found. +AC_DEFUN(SMB_REPLACE_FUNCS, [ + AC_REQUIRE([SMB_LIBREPLACE])dnl + + if test -z "$replacedir" || test -f "$replacedir/libreplace.a" + then + LIBS="$LIBS $REPLACE_LIBS" + for f in $1 + do + AC_CHECK_FUNC($f, [], [ + AC_MSG_ERROR([Unable to find $f in the system. Consider + specifying the path to the replacement library]) + ]) + done + fi +]) diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index eaa5eec405..8182f83751 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -103,11 +103,11 @@ * **************************************************************/ -#ifndef NO_CONFIG_H +#ifdef _SAMBA_BUILD_ #include "config.h" #else -#define NULL 0 -#endif +#include "replace_config.h" +#endif #ifdef TEST_SNPRINTF /* need math library headers for testing */ diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c new file mode 100644 index 0000000000..2c68fd6664 --- /dev/null +++ b/source4/lib/replace/test/testsuite.c @@ -0,0 +1,366 @@ +/* + Unix SMB/CIFS implementation. + + libreplace tests + + Copyright (C) Jelmer Vernooij 2006 + + ** NOTE! The following LGPL license applies to the talloc + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "../replace.h" +#include + +int test_ftruncate() +{ + /* FIXME */ + return true; +} + +int test_strlcpy() +{ + /* FIXME */ + return true; +} + +int test_strlcat() +{ + /* FIXME */ + return true; +} + +int test_mktime() +{ + /* FIXME */ + return true; +} + +int test_rename() +{ + /* FIXME */ + return true; +} + +int test_innetgr() +{ + /* FIXME */ + return true; +} + +int test_initgroups() +{ + /* FIXME */ + return true; +} + +int test_memmove() +{ + /* FIXME */ + return true; +} + +int test_strdup() +{ + /* FIXME */ + return true; +} + +int test_setlinebuf() +{ + /* FIXME */ + return true; +} + +int test_vsyslog() +{ + /* FIXME */ + return true; +} + +int test_timegm() +{ + /* FIXME */ + return true; +} + +int test_setenv() +{ + /* FIXME */ + return true; +} + +int test_strndup() +{ + /* FIXME */ + return true; +} + +int test_strnlen() +{ + /* FIXME */ + return true; +} + +int test_waitpid() +{ + /* FIXME */ + return true; +} + +int test_seteuid() +{ + /* FIXME */ + return true; +} + +int test_setegid() +{ + /* FIXME */ + return true; +} + +int test_asprintf() +{ + /* FIXME */ + return true; +} + +int test_snprintf() +{ + /* FIXME */ + return true; +} + +int test_vasprintf() +{ + /* FIXME */ + return true; +} + +int test_vsnprintf() +{ + /* FIXME */ + return true; +} + +int test_opendir() +{ + /* FIXME */ + return true; +} + +int test_readdir() +{ + /* FIXME */ + return true; +} + +int test_telldir() +{ + /* FIXME */ + return true; +} + +int test_seekdir() +{ + /* FIXME */ + return true; +} + +int test_dlopen() +{ + /* FIXME: test dlopen, dlsym, dlclose, dlerror */ + return true; +} + + +int test_chroot() +{ + /* FIXME: chroot() */ + return true; +} + +int test_bzero() +{ + /* FIXME: bzero */ + return true; +} + +int test_strerror() +{ + /* FIXME */ + return true; +} + +int test_errno() +{ + /* FIXME */ + return true; +} + +int test_mkdtemp() +{ + /* FIXME */ + return true; +} + +int test_mkstemp() +{ + /* FIXME */ + return true; +} + +int test_pread() +{ + /* FIXME */ + return true; +} + +int test_pwrite() +{ + /* FIXME */ + return true; +} + +int test_getpass() +{ + /* FIXME */ + return true; +} + +int test_inet_ntoa() +{ + /* FIXME */ + return true; +} + +int test_strtoll() +{ + /* FIXME */ + return true; +} + +int test_strtoull() +{ + /* FIXME */ + return true; +} + +/* +FIXME: +Types: +bool +socklen_t +uint_t +uint{8,16,32,64}_t +int{8,16,32,64}_t +intptr_t + +Constants: +PATH_NAME_MAX +UINT{16,32,64}_MAX +INT32_MAX +*/ + +int test_va_copy() +{ + /* FIXME */ + return true; +} + +int test_FUNCTION() +{ + /* FIXME: test __FUNCTION__ macro */ + return true; +} + +int test_MIN() +{ + /* FIXME */ + return true; +} + +int test_MAX() +{ + /* FIXME */ + return true; +} + +int torture_local_replace() +{ + int ret = true; +; + ret &= test_ftruncate(); + ret &= test_strlcpy(); + ret &= test_strlcat(); + ret &= test_mktime(); + ret &= test_rename(); + ret &= test_innetgr(); + ret &= test_initgroups(); + ret &= test_memmove(); + ret &= test_strdup(); + ret &= test_setlinebuf(); + ret &= test_vsyslog(); + ret &= test_timegm(); + ret &= test_setenv(); + ret &= test_strndup(); + ret &= test_strnlen(); + ret &= test_waitpid(); + ret &= test_seteuid(); + ret &= test_setegid(); + ret &= test_asprintf(); + ret &= test_snprintf(); + ret &= test_vasprintf(); + ret &= test_vsnprintf(); + ret &= test_opendir(); + ret &= test_readdir() ; + ret &= test_telldir(); + ret &= test_seekdir(); + ret &= test_dlopen(); + ret &= test_chroot(); + ret &= test_bzero(); + ret &= test_strerror(); + ret &= test_errno(); + ret &= test_mkdtemp(); + ret &= test_mkstemp(); + ret &= test_pread(); + ret &= test_pwrite(); + ret &= test_getpass(); + ret &= test_inet_ntoa(); + ret &= test_strtoll(); + ret &= test_strtoll(); + ret &= test_strtoull(); + ret &= test_va_copy(); + ret &= test_FUNCTION(); + ret &= test_MIN(); + ret &= test_MAX(); + + return ret; +} + +#if !defined(_SAMBA_BUILD_) || ((SAMBA_VERSION_MAJOR==3)&&(SAMBA_VERSION_MINOR<9)) +int main(void) +{ + if (!torture_local_replace(NULL)) { + printf("ERROR: TESTSUITE FAILED\n"); + return -1; + } + return 0; +} +#endif diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c new file mode 100644 index 0000000000..5fb15475f3 --- /dev/null +++ b/source4/lib/replace/timegm.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1997 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + adapted for Samba4 by Andrew Tridgell +*/ + +#include "includes.h" +#include "ldb/include/includes.h" + +#ifndef HAVE_TIMEGM + +static int is_leap(unsigned y) +{ + y += 1900; + return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0); +} + +time_t timegm(struct tm *tm) +{ + static const unsigned ndays[2][12] ={ + {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, + {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; + time_t res = 0; + unsigned i; + + for (i = 70; i < tm->tm_year; ++i) + res += is_leap(i) ? 366 : 365; + + for (i = 0; i < tm->tm_mon; ++i) + res += ndays[is_leap(tm->tm_year)][i]; + res += tm->tm_mday - 1; + res *= 24; + res += tm->tm_hour; + res *= 60; + res += tm->tm_min; + res *= 60; + res += tm->tm_sec; + return res; +} + +#endif /* HAVE_TIMEGM */ -- cgit From e8b3da023a186c095d108056130c56f90749b794 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 12:31:23 +0000 Subject: r18032: added a 'make distclean' (This used to be commit e83ea30b72c92ecf242274d090b00009bddd8be6) --- source4/lib/replace/Makefile.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 916b5df3d9..4f1d2c6e22 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -34,4 +34,12 @@ testsuite: libreplace.a $(TEST_OBJS) $(CC) $(CFLAGS) -c $< -o $@ clean: - rm -f *.o + rm -f *.o *.a testsuite + +distclean: clean + rm -f *~ */*~ + rm -rf autom4te.cache + rm -f configure \ + config.log config.status \ + replace_config.h + rm -f Makefile -- cgit From f3cf9d4ef6d30ec03a7b46c384a5ee914587fcd9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 12:31:40 +0000 Subject: r18033: added install-sh, needed for standalone libreplace build (This used to be commit 652c11e4b8d5188690bbe512b205ab5ac783aee8) --- source4/lib/replace/install-sh | 238 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100755 source4/lib/replace/install-sh (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/install-sh b/source4/lib/replace/install-sh new file mode 100755 index 0000000000..58719246f0 --- /dev/null +++ b/source4/lib/replace/install-sh @@ -0,0 +1,238 @@ +#! /bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. +# + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 -- cgit From 7e97a15fa0b67278499aa9aa3e2a307e5c8db097 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 12:36:06 +0000 Subject: r18034: fixed build of libreplace outside of source directory (This used to be commit 8c07569227c6f2b0c9abdfe535733f3d5cb40fe5) --- source4/lib/replace/Makefile.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 4f1d2c6e22..9c16448b92 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -9,6 +9,8 @@ srcdir = @srcdir@ builddir = @builddir@ INSTALL = @INSTALL@ +CFLAGS=-I. -I$(srcdir) @CFLAGS@ + OBJS = dlfcn.o getpass.o replace.o snprintf.o all: libreplace.a @@ -31,7 +33,7 @@ testsuite: libreplace.a $(TEST_OBJS) .c.o: @echo Compiling $*.c @mkdir -p `dirname $@` - $(CC) $(CFLAGS) -c $< -o $@ + @$(CC) $(CFLAGS) -c $< -o $@ clean: rm -f *.o *.a testsuite -- cgit From 63799e5c631ab0765b973f909ecb27a0454cbd2f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 12:39:41 +0000 Subject: r18035: - fixed 'make clean' to remove test objects - fixed 'make install' to create target dir should be ready to go into the build farm as a standalone build now? (This used to be commit 5feaeaf1dc6434874c8f4c0e913a7e6c70b87309) --- source4/lib/replace/Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 9c16448b92..4d14fe5123 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -16,6 +16,7 @@ OBJS = dlfcn.o getpass.o replace.o snprintf.o all: libreplace.a install: all + mkdir -p $(libdir) $(INSTALL) libreplace.a $(libdir) libreplace.a: $(OBJS) @@ -36,7 +37,7 @@ testsuite: libreplace.a $(TEST_OBJS) @$(CC) $(CFLAGS) -c $< -o $@ clean: - rm -f *.o *.a testsuite + rm -f *.o test/*.o *.a testsuite distclean: clean rm -f *~ */*~ -- cgit From e67b1f21f649ba0d47230646a210d2cd4c4d5250 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 12:56:14 +0000 Subject: r18037: added 'make installcheck' target (This used to be commit 34f173d8cb23a3e12e94744b696343757b837066) --- source4/lib/replace/Makefile.in | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 4d14fe5123..a53a1271ef 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -26,6 +26,8 @@ libreplace.a: $(OBJS) test: testsuite ./testsuite +installcheck: install test + TEST_OBJS = test/testsuite.o testsuite: libreplace.a $(TEST_OBJS) -- cgit From 6cf5528e20685585d4d1e3b779088f488f664273 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 12:57:40 +0000 Subject: r18038: make test fns static (This used to be commit 2dda101a5fcc40702df9fa2f932d6fe97ae64163) --- source4/lib/replace/test/testsuite.c | 86 ++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 2c68fd6664..83da05ce45 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -27,236 +27,236 @@ #include "../replace.h" #include -int test_ftruncate() +static int test_ftruncate() { /* FIXME */ return true; } -int test_strlcpy() +static int test_strlcpy() { /* FIXME */ return true; } -int test_strlcat() +static int test_strlcat() { /* FIXME */ return true; } -int test_mktime() +static int test_mktime() { /* FIXME */ return true; } -int test_rename() +static int test_rename() { /* FIXME */ return true; } -int test_innetgr() +static int test_innetgr() { /* FIXME */ return true; } -int test_initgroups() +static int test_initgroups() { /* FIXME */ return true; } -int test_memmove() +static int test_memmove() { /* FIXME */ return true; } -int test_strdup() +static int test_strdup() { /* FIXME */ return true; } -int test_setlinebuf() +static int test_setlinebuf() { /* FIXME */ return true; } -int test_vsyslog() +static int test_vsyslog() { /* FIXME */ return true; } -int test_timegm() +static int test_timegm() { /* FIXME */ return true; } -int test_setenv() +static int test_setenv() { /* FIXME */ return true; } -int test_strndup() +static int test_strndup() { /* FIXME */ return true; } -int test_strnlen() +static int test_strnlen() { /* FIXME */ return true; } -int test_waitpid() +static int test_waitpid() { /* FIXME */ return true; } -int test_seteuid() +static int test_seteuid() { /* FIXME */ return true; } -int test_setegid() +static int test_setegid() { /* FIXME */ return true; } -int test_asprintf() +static int test_asprintf() { /* FIXME */ return true; } -int test_snprintf() +static int test_snprintf() { /* FIXME */ return true; } -int test_vasprintf() +static int test_vasprintf() { /* FIXME */ return true; } -int test_vsnprintf() +static int test_vsnprintf() { /* FIXME */ return true; } -int test_opendir() +static int test_opendir() { /* FIXME */ return true; } -int test_readdir() +static int test_readdir() { /* FIXME */ return true; } -int test_telldir() +static int test_telldir() { /* FIXME */ return true; } -int test_seekdir() +static int test_seekdir() { /* FIXME */ return true; } -int test_dlopen() +static int test_dlopen() { /* FIXME: test dlopen, dlsym, dlclose, dlerror */ return true; } -int test_chroot() +static int test_chroot() { /* FIXME: chroot() */ return true; } -int test_bzero() +static int test_bzero() { /* FIXME: bzero */ return true; } -int test_strerror() +static int test_strerror() { /* FIXME */ return true; } -int test_errno() +static int test_errno() { /* FIXME */ return true; } -int test_mkdtemp() +static int test_mkdtemp() { /* FIXME */ return true; } -int test_mkstemp() +static int test_mkstemp() { /* FIXME */ return true; } -int test_pread() +static int test_pread() { /* FIXME */ return true; } -int test_pwrite() +static int test_pwrite() { /* FIXME */ return true; } -int test_getpass() +static int test_getpass() { /* FIXME */ return true; } -int test_inet_ntoa() +static int test_inet_ntoa() { /* FIXME */ return true; } -int test_strtoll() +static int test_strtoll() { /* FIXME */ return true; } -int test_strtoull() +static int test_strtoull() { /* FIXME */ return true; @@ -278,25 +278,25 @@ UINT{16,32,64}_MAX INT32_MAX */ -int test_va_copy() +static int test_va_copy() { /* FIXME */ return true; } -int test_FUNCTION() +static int test_FUNCTION() { /* FIXME: test __FUNCTION__ macro */ return true; } -int test_MIN() +static int test_MIN() { /* FIXME */ return true; } -int test_MAX() +static int test_MAX() { /* FIXME */ return true; -- cgit From 41ff8ad80e627f2c1df1f39831051a2911af54f4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 4 Sep 2006 13:07:29 +0000 Subject: r18039: Include header with time_t if needed. (This used to be commit b0cfdd24be88ba3963eb43cdbcb6317e65aed57b) --- source4/lib/replace/replace.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 827777983f..4f0308ce52 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -76,11 +76,21 @@ char *rep_strdup(const char *s); void *rep_memmove(void *dest,const void *src,int size); #endif +#if !defined(HAVE_MKTIME) || !defined(HAVE_TIMEGM) +#include +#endif + #ifndef HAVE_MKTIME #define mktime rep_mktime time_t rep_mktime(struct tm *t); #endif +#ifndef HAVE_TIMEGM +struct tm; +#define timegm rep_timegm +time_t rep_timegm(struct tm *tm); +#endif + #ifndef HAVE_STRLCPY #define strlcpy rep_strlcpy size_t rep_strlcpy(char *d, const char *s, size_t bufsize); @@ -145,11 +155,6 @@ int rep_vasprintf(char **ptr, const char *format, va_list ap); #define bzero(a,b) memset((a),'\0',(b)) #endif -#ifndef HAVE_TIMEGM -struct tm; -#define timegm rep_timegm -time_t rep_timegm(struct tm *tm); -#endif #ifndef PRINTF_ATTRIBUTE #if __GNUC__ >= 3 -- cgit From c90a12781be9f38ba2f03e903205e347733ff4a9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 4 Sep 2006 13:10:14 +0000 Subject: r18040: Use only one strnlen implementation (This used to be commit 9a421425d242f6e0385414121c114c7c62ea1aaa) --- source4/lib/replace/replace.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 5333c6a9fe..1c05c14eb6 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -375,7 +375,7 @@ void rep_vsyslog (int facility_priority, char *format, va_list arglist) /** Some platforms don't have strnlen **/ - size_t strnlen(const char *s, size_t max) + size_t rep_strnlen(const char *s, size_t max) { size_t len; @@ -540,19 +540,6 @@ char *rep_strtok_r(char *s, const char *delim, char **save_ptr) } #endif -#ifndef HAVE_STRNLEN -/** - Some platforms don't have strnlen -**/ -size_t rep_strnlen(const char *s, size_t n) -{ - int i; - for (i=0; s[i] && i Date: Mon, 4 Sep 2006 13:10:49 +0000 Subject: r18041: started on the bodies of the testsuite functions for libreplace (This used to be commit a2a6782ec721312e329cd16b609fb3eff8ad284d) --- source4/lib/replace/Makefile.in | 2 +- source4/lib/replace/test/testsuite.c | 44 +++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index a53a1271ef..2f13b97836 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -13,7 +13,7 @@ CFLAGS=-I. -I$(srcdir) @CFLAGS@ OBJS = dlfcn.o getpass.o replace.o snprintf.o -all: libreplace.a +all: libreplace.a testsuite install: all mkdir -p $(libdir) diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 83da05ce45..c00e2a788f 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -27,9 +27,51 @@ #include "../replace.h" #include +#if HAVE_STDLIB_H +#include +#endif + +#if HAVE_TYPES_H +#include +#endif + +#if HAVE_SYS_STAT_H +#include +#endif + +#include +#include + +#define TESTFILE "testfile.dat" + +/* + test ftruncate() function + */ static int test_ftruncate() { - /* FIXME */ + struct stat st; + int fd, i; + const int size; + printf("testing ftruncate\n"); + unlink(TESTFILE); + fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); + if (fd == -1) { + printf("creating '%s' failed - %s\n", TESTFILE, strerror(errno)); + return false; + } + if (ftruncate(fd, size) != 0) { + printf("ftruncate failed - %s\n", strerror(errno)); + return false; + } + if (fstat(fd, &st) != 0) { + printf("fstat failed - %s\n", strerror(errno)); + return false; + } + if (st.st_size != size) { + printf("ftruncate gave wrong size %d - expected %d\n", + (int)st.st_size, size); + return false; + } return true; } -- cgit From eab9f6d1027d678e45215f2db24c5cc44db14c8c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 13:27:16 +0000 Subject: r18042: testsuite needs to link to libreplace.a :-) (This used to be commit d359dea98eceadb4881578f70d8f4453ec0a2b88) --- source4/lib/replace/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 2f13b97836..1880a122dd 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -31,7 +31,7 @@ installcheck: install test TEST_OBJS = test/testsuite.o testsuite: libreplace.a $(TEST_OBJS) - $(CC) -o testsuite $(TEST_OBJS) + $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace .c.o: @echo Compiling $*.c -- cgit From 73493a095ae4802cd3e1222b22321454db17b988 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 13:28:54 +0000 Subject: r18043: added strlcpy() test (This used to be commit a68b3395199d2d47af3b23959e6da7109a9c5193) --- source4/lib/replace/test/testsuite.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index c00e2a788f..5d20c345f8 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -75,9 +75,31 @@ static int test_ftruncate() return true; } +/* + test strlcpy() function. + see http://www.gratisoft.us/todd/papers/strlcpy.html + */ static int test_strlcpy() { - /* FIXME */ + char buf[4]; + const struct { + const char *src; + int result; + } tests[] = { + { "abc", 3 }, + { "abcdef", 6 }, + { "abcd", 4 }, + { "", 0 }, + { NULL, 0 } + }; + int i; + printf("testing strlcpy\n"); + for (i=0;tests[i].src;i++) { + if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) { + printf("strlcpy test %d failed\n"); + return false; + } + } return true; } @@ -347,7 +369,6 @@ static int test_MAX() int torture_local_replace() { int ret = true; -; ret &= test_ftruncate(); ret &= test_strlcpy(); ret &= test_strlcat(); -- cgit From cb962c93737e8d0facdcd26461aaea5062a3b21d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 13:35:03 +0000 Subject: r18044: timegm.c needs to be in a separate file (This used to be commit 3ec1db7bd12cdc233c37f261073a33fc48ecd7ce) --- source4/lib/replace/Makefile.in | 2 +- source4/lib/replace/replace.c | 33 +-------------------------------- source4/lib/replace/timegm.c | 4 ++-- 3 files changed, 4 insertions(+), 35 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 1880a122dd..1dbc94341b 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -11,7 +11,7 @@ INSTALL = @INSTALL@ CFLAGS=-I. -I$(srcdir) @CFLAGS@ -OBJS = dlfcn.o getpass.o replace.o snprintf.o +OBJS = dlfcn.o getpass.o replace.o snprintf.o timegm.o all: libreplace.a testsuite diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 1c05c14eb6..7bfdc3d640 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -468,7 +468,7 @@ char *rep_mkdtemp(char *template) { char *dname; - if (dname = mktemp(template)) { + if ((dname = mktemp(template))) { if (mkdir(dname, 0700) >= 0) { return dname; } @@ -603,34 +603,3 @@ int rep_setenv(const char *name, const char *value, int overwrite) } #endif -#if !defined(HAVE_TIMEGM) - -static int is_leap(unsigned y) -{ - y += 1900; - return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0); -} - -time_t timegm(struct tm *tm) -{ - static const unsigned ndays[2][12] ={ - {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, - {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; - time_t res = 0; - unsigned i; - - for (i = 70; i < tm->tm_year; ++i) - res += is_leap(i) ? 366 : 365; - - for (i = 0; i < tm->tm_mon; ++i) - res += ndays[is_leap(tm->tm_year)][i]; - res += tm->tm_mday - 1; - res *= 24; - res += tm->tm_hour; - res *= 60; - res += tm->tm_min; - res *= 60; - res += tm->tm_sec; - return res; -} -#endif diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c index 5fb15475f3..1c9a0e4165 100644 --- a/source4/lib/replace/timegm.c +++ b/source4/lib/replace/timegm.c @@ -35,8 +35,8 @@ adapted for Samba4 by Andrew Tridgell */ -#include "includes.h" -#include "ldb/include/includes.h" +#include "replace.h" +#include #ifndef HAVE_TIMEGM -- cgit From c13ea9b3a6601406d29c5970734891fbc7eccaac Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 4 Sep 2006 13:47:57 +0000 Subject: r18045: Update format, list "test" target as phony. (This used to be commit 1f431dcd0a1f9a2cd5a0a3b73fbf8b05b8bc6793) --- source4/lib/replace/Makefile.in | 2 ++ source4/lib/replace/test/testsuite.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 1dbc94341b..54196b089a 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -9,6 +9,8 @@ srcdir = @srcdir@ builddir = @builddir@ INSTALL = @INSTALL@ +.PHONY: test + CFLAGS=-I. -I$(srcdir) @CFLAGS@ OBJS = dlfcn.o getpass.o replace.o snprintf.o timegm.o diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 5d20c345f8..998715f63f 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -96,7 +96,7 @@ static int test_strlcpy() printf("testing strlcpy\n"); for (i=0;tests[i].src;i++) { if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) { - printf("strlcpy test %d failed\n"); + printf("strlcpy test %d failed\n", i); return false; } } -- cgit From 62e60274131ae4968560bbd58fb847cb9f9e8f9f Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 4 Sep 2006 16:30:40 +0000 Subject: r18046: Add 'z' specifier support and a configure test. Jeremy should I backport this to samba3 too? (This used to be commit dc689b5579987da8ee5397b9758a42b01e44fb73) --- source4/lib/replace/config.m4 | 12 ++++++--- source4/lib/replace/snprintf.c | 55 +++++++++++++++++++++++++++++++++--------- 2 files changed, 51 insertions(+), 16 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index c2e0e5e6f4..8bfd836189 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -91,7 +91,9 @@ AC_CHECK_HEADERS(strings.h) AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[ AC_TRY_RUN([ #include +#include #include +#include void foo(const char *format, ...) { va_list ap; int len; @@ -107,12 +109,14 @@ void foo(const char *format, ...) { va_start(ap, format); len = vsnprintf(0, 0, format, ap); va_end(ap); - if (len != 5) exit(1); + if (len != 5) exit(2); - if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); + if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3); - if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(1); - if (snprintf(buf, 20, "%s", 0) < 3) exit(1); + if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4); + if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5); + if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6); + if (snprintf(buf, 20, "%s", 0) < 3) exit(7); exit(0); } diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 8182f83751..30c2b0a1b7 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -200,6 +200,7 @@ #define DP_C_LONG 3 #define DP_C_LDOUBLE 4 #define DP_C_LLONG 5 +#define DP_C_SIZET 6 /* Chunk types */ #define CNK_FMT_STR 0 @@ -467,6 +468,10 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args cnk->cflags = DP_C_LDOUBLE; ch = *format++; break; + case 'z': + cnk->cflags = DP_C_SIZET; + ch = *format++; + break; default: break; } @@ -575,6 +580,8 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args cnk->value = va_arg (args, long int); else if (cnk->cflags == DP_C_LLONG) cnk->value = va_arg (args, LLONG); + else if (cnk->cflags == DP_C_SIZET) + cnk->value = va_arg (args, ssize_t); else cnk->value = va_arg (args, int); @@ -592,6 +599,8 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args cnk->value = (unsigned long int)va_arg (args, unsigned long int); else if (cnk->cflags == DP_C_LLONG) cnk->value = (LLONG)va_arg (args, unsigned LLONG); + else if (cnk->cflags == DP_C_SIZET) + cnk->value = (size_t)va_arg (args, size_t); else cnk->value = (unsigned int)va_arg (args, unsigned int); @@ -644,6 +653,8 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args cnk->pnum = va_arg (args, long int *); else if (cnk->cflags == DP_C_LLONG) cnk->pnum = va_arg (args, LLONG *); + else if (cnk->cflags == DP_C_SIZET) + cnk->pnum = va_arg (args, ssize_t *); else cnk->pnum = va_arg (args, int *); @@ -725,6 +736,8 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args *((long int *)(cnk->pnum)) = (long int)currlen; else if (cnk->cflags == DP_C_LLONG) *((LLONG *)(cnk->pnum)) = (LLONG)currlen; + else if (cnk->cflags == DP_C_SIZET) + *((ssize_t *)(cnk->pnum)) = (ssize_t)currlen; else *((int *)(cnk->pnum)) = (int)currlen; break; @@ -1258,6 +1271,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, #ifdef TEST_SNPRINTF int sprintf(char *str,const char *fmt,...); + int printf(const char *fmt,...); int main (void) { @@ -1327,15 +1341,20 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, int fail = 0; int num = 0; int l1, l2; + char *ss_fmt[] = { + "%zd", + "%zu", + NULL + }; + size_t ss_nums[] = {134, 91340, 123456789, 0203, 1234567890, 0}; printf ("Testing snprintf format codes against system sprintf...\n"); for (x = 0; fp_fmt[x] ; x++) { for (y = 0; fp_nums[y] != 0 ; y++) { buf1[0] = buf2[0] = '\0'; - l1 = snprintf(NULL, 0, fp_fmt[x], fp_nums[y]); - l2 = sprintf(buf1, fp_fmt[x], fp_nums[y]); - sprintf (buf2, fp_fmt[x], fp_nums[y]); + l1 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]); + l2 = sprintf (buf2, fp_fmt[x], fp_nums[y]); buf1[1023] = buf2[1023] = '\0'; if (strcmp (buf1, buf2) || (l1 != l2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", @@ -1349,9 +1368,8 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, for (x = 0; int_fmt[x] ; x++) { for (y = 0; int_nums[y] != 0 ; y++) { buf1[0] = buf2[0] = '\0'; - l1 = snprintf(NULL, 0, int_fmt[x], int_nums[y]); - l2 = sprintf(buf1, int_fmt[x], int_nums[y]); - sprintf (buf2, int_fmt[x], int_nums[y]); + l1 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]); + l2 = sprintf (buf2, int_fmt[x], int_nums[y]); buf1[1023] = buf2[1023] = '\0'; if (strcmp (buf1, buf2) || (l1 != l2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", @@ -1365,9 +1383,8 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, for (x = 0; str_fmt[x] ; x++) { for (y = 0; str_vals[y] != 0 ; y++) { buf1[0] = buf2[0] = '\0'; - l1 = snprintf(NULL, 0, str_fmt[x], str_vals[y]); - l2 = sprintf(buf1, str_fmt[x], str_vals[y]); - sprintf (buf2, str_fmt[x], str_vals[y]); + l1 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]); + l2 = sprintf (buf2, str_fmt[x], str_vals[y]); buf1[1023] = buf2[1023] = '\0'; if (strcmp (buf1, buf2) || (l1 != l2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", @@ -1382,9 +1399,8 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, for (x = 0; ll_fmt[x] ; x++) { for (y = 0; ll_nums[y] != 0 ; y++) { buf1[0] = buf2[0] = '\0'; - l1 = snprintf(NULL, 0, ll_fmt[x], ll_nums[y]); - l2 = sprintf(buf1, ll_fmt[x], ll_nums[y]); - sprintf (buf2, ll_fmt[x], ll_nums[y]); + l1 = snprintf(buf1, sizeof(buf1), ll_fmt[x], ll_nums[y]); + l2 = sprintf (buf2, ll_fmt[x], ll_nums[y]); buf1[1023] = buf2[1023] = '\0'; if (strcmp (buf1, buf2) || (l1 != l2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", @@ -1431,6 +1447,21 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, "%4$*1$d %2$s %3$*1$.*1$f", l1, buf1, l2, buf2); fail++; } + + for (x = 0; ss_fmt[x] ; x++) { + for (y = 0; ss_nums[y] != 0 ; y++) { + buf1[0] = buf2[0] = '\0'; + l1 = snprintf(buf1, sizeof(buf1), ss_fmt[x], ss_nums[y]); + l2 = sprintf (buf2, ss_fmt[x], ss_nums[y]); + buf1[1023] = buf2[1023] = '\0'; + if (strcmp (buf1, buf2) || (l1 != l2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n", + ss_fmt[x], l1, buf1, l2, buf2); + fail++; + } + num++; + } + } #if 0 buf1[0] = buf2[0] = '\0'; l1 = snprintf(buf1, sizeof(buf1), "%lld", (LLONG)1234567890); -- cgit From a0202040e2b99117e6307e886fd08401330d20f8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 22:49:30 +0000 Subject: r18051: - add gcc warning flags - fix piles of warnings and ftruncate bug in libreplace testsuite (This used to be commit f5fc88f0c4c752a2773d5280ed4d94818e2d4744) --- source4/lib/replace/configure.ac | 6 +++ source4/lib/replace/test/testsuite.c | 100 +++++++++++++++++++---------------- 2 files changed, 60 insertions(+), 46 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index a05a9cbfe7..3d56c8d934 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -46,6 +46,12 @@ AC_INIT(dlfcn.c) AC_CONFIG_SRCDIR([dlfcn.c]) AC_CONFIG_HEADER(replace_config.h) AC_PROG_INSTALL +AC_PROG_CC + +if test "$ac_cv_prog_gcc" = yes; then + CFLAGS="$CFLAGS -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings" +fi + sinclude(config.m4) sinclude(win32/config.m4) sinclude(repdir/config.m4) diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 998715f63f..0dad3de9db 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -39,6 +39,14 @@ #include #endif +#if HAVE_UNISTD_H +#include +#endif + +#if HAVE_STRING_H +#include +#endif + #include #include @@ -47,11 +55,11 @@ /* test ftruncate() function */ -static int test_ftruncate() +static int test_ftruncate(void) { struct stat st; - int fd, i; - const int size; + int fd; + const int size = 1234; printf("testing ftruncate\n"); unlink(TESTFILE); fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); @@ -79,7 +87,7 @@ static int test_ftruncate() test strlcpy() function. see http://www.gratisoft.us/todd/papers/strlcpy.html */ -static int test_strlcpy() +static int test_strlcpy(void) { char buf[4]; const struct { @@ -103,224 +111,224 @@ static int test_strlcpy() return true; } -static int test_strlcat() +static int test_strlcat(void) { /* FIXME */ return true; } -static int test_mktime() +static int test_mktime(void) { /* FIXME */ return true; } -static int test_rename() +static int test_rename(void) { /* FIXME */ return true; } -static int test_innetgr() +static int test_innetgr(void) { /* FIXME */ return true; } -static int test_initgroups() +static int test_initgroups(void) { /* FIXME */ return true; } -static int test_memmove() +static int test_memmove(void) { /* FIXME */ return true; } -static int test_strdup() +static int test_strdup(void) { /* FIXME */ return true; } -static int test_setlinebuf() +static int test_setlinebuf(void) { /* FIXME */ return true; } -static int test_vsyslog() +static int test_vsyslog(void) { /* FIXME */ return true; } -static int test_timegm() +static int test_timegm(void) { /* FIXME */ return true; } -static int test_setenv() +static int test_setenv(void) { /* FIXME */ return true; } -static int test_strndup() +static int test_strndup(void) { /* FIXME */ return true; } -static int test_strnlen() +static int test_strnlen(void) { /* FIXME */ return true; } -static int test_waitpid() +static int test_waitpid(void) { /* FIXME */ return true; } -static int test_seteuid() +static int test_seteuid(void) { /* FIXME */ return true; } -static int test_setegid() +static int test_setegid(void) { /* FIXME */ return true; } -static int test_asprintf() +static int test_asprintf(void) { /* FIXME */ return true; } -static int test_snprintf() +static int test_snprintf(void) { /* FIXME */ return true; } -static int test_vasprintf() +static int test_vasprintf(void) { /* FIXME */ return true; } -static int test_vsnprintf() +static int test_vsnprintf(void) { /* FIXME */ return true; } -static int test_opendir() +static int test_opendir(void) { /* FIXME */ return true; } -static int test_readdir() +static int test_readdir(void) { /* FIXME */ return true; } -static int test_telldir() +static int test_telldir(void) { /* FIXME */ return true; } -static int test_seekdir() +static int test_seekdir(void) { /* FIXME */ return true; } -static int test_dlopen() +static int test_dlopen(void) { /* FIXME: test dlopen, dlsym, dlclose, dlerror */ return true; } -static int test_chroot() +static int test_chroot(void) { /* FIXME: chroot() */ return true; } -static int test_bzero() +static int test_bzero(void) { /* FIXME: bzero */ return true; } -static int test_strerror() +static int test_strerror(void) { /* FIXME */ return true; } -static int test_errno() +static int test_errno(void) { /* FIXME */ return true; } -static int test_mkdtemp() +static int test_mkdtemp(void) { /* FIXME */ return true; } -static int test_mkstemp() +static int test_mkstemp(void) { /* FIXME */ return true; } -static int test_pread() +static int test_pread(void) { /* FIXME */ return true; } -static int test_pwrite() +static int test_pwrite(void) { /* FIXME */ return true; } -static int test_getpass() +static int test_getpass(void) { /* FIXME */ return true; } -static int test_inet_ntoa() +static int test_inet_ntoa(void) { /* FIXME */ return true; } -static int test_strtoll() +static int test_strtoll(void) { /* FIXME */ return true; } -static int test_strtoull() +static int test_strtoull(void) { /* FIXME */ return true; @@ -342,31 +350,31 @@ UINT{16,32,64}_MAX INT32_MAX */ -static int test_va_copy() +static int test_va_copy(void) { /* FIXME */ return true; } -static int test_FUNCTION() +static int test_FUNCTION(void) { /* FIXME: test __FUNCTION__ macro */ return true; } -static int test_MIN() +static int test_MIN(void) { /* FIXME */ return true; } -static int test_MAX() +static int test_MAX(void) { /* FIXME */ return true; } -int torture_local_replace() +int torture_local_replace(void *ctx) { int ret = true; ret &= test_ftruncate(); -- cgit From cbae8b2014dc118e876018a0dcf27167724d0143 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Sep 2006 22:58:55 +0000 Subject: r18052: discard_const_p() isn't part of the libreplace API, so we can't use it inside libreplace. (This used to be commit 5745ecdd826c387137a742f32ee3c8f60191a6a7) --- source4/lib/replace/replace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 7bfdc3d640..17a04c6239 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -506,7 +506,7 @@ char *rep_strcasestr(const char *haystack, const char *needle) for (s=haystack;*s;s++) { if (toupper(*needle) == toupper(*s) && strncasecmp(s, needle, nlen) == 0) { - return discard_const_p(char, s); + return (char *)((intptr_t)s); } } return NULL; -- cgit From 474b74b345b7ebe5492fe9c09d2ca07438bf836f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 01:50:52 +0000 Subject: r18053: the sig_atomic_t test needs to be in libreplace for getpass.c to compile on hpux (This used to be commit a0bd4f5c4a08f4815aa742cc2406ed8e46d7b8f5) --- source4/lib/replace/config.m4 | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 8bfd836189..32870df386 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -192,3 +192,16 @@ eprintf("bla", "bar"); # Check prerequisites AC_CHECK_FUNCS([memset printf syslog], [], [ AC_MSG_ERROR([Required function not found])]) + +AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ + AC_TRY_COMPILE([ +#include +#if STDC_HEADERS +#include +#include +#endif +#include ],[sig_atomic_t i = 0], + samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)]) +if test x"$samba_cv_sig_atomic_t" = x"yes"; then + AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type]) +fi -- cgit From d9319068f5745af01619d46468eca9cc9b57b5be Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 01:54:49 +0000 Subject: r18054: snprintf.c needs to use replace.h to get the rep_vasprintf and related macros (This used to be commit 3917436ff733f8ee1925e646eec2331190d79663) --- source4/lib/replace/snprintf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 30c2b0a1b7..dd41ca3306 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -103,11 +103,7 @@ * **************************************************************/ -#ifdef _SAMBA_BUILD_ -#include "config.h" -#else -#include "replace_config.h" -#endif +#include "replace.h" #ifdef TEST_SNPRINTF /* need math library headers for testing */ -- cgit From a587277aa31dcb9dc46e02e165e2c4ebb6e2be1a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 02:03:22 +0000 Subject: r18055: aix needs time.h for timegm.c to compile (This used to be commit 1c91de687f0078100aa9de9111416c9fced45990) --- source4/lib/replace/config.m4 | 1 + source4/lib/replace/timegm.c | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 32870df386..0a8e4448b0 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -50,6 +50,7 @@ AC_TRY_COMPILE([ [AC_DEFINE(socklen_t, int,[Socket length type])]) AC_CHECK_HEADERS(sys/syslog.h syslog.h) +AC_CHECK_HEADERS(sys/time.h time.h) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c index 1c9a0e4165..c2746db1a4 100644 --- a/source4/lib/replace/timegm.c +++ b/source4/lib/replace/timegm.c @@ -40,6 +40,14 @@ #ifndef HAVE_TIMEGM +#ifdef HAVE_SYS_TIME_H +#include +#endif + +#ifdef TIME_H +#include +#endif + static int is_leap(unsigned y) { y += 1900; -- cgit From e057ef3c6f97f85b846add87aebf97c24170c55f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 02:05:36 +0000 Subject: r18056: includes needed for O_CREAT (This used to be commit 0b80ee8b3b17d4914010c9a54d5c2dcb69738990) --- source4/lib/replace/replace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 17a04c6239..b1154fb7a2 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -26,8 +26,10 @@ #include #include -#include #include +#include +#include +#include void replace_dummy(void); void replace_dummy(void) {} -- cgit From 3539b6ae7b6c4187927e30582fde7f8b40672833 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 04:19:16 +0000 Subject: r18057: fixed an #ifdef (This used to be commit e4c3b9ea2fd47540f693ced2fa6b7aa55372315b) --- source4/lib/replace/timegm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c index c2746db1a4..bd20da703f 100644 --- a/source4/lib/replace/timegm.c +++ b/source4/lib/replace/timegm.c @@ -44,7 +44,7 @@ #include #endif -#ifdef TIME_H +#ifdef HAVE_TIME_H #include #endif -- cgit From 09a4749a314eb5cdbef55d5e87ba229353de2c26 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 04:23:11 +0000 Subject: r18058: we don't actually need __VA_ARGS__ yet (its another C99 feature which I don't think we use anywhere) (This used to be commit bac8d5ce28e86b703a917902f44588746d7e8290) --- source4/lib/replace/config.m4 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 0a8e4448b0..994cd24866 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -185,10 +185,11 @@ AC_CHECK_TYPE(comparison_fn_t, AC_CHECK_FUNCS(timegm strnlen setenv) AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) -AC_TRY_CPP([ -#define eprintf(...) fprintf(stderr, __VA_ARGS__) -eprintf("bla", "bar"); -], [], [AC_MSG_ERROR([__VA_ARGS__ is required])]) +# this test disabled as we don't actually need __VA_ARGS__ yet +# AC_TRY_CPP([ +# #define eprintf(...) fprintf(stderr, __VA_ARGS__) +# eprintf("bla", "bar"); +# ], [], [AC_MSG_ERROR([__VA_ARGS__ is required])]) # Check prerequisites AC_CHECK_FUNCS([memset printf syslog], [], -- cgit From a41abfd514ae2259207b3cb90b8bc76434164b91 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 04:48:01 +0000 Subject: r18059: another cpp error (This used to be commit 64eff9d9d998ec2fd3d75393eb57028dfb942acf) --- source4/lib/replace/test/testsuite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 0dad3de9db..af50edc2a3 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -31,7 +31,7 @@ #include #endif -#if HAVE_TYPES_H +#if HAVE_SYS_TYPES_H #include #endif -- cgit From bd35940710efa8cda09a75b273ce19900312997d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 04:53:46 +0000 Subject: r18060: use gmake for libreplace if available (This used to be commit 838de24dfeeb4f67d836681d8ca4b8f94b38d6e2) --- source4/lib/replace/Makefile.in | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 54196b089a..baadbc5d5c 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -1,3 +1,5 @@ +#!gmake +# CC = @CC@ prefix = @prefix@ exec_prefix = @exec_prefix@ -- cgit From 5d363fa0ddcb8d6c6f13e4e975ce260c40780092 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 04:58:23 +0000 Subject: r18061: this should fix the libreplace build on us4 with gcc (This used to be commit 71c0a0731c52458105974e9ad727b7ba403fd992) --- source4/lib/replace/config.m4 | 1 + source4/lib/replace/replace.c | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 994cd24866..53eda9e8ed 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -51,6 +51,7 @@ AC_TRY_COMPILE([ AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_HEADERS(sys/time.h time.h) +AC_CHECK_HEADERS(sys/socket.h netinet/in.h) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b1154fb7a2..b9c106d582 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -31,6 +31,14 @@ #include #include +#if HAVE_SYS_SOCKET_H +#include +#endif + +#if HAVE_NETINET_IN_H +#include +#endif + void replace_dummy(void); void replace_dummy(void) {} -- cgit From 8e9c4e83fa02642d6c8671e9fe0108f417c9268f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 07:58:26 +0000 Subject: r18067: some tweaks for irix and hpux this checks for -AC99 or -c99 to get C99 structure init to work. It's based on a similar macro metze did for Samba4. the double sinclude() is weird, but I can't see any other way to use a common config.m4 between libreplace and all the projects that use it (This used to be commit 8d80024976bc508d73b42b4cf12315fe8f7a6322) --- source4/lib/replace/cc_features.m4 | 42 ++++++++++++++++++++++++++++++++++++++ source4/lib/replace/config.m4 | 6 ++++++ source4/lib/replace/replace.h | 8 ++------ 3 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 source4/lib/replace/cc_features.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/cc_features.m4 b/source4/lib/replace/cc_features.m4 new file mode 100644 index 0000000000..a109dfb414 --- /dev/null +++ b/source4/lib/replace/cc_features.m4 @@ -0,0 +1,42 @@ +dnl C99 compiler check +dnl ------------------------------------------------------- +dnl Copyright (C) Stefan (metze) Metzmacher 2004,2005 +dnl Released under the GNU GPL +dnl ------------------------------------------------------- +dnl +dnl adapted for libreplace by Andrew Tridgell + +############################################ +# Check if the compiler handles c99 struct initialization, and if not try -AC99 and -c99 flags +# Usage: LIBREPLACE_CC_SUPPORTS_C99_STRUCT_INIT(success-action,failure-action) +# changes CFLAGS to add -AC99 or -c99 if needed + +AC_DEFUN([LIBREPLACE_C99_STRUCT_INIT], +[ +AC_MSG_CHECKING(for C99 designated initializers) +saved_CFLAGS="$CFLAGS"; +AC_TRY_COMPILE([#include ], + [ struct foo {int x;char y;}; + struct foo bar = { .y = 'X', .x = 1 }; + ], + [AC_MSG_RESULT(yes); c99_init=yes; $1], [c99_init=no; AC_MSG_RESULT(no)]) +if test x"$c99_init" = x"no"; then + AC_MSG_CHECKING(for C99 designated initializers with -AC99) + CFLAGS="$saved_CFLAGS -AC99"; + AC_TRY_COMPILE([#include ], + [ struct foo {int x;char y;}; + struct foo bar = { .y = 'X', .x = 1 }; + ], + [AC_MSG_RESULT(yes); c99_init=yes; $1],[AC_MSG_RESULT(no)]) +fi +if test x"$c99_init" = x"no"; then + AC_MSG_CHECKING(for C99 designated initializers with -c99) + CFLAGS="$saved_CFLAGS -c99" + AC_TRY_COMPILE([#include ], + [ struct foo {int x;char y;}; + struct foo bar = { .y = 'X', .x = 1 }; + ], + [AC_MSG_RESULT(yes); $1],[AC_MSG_RESULT(no);CFLAGS="$saved_CFLAGS"; $2]) +fi +]) + diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index 53eda9e8ed..a846f5168f 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -142,6 +142,12 @@ AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) sinclude(lib/replace/getpass.m4) +sinclude(getpass.m4) +sinclude(lib/replace/cc_features.m4) +sinclude(cc_features.m4) + +LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes, + c99_struct_initialization=no) dnl VA_COPY AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[ diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 4f0308ce52..1d07361a28 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -51,9 +51,7 @@ #ifdef HAVE_STDINT_H #include -#endif - -#ifdef HAVE_INTTYPES_H +#elif HAVE_INTTYPES_H #include #endif @@ -257,9 +255,7 @@ char *rep_mkdtemp(char *template); #ifdef HAVE_STDBOOL_H #include -#endif - -#ifndef HAVE_BOOL +#elif !defined(HAVE_BOOL) #define __bool_true_false_are_defined typedef int bool; #define false (0) -- cgit From a57365a2e6f303572da011e490d05e1424c53934 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 11:21:16 +0000 Subject: r18073: next step in grab libreplace plan - see IRC logs for very detailed discussion wity metze and jelmer! (This used to be commit f18c913b6cf772c44dfaa8a3164cc78f6554e4a9) --- source4/lib/replace/Makefile.in | 6 +++--- source4/lib/replace/config.m4 | 30 +++++++++++++++++------------- source4/lib/replace/configure.ac | 40 ---------------------------------------- 3 files changed, 20 insertions(+), 56 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index baadbc5d5c..502dacbd2a 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -6,16 +6,16 @@ exec_prefix = @exec_prefix@ bindir = @bindir@ includedir = @includedir@ libdir = @libdir@ -VPATH = @srcdir@ +VPATH = @libreplacedir@ srcdir = @srcdir@ builddir = @builddir@ INSTALL = @INSTALL@ .PHONY: test -CFLAGS=-I. -I$(srcdir) @CFLAGS@ +CFLAGS=-I. -I@libreplacedir@ @CFLAGS@ -OBJS = dlfcn.o getpass.o replace.o snprintf.o timegm.o +OBJS = @LIBREPLACEOBJ@ all: libreplace.a testsuite diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 index a846f5168f..382da639fc 100644 --- a/source4/lib/replace/config.m4 +++ b/source4/lib/replace/config.m4 @@ -1,3 +1,16 @@ +dnl find the libreplace sources. This is meant to work both for +dnl libreplace standalone builds, and builds of packages using libreplace +libreplacedir="" +for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace"; do + if test -f "$d/replace.c"; then + libreplacedir="$d" + AC_SUBST(libreplacedir) + break; + fi +done +LIBREPLACEOBJ="dlfcn.o getpass.o replace.o snprintf.o timegm.o" +AC_SUBST(LIBREPLACEOBJ) + AC_CHECK_HEADERS([stdint.h inttypes.h]) AC_CHECK_TYPE(uint_t, unsigned int) AC_CHECK_TYPE(uint8_t, unsigned char) @@ -56,9 +69,7 @@ AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) -AC_HAVE_DECL(setresuid, [#include ]) -AC_HAVE_DECL(setresgid, [#include ]) -AC_HAVE_DECL(errno, [#include ]) +AC_CHECK_DECLS([setresuid, setresgid, errno]) AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[ AC_TRY_RUN([#include @@ -83,10 +94,7 @@ if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then fi dnl Provided by snprintf.c: -AC_HAVE_DECL(asprintf, [#include ]) -AC_HAVE_DECL(vasprintf, [#include ]) -AC_HAVE_DECL(vsnprintf, [#include ]) -AC_HAVE_DECL(snprintf, [#include ]) +AC_CHECK_DECLS([asprintf, vasprintf, snprintf]) AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf) AC_CHECK_HEADERS(strings.h) @@ -129,14 +137,10 @@ if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf]) fi -dnl Provided by dlfcn.c: -AC_SEARCH_LIBS_EXT(dlopen, [dl], DL_LIBS) -SMB_EXT_LIB(DL,[${DL_LIBS}],[${DL_CFLAGS}],[${DL_CPPFLAGS}],[${DL_LDFLAGS}]) -SAVE_LIBS="$LIBS" -LIBS="$LIBS $DL_LIBS" +dnl dummies provided by dlfcn.c if not available +AC_SEARCH_LIBS(dlopen, dl) AC_CHECK_HEADERS(dlfcn.h) AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose) -LIBS="$SAVE_LIBS" AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index 3d56c8d934..2b5fbf1c18 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -1,46 +1,6 @@ AC_DEFUN([SMB_EXT_LIB], [echo -n ""]) AC_DEFUN([SMB_ENABLE], [echo -n ""]) -dnl see if a declaration exists for a function or variable -dnl defines HAVE_function_DECL if it exists -dnl AC_HAVE_DECL(var, includes) -AC_DEFUN(AC_HAVE_DECL, -[ - AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[ - AC_TRY_COMPILE([$2],[int i = (int)$1], - ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)]) - if test x"$ac_cv_have_$1_decl" = x"yes"; then - AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available]) - fi -]) - -dnl AC_SEARCH_LIBS_EXT(FUNCTION, SEARCH-LIBS, EXT_LIBS, -dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], -dnl [OTHER-LIBRARIES]) -dnl -------------------------------------------------------- -dnl Search for a library defining FUNC, if it's not already available. -AC_DEFUN([AC_SEARCH_LIBS_EXT], -[AC_CACHE_CHECK([for library containing $1], [ac_cv_search_ext_$1], -[ -ac_func_search_ext_save_LIBS=$LIBS -ac_cv_search_ext_$1=no -AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], - [ac_cv_search_ext_$1="none required"]) -if test "$ac_cv_search_ext_$1" = no; then - for ac_lib in $2; do - LIBS="-l$ac_lib $$3 $6 $ac_func_search_save_ext_LIBS" - AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], - [ac_cv_search_ext_$1="-l$ac_lib" -break]) - done -fi -LIBS=$ac_func_search_ext_save_LIBS]) -AS_IF([test "$ac_cv_search_ext_$1" != no], - [test "$ac_cv_search_ext_$1" = "none required" || $3="$ac_cv_search_ext_$1 $$3" - $4], - [$5])dnl -]) - AC_PREREQ(2.50) AC_INIT(dlfcn.c) AC_CONFIG_SRCDIR([dlfcn.c]) -- cgit From b70a7de8028a0c1c56dd2d7c4404aa0af6c89747 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 11:22:11 +0000 Subject: r18074: config.m4 is now libreplace.m4 (This used to be commit b2e680500e07742d82735bcc05ba2030a5deb603) --- source4/lib/replace/config.m4 | 220 -------------------------------------- source4/lib/replace/configure.ac | 2 +- source4/lib/replace/libreplace.m4 | 220 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 221 insertions(+), 221 deletions(-) delete mode 100644 source4/lib/replace/config.m4 create mode 100644 source4/lib/replace/libreplace.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4 deleted file mode 100644 index 382da639fc..0000000000 --- a/source4/lib/replace/config.m4 +++ /dev/null @@ -1,220 +0,0 @@ -dnl find the libreplace sources. This is meant to work both for -dnl libreplace standalone builds, and builds of packages using libreplace -libreplacedir="" -for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace"; do - if test -f "$d/replace.c"; then - libreplacedir="$d" - AC_SUBST(libreplacedir) - break; - fi -done -LIBREPLACEOBJ="dlfcn.o getpass.o replace.o snprintf.o timegm.o" -AC_SUBST(LIBREPLACEOBJ) - -AC_CHECK_HEADERS([stdint.h inttypes.h]) -AC_CHECK_TYPE(uint_t, unsigned int) -AC_CHECK_TYPE(uint8_t, unsigned char) -AC_CHECK_TYPE(int8_t, char) -AC_CHECK_TYPE(int16_t, short) -AC_CHECK_TYPE(uint16_t, unsigned short) -AC_CHECK_TYPE(int32_t, long) -AC_CHECK_TYPE(intptr_t, unsigned long long) -AC_CHECK_TYPE(uint32_t, unsigned long) -AC_CHECK_TYPE(ssize_t, int) - -AC_CHECK_HEADERS(stdbool.h) - -AC_CHECK_TYPE(bool, -[AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],, -[ -AC_INCLUDES_DEFAULT -#ifdef HAVE_STDBOOL_H -#include -#endif] -) - - -AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ -AC_TRY_RUN([ -#include -#include -#include -#ifdef HAVE_ARPA_INET_H -#include -#endif -main() { struct in_addr ip; ip.s_addr = 0x12345678; -if (strcmp(inet_ntoa(ip),"18.52.86.120") && - strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } -exit(1);}], - samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)]) -if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then - AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) -fi - -dnl Provided by replace.c: -AC_TRY_COMPILE([ -#include -#if STDC_HEADERS -#include -#include -#endif -#include ], -[socklen_t foo;],, -[AC_DEFINE(socklen_t, int,[Socket length type])]) - -AC_CHECK_HEADERS(sys/syslog.h syslog.h) -AC_CHECK_HEADERS(sys/time.h time.h) -AC_CHECK_HEADERS(sys/socket.h netinet/in.h) -AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) -AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) -AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) -AC_CHECK_DECLS([setresuid, setresgid, errno]) - -AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[ -AC_TRY_RUN([#include -#include -#include -#include -main() { - struct stat st; - char tpl[20]="/tmp/test.XXXXXX"; - int fd = mkstemp(tpl); - if (fd == -1) exit(1); - unlink(tpl); - if (fstat(fd, &st) != 0) exit(1); - if ((st.st_mode & 0777) != 0600) exit(1); - exit(0); -}], -samba_cv_HAVE_SECURE_MKSTEMP=yes, -samba_cv_HAVE_SECURE_MKSTEMP=no, -samba_cv_HAVE_SECURE_MKSTEMP=cross)]) -if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then - AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure]) -fi - -dnl Provided by snprintf.c: -AC_CHECK_DECLS([asprintf, vasprintf, snprintf]) -AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf) -AC_CHECK_HEADERS(strings.h) - -AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[ -AC_TRY_RUN([ -#include -#include -#include -#include -void foo(const char *format, ...) { - va_list ap; - int len; - char buf[20]; - long long l = 1234567890; - l *= 100; - - va_start(ap, format); - len = vsnprintf(buf, 0, format, ap); - va_end(ap); - if (len != 5) exit(1); - - va_start(ap, format); - len = vsnprintf(0, 0, format, ap); - va_end(ap); - if (len != 5) exit(2); - - if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3); - - if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4); - if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5); - if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6); - if (snprintf(buf, 20, "%s", 0) < 3) exit(7); - - exit(0); -} -main() { foo("hello"); } -], -samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)]) -if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then - AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf]) -fi - -dnl dummies provided by dlfcn.c if not available -AC_SEARCH_LIBS(dlopen, dl) -AC_CHECK_HEADERS(dlfcn.h) -AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose) - -AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, - [AC_MSG_ERROR([Required function not found])]) - -sinclude(lib/replace/getpass.m4) -sinclude(getpass.m4) -sinclude(lib/replace/cc_features.m4) -sinclude(cc_features.m4) - -LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes, - c99_struct_initialization=no) - -dnl VA_COPY -AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[ -AC_TRY_LINK([#include -va_list ap1,ap2;], [va_copy(ap1,ap2);], -samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)]) -if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then - AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) -fi - -if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then -AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[ -AC_TRY_LINK([#include -va_list ap1,ap2;], [__va_copy(ap1,ap2);], -samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)]) -if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then - AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available]) -fi -fi - -dnl __FUNCTION__ macro -AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[ -AC_TRY_COMPILE([#include ], [printf("%s\n", __FUNCTION__);], -samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)]) -if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then - AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro]) -else - dnl __func__ macro - AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[ - AC_TRY_COMPILE([#include ], [printf("%s\n", __func__);], - samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)]) - if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then - AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro]) - fi -fi - -AC_CHECK_HEADERS([sys/param.h limits.h]) - -AC_CHECK_TYPE(comparison_fn_t, -[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) - -AC_CHECK_FUNCS(timegm strnlen setenv) -AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) - -# this test disabled as we don't actually need __VA_ARGS__ yet -# AC_TRY_CPP([ -# #define eprintf(...) fprintf(stderr, __VA_ARGS__) -# eprintf("bla", "bar"); -# ], [], [AC_MSG_ERROR([__VA_ARGS__ is required])]) - -# Check prerequisites -AC_CHECK_FUNCS([memset printf syslog], [], - [ AC_MSG_ERROR([Required function not found])]) - -AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ - AC_TRY_COMPILE([ -#include -#if STDC_HEADERS -#include -#include -#endif -#include ],[sig_atomic_t i = 0], - samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)]) -if test x"$samba_cv_sig_atomic_t" = x"yes"; then - AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type]) -fi diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index 2b5fbf1c18..b2317708b3 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -12,7 +12,7 @@ if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings" fi -sinclude(config.m4) +sinclude(libreplace.m4) sinclude(win32/config.m4) sinclude(repdir/config.m4) AC_OUTPUT(Makefile) diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 new file mode 100644 index 0000000000..382da639fc --- /dev/null +++ b/source4/lib/replace/libreplace.m4 @@ -0,0 +1,220 @@ +dnl find the libreplace sources. This is meant to work both for +dnl libreplace standalone builds, and builds of packages using libreplace +libreplacedir="" +for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace"; do + if test -f "$d/replace.c"; then + libreplacedir="$d" + AC_SUBST(libreplacedir) + break; + fi +done +LIBREPLACEOBJ="dlfcn.o getpass.o replace.o snprintf.o timegm.o" +AC_SUBST(LIBREPLACEOBJ) + +AC_CHECK_HEADERS([stdint.h inttypes.h]) +AC_CHECK_TYPE(uint_t, unsigned int) +AC_CHECK_TYPE(uint8_t, unsigned char) +AC_CHECK_TYPE(int8_t, char) +AC_CHECK_TYPE(int16_t, short) +AC_CHECK_TYPE(uint16_t, unsigned short) +AC_CHECK_TYPE(int32_t, long) +AC_CHECK_TYPE(intptr_t, unsigned long long) +AC_CHECK_TYPE(uint32_t, unsigned long) +AC_CHECK_TYPE(ssize_t, int) + +AC_CHECK_HEADERS(stdbool.h) + +AC_CHECK_TYPE(bool, +[AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],, +[ +AC_INCLUDES_DEFAULT +#ifdef HAVE_STDBOOL_H +#include +#endif] +) + + +AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ +AC_TRY_RUN([ +#include +#include +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +main() { struct in_addr ip; ip.s_addr = 0x12345678; +if (strcmp(inet_ntoa(ip),"18.52.86.120") && + strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } +exit(1);}], + samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)]) +if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then + AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) +fi + +dnl Provided by replace.c: +AC_TRY_COMPILE([ +#include +#if STDC_HEADERS +#include +#include +#endif +#include ], +[socklen_t foo;],, +[AC_DEFINE(socklen_t, int,[Socket length type])]) + +AC_CHECK_HEADERS(sys/syslog.h syslog.h) +AC_CHECK_HEADERS(sys/time.h time.h) +AC_CHECK_HEADERS(sys/socket.h netinet/in.h) +AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) +AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) +AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) +AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) +AC_CHECK_DECLS([setresuid, setresgid, errno]) + +AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[ +AC_TRY_RUN([#include +#include +#include +#include +main() { + struct stat st; + char tpl[20]="/tmp/test.XXXXXX"; + int fd = mkstemp(tpl); + if (fd == -1) exit(1); + unlink(tpl); + if (fstat(fd, &st) != 0) exit(1); + if ((st.st_mode & 0777) != 0600) exit(1); + exit(0); +}], +samba_cv_HAVE_SECURE_MKSTEMP=yes, +samba_cv_HAVE_SECURE_MKSTEMP=no, +samba_cv_HAVE_SECURE_MKSTEMP=cross)]) +if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then + AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure]) +fi + +dnl Provided by snprintf.c: +AC_CHECK_DECLS([asprintf, vasprintf, snprintf]) +AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf) +AC_CHECK_HEADERS(strings.h) + +AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[ +AC_TRY_RUN([ +#include +#include +#include +#include +void foo(const char *format, ...) { + va_list ap; + int len; + char buf[20]; + long long l = 1234567890; + l *= 100; + + va_start(ap, format); + len = vsnprintf(buf, 0, format, ap); + va_end(ap); + if (len != 5) exit(1); + + va_start(ap, format); + len = vsnprintf(0, 0, format, ap); + va_end(ap); + if (len != 5) exit(2); + + if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3); + + if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4); + if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5); + if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6); + if (snprintf(buf, 20, "%s", 0) < 3) exit(7); + + exit(0); +} +main() { foo("hello"); } +], +samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)]) +if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then + AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf]) +fi + +dnl dummies provided by dlfcn.c if not available +AC_SEARCH_LIBS(dlopen, dl) +AC_CHECK_HEADERS(dlfcn.h) +AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose) + +AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, + [AC_MSG_ERROR([Required function not found])]) + +sinclude(lib/replace/getpass.m4) +sinclude(getpass.m4) +sinclude(lib/replace/cc_features.m4) +sinclude(cc_features.m4) + +LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes, + c99_struct_initialization=no) + +dnl VA_COPY +AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[ +AC_TRY_LINK([#include +va_list ap1,ap2;], [va_copy(ap1,ap2);], +samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)]) +if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then + AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) +fi + +if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then +AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[ +AC_TRY_LINK([#include +va_list ap1,ap2;], [__va_copy(ap1,ap2);], +samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)]) +if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then + AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available]) +fi +fi + +dnl __FUNCTION__ macro +AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[ +AC_TRY_COMPILE([#include ], [printf("%s\n", __FUNCTION__);], +samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)]) +if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then + AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro]) +else + dnl __func__ macro + AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[ + AC_TRY_COMPILE([#include ], [printf("%s\n", __func__);], + samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)]) + if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then + AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro]) + fi +fi + +AC_CHECK_HEADERS([sys/param.h limits.h]) + +AC_CHECK_TYPE(comparison_fn_t, +[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) + +AC_CHECK_FUNCS(timegm strnlen setenv) +AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) + +# this test disabled as we don't actually need __VA_ARGS__ yet +# AC_TRY_CPP([ +# #define eprintf(...) fprintf(stderr, __VA_ARGS__) +# eprintf("bla", "bar"); +# ], [], [AC_MSG_ERROR([__VA_ARGS__ is required])]) + +# Check prerequisites +AC_CHECK_FUNCS([memset printf syslog], [], + [ AC_MSG_ERROR([Required function not found])]) + +AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ + AC_TRY_COMPILE([ +#include +#if STDC_HEADERS +#include +#include +#endif +#include ],[sig_atomic_t i = 0], + samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)]) +if test x"$samba_cv_sig_atomic_t" = x"yes"; then + AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type]) +fi -- cgit From b383add7b0ff4a4d89760b9488983e0256417c7c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 11:33:46 +0000 Subject: r18075: with the new scheme, we now use config.h again (thanks jelmer!) (This used to be commit c45c48786180fc97e2bb53edbdd5ebddfe85e291) --- source4/lib/replace/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index b2317708b3..b46dfdced0 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -4,7 +4,7 @@ AC_DEFUN([SMB_ENABLE], [echo -n ""]) AC_PREREQ(2.50) AC_INIT(dlfcn.c) AC_CONFIG_SRCDIR([dlfcn.c]) -AC_CONFIG_HEADER(replace_config.h) +AC_CONFIG_HEADER(config.h) AC_PROG_INSTALL AC_PROG_CC -- cgit From 6e5beba8668ea181e009baad27ea7619a4671922 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 11:42:20 +0000 Subject: r18078: these tests came from talloc (This used to be commit 1e5e311233c5253d107bf043dc78dfd21057bb35) --- source4/lib/replace/libreplace.m4 | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 382da639fc..6a841cfd3d 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -65,6 +65,7 @@ AC_TRY_COMPILE([ AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_HEADERS(sys/time.h time.h) AC_CHECK_HEADERS(sys/socket.h netinet/in.h) +AC_CHECK_HEADERS(stdarg.h vararg.h) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) @@ -218,3 +219,5 @@ AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ if test x"$samba_cv_sig_atomic_t" = x"yes"; then AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type]) fi + + -- cgit From 780b3396564007a9b943035651ccd4972b9005f8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 11:45:55 +0000 Subject: r18079: fix for in-tree build with samba4 dir layout (This used to be commit 8eccdc1cd1fcf59a3bb9683f31a8613f748a1bfc) --- source4/lib/replace/libreplace.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 6a841cfd3d..593666a567 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -1,7 +1,7 @@ dnl find the libreplace sources. This is meant to work both for dnl libreplace standalone builds, and builds of packages using libreplace libreplacedir="" -for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace"; do +for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace" "$srcdir/../replace"; do if test -f "$d/replace.c"; then libreplacedir="$d" AC_SUBST(libreplacedir) -- cgit From b5c0202bff42fe5792d0e58b0349527da5ae4ff9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 11:51:00 +0000 Subject: r18081: libreplace now uses config.h again (This used to be commit 037196538a9850be194c1577f59c0c6a03ea8b9a) --- source4/lib/replace/replace.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 1d07361a28..631488bbf8 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -28,12 +28,7 @@ #ifndef _replace_h #define _replace_h -#ifdef _SAMBA_BUILD_ #include "config.h" -#else -#include "replace_config.h" -#endif /* _SAMBA_BUILD_ */ - #include #include -- cgit From 81fdc61c114b66b8e58d5032d05029e5188a04eb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 12:08:35 +0000 Subject: r18084: we don't need the double sinclude() any more (This used to be commit 2dab7886c1c0abfd95374c8a796f0fde029de8b6) --- source4/lib/replace/libreplace.m4 | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 593666a567..18b9a1a6e6 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -146,9 +146,7 @@ AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose) AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) -sinclude(lib/replace/getpass.m4) sinclude(getpass.m4) -sinclude(lib/replace/cc_features.m4) sinclude(cc_features.m4) LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes, -- cgit From 0dd630cfa7dc55b4ba4146bbef801bccc15a4c74 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Sep 2006 12:13:15 +0000 Subject: r18085: using m4_include() instead of sinclude() means we get an error if the include fails - thats better than the compile failing mysteriously (This used to be commit b4df3c73913557297e0eb1ea89cb42a8e7920de8) --- source4/lib/replace/configure.ac | 6 +++--- source4/lib/replace/libreplace.m4 | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index b46dfdced0..bd500ae8d4 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -12,7 +12,7 @@ if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings" fi -sinclude(libreplace.m4) -sinclude(win32/config.m4) -sinclude(repdir/config.m4) +m4_include(libreplace.m4) +m4_include(win32/config.m4) +m4_include(repdir/config.m4) AC_OUTPUT(Makefile) diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 18b9a1a6e6..ce42367212 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -146,8 +146,8 @@ AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose) AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) -sinclude(getpass.m4) -sinclude(cc_features.m4) +m4_include(getpass.m4) +m4_include(cc_features.m4) LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes, c99_struct_initialization=no) -- cgit From 72c697167e6abd5a09f480ffd7735a306241a1f7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 5 Sep 2006 13:41:26 +0000 Subject: r18088: sometimes autoconf picks up some old stuff: - remove configure and config.h.in - cleanup after autoconf and autoheader are done metze (This used to be commit c4f91114a3cc741538b358e3e44dc8eb0d13188a) --- source4/lib/replace/autogen.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/autogen.sh b/source4/lib/replace/autogen.sh index 5b4c37cf96..d46a4279f3 100755 --- a/source4/lib/replace/autogen.sh +++ b/source4/lib/replace/autogen.sh @@ -1,10 +1,13 @@ #!/bin/sh rm -rf autom4te.cache +rm -f configure config.h.in autoheader || exit 1 autoconf || exit 1 +rm -rf autom4te.cache + echo "Now run ./configure and then make." exit 0 -- cgit From c2dfdbb64d19bd9520f194d472a4883c494b4c60 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 5 Sep 2006 14:26:14 +0000 Subject: r18093: check for the headers first and check all functions metze (This used to be commit 5bb8a5ce32a3e85355d8554974d226708df41970) --- source4/lib/replace/libreplace.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index ce42367212..abbd63db7a 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -95,9 +95,9 @@ if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then fi dnl Provided by snprintf.c: -AC_CHECK_DECLS([asprintf, vasprintf, snprintf]) +AC_CHECK_HEADERS(stdio.h strings.h) +AC_CHECK_DECLS([snprintf, vsnprintf, asprintf, vasprintf]) AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf) -AC_CHECK_HEADERS(strings.h) AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[ AC_TRY_RUN([ -- cgit From c91a27fd80a0c282b0668cb3a7a297173476b2cb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 5 Sep 2006 14:29:34 +0000 Subject: r18094: try to fix the samba4 build metze (This used to be commit 3c00983e2cda2ea55585c25926014e7374d613ce) --- source4/lib/replace/config.mk | 2 +- source4/lib/replace/samba.m4 | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 source4/lib/replace/samba.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 49a1e7fe1b..a05db5abad 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -14,6 +14,6 @@ OBJ_FILES = replace.o \ snprintf.o \ dlfcn.o \ getpass.o -PUBLIC_DEPENDENCIES = REPLACE_READDIR DL +PUBLIC_DEPENDENCIES = REPLACE_READDIR REPLACE_EXT # End SUBSYSTEM LIBREPLACE ############################## diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4 new file mode 100644 index 0000000000..6183b7e28f --- /dev/null +++ b/source4/lib/replace/samba.m4 @@ -0,0 +1,27 @@ +SAVE_LIBS="$LIBS" +SAVE_CFLAGS="$CFLAGS" +SAVE_CPPFLAGS="$CPPFLAGS" +SAVE_LDFLAGS="$LDFLAGS" + +LIBS="" +CFLAGS="" +CPPFLAGS="" +LDFLAGS="" + +m4_include(libreplace.m4) + +REPLACE_EXT_LIBS="$LIBS" +REPLACE_EXT_CFLAGS="$CFLAGS" +REPLACE_EXT_CPPFLAGS="$CPPFLAGS" +REPLACE_EXT_LDFLAGS="$LDFLAGS" + +LIBS="$SAVE_LIBS" +CFLAGS="$SAVE_CFLAGS" +CPPFLAGS="$SAVE_CPPFLAGS" +LDFLAGS="$SAVE_LDFLAGS" + +SMB_EXT_LIB(REPLACE_EXT, + [${REPLACE_EXT_LIBS}], + [${REPLACE_EXT_CFLAGS}], + [${REPLACE_EXT_CPPFLAGS}], + [${REPLACE_EXT_LDFLAGS}]) -- cgit From e906cb59664d1c71b681f525f67617865152c46b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 00:06:00 +0000 Subject: r18111: base inclusion of replacement printf fns on function existance, not declaration. Otherwise _GNU_SOURCE and _BSD_SOURCE stuffs things up (possibly fixable, but not now) (This used to be commit 68caf1bba73fe68f452c7db2ac3895a451645dec) --- source4/lib/replace/replace.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 631488bbf8..566be225be 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -139,11 +139,6 @@ unsigned long long int rep_strtoull(const char *str, char **endptr, int base); int rep_ftruncate(int f,long l); #endif -#ifndef HAVE_VASPRINTF_DECL -#define vasprintf rep_vasprintf -int rep_vasprintf(char **ptr, const char *format, va_list ap); -#endif - #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET) #define bzero(a,b) memset((a),'\0',(b)) #endif @@ -161,12 +156,22 @@ int rep_vasprintf(char **ptr, const char *format, va_list ap); #endif #endif -/* add varargs prototypes with printf checking */ -#ifndef HAVE_SNPRINTF_DECL +#ifndef HAVE_VASPRINTF +#define vasprintf rep_vasprintf +int rep_vasprintf(char **ptr, const char *format, va_list ap); +#endif + +#ifndef HAVE_SNPRINTF #define snprintf rep_snprintf int rep_snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4); #endif -#ifndef HAVE_ASPRINTF_DECL + +#ifndef HAVE_VSNPRINTF +#define vsnprintf rep_vsnprintf +int rep_vsnprintf(char *,size_t ,const char *, va_list ap); +#endif + +#ifndef HAVE_ASPRINTF #define asprintf rep_asprintf int rep_asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); #endif -- cgit From a59706f721c70e9a4f78eb2296bb746b912ce9d0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 01:36:02 +0000 Subject: r18121: Simplify m4 code, hopefully fix Samba4 build problems. (This used to be commit 1adf65b4d7c5d2d4f65d4b28575bdf2368a42139) --- source4/lib/replace/config.mk | 2 +- source4/lib/replace/libreplace.m4 | 5 +++++ source4/lib/replace/samba.m4 | 27 --------------------------- 3 files changed, 6 insertions(+), 28 deletions(-) delete mode 100644 source4/lib/replace/samba.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index a05db5abad..2482c69636 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -14,6 +14,6 @@ OBJ_FILES = replace.o \ snprintf.o \ dlfcn.o \ getpass.o -PUBLIC_DEPENDENCIES = REPLACE_READDIR REPLACE_EXT +PUBLIC_DEPENDENCIES = REPLACE_READDIR # End SUBSYSTEM LIBREPLACE ############################## diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index abbd63db7a..7136a18029 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -139,7 +139,12 @@ if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then fi dnl dummies provided by dlfcn.c if not available +save_LIBS="$LIBS" +LIBS="" AC_SEARCH_LIBS(dlopen, dl) +LIBDL="$LIBS" +AC_SUBST(LIBDL) +LIBS="$save_LIBS" AC_CHECK_HEADERS(dlfcn.h) AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose) diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4 deleted file mode 100644 index 6183b7e28f..0000000000 --- a/source4/lib/replace/samba.m4 +++ /dev/null @@ -1,27 +0,0 @@ -SAVE_LIBS="$LIBS" -SAVE_CFLAGS="$CFLAGS" -SAVE_CPPFLAGS="$CPPFLAGS" -SAVE_LDFLAGS="$LDFLAGS" - -LIBS="" -CFLAGS="" -CPPFLAGS="" -LDFLAGS="" - -m4_include(libreplace.m4) - -REPLACE_EXT_LIBS="$LIBS" -REPLACE_EXT_CFLAGS="$CFLAGS" -REPLACE_EXT_CPPFLAGS="$CPPFLAGS" -REPLACE_EXT_LDFLAGS="$LDFLAGS" - -LIBS="$SAVE_LIBS" -CFLAGS="$SAVE_CFLAGS" -CPPFLAGS="$SAVE_CPPFLAGS" -LDFLAGS="$SAVE_LDFLAGS" - -SMB_EXT_LIB(REPLACE_EXT, - [${REPLACE_EXT_LIBS}], - [${REPLACE_EXT_CFLAGS}], - [${REPLACE_EXT_CPPFLAGS}], - [${REPLACE_EXT_LDFLAGS}]) -- cgit From 7619eff87d872fa29eecad2afc1d858ec2cd38bb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 01:41:41 +0000 Subject: r18122: Fix warnings related to errno declaration. (This used to be commit c30abc8e491d482c1771e7ac06cb511bae578467) --- source4/lib/replace/libreplace.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 7136a18029..ffea11f734 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -70,7 +70,9 @@ AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) -AC_CHECK_DECLS([setresuid, setresgid, errno]) +AC_HAVE_DECL(setresuid, [#include ]) +AC_HAVE_DECL(setresgid, [#include ]) +AC_HAVE_DECL(errno, [#include ]) AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[ AC_TRY_RUN([#include -- cgit From 7e251d1f1182c0c3317bbf3d3ab073eadc7f4583 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 01:50:09 +0000 Subject: r18124: Keep right libs when looking for dl*() functions (This used to be commit 12ce4cef2fcdb4224fdf15c9ecf952ceb797f02c) --- source4/lib/replace/libreplace.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index ffea11f734..c396f11dfd 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -144,11 +144,11 @@ dnl dummies provided by dlfcn.c if not available save_LIBS="$LIBS" LIBS="" AC_SEARCH_LIBS(dlopen, dl) +AC_CHECK_HEADERS(dlfcn.h) +AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose) LIBDL="$LIBS" AC_SUBST(LIBDL) LIBS="$save_LIBS" -AC_CHECK_HEADERS(dlfcn.h) -AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose) AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) -- cgit From 4f643be1cbde0ea020458535fecff68cd6906561 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 02:00:17 +0000 Subject: r18125: Remove obsolete file. (This used to be commit 27aa34eb55afdbc27f36cebae074d6fef5fc822c) --- source4/lib/replace/replace.m4 | 58 ------------------------------------------ 1 file changed, 58 deletions(-) delete mode 100644 source4/lib/replace/replace.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.m4 b/source4/lib/replace/replace.m4 deleted file mode 100644 index 829f4db6f6..0000000000 --- a/source4/lib/replace/replace.m4 +++ /dev/null @@ -1,58 +0,0 @@ -dnl Try to find a replacement library -dnl Will define HAVE_REPLACE_H if replace.h can be found -AC_DEFUN([SMB_LIBREPLACE], [ -AC_ARG_WITH(libreplace, -[ --with-libreplace Specify location to libreplace], -[ - # Check whether libreplace can actually be found in this location - if ! test -f "$withval/replace.h" - then - AC_MSG_ERROR([Unable to find replace.h in $withval]) - fi - replacedir=$withval -], -[ - # Check if we can find libreplace in a common location - for dir in . replace ../replace - do - AC_MSG_CHECKING([for libreplace in $dir]) - if test -f "$dir/replace.h" - then - replacedir="$dir" - AC_MSG_RESULT(yes) - break - fi - AC_MSG_RESULT(no) - done -]) - -AC_SUBST(REPLACE_LIBS) - -if test "$replacedir" != "" -then - REPLACE_LIBS="$replacedir/libreplace.a" - CFLAGS="$CFLAGS -I$replacedir" - AC_DEFINE(HAVE_REPLACE_H, 1, - [Whether replace.h is present and should be used]) -fi -]) - -dnl Try to find the specified functions in the system, or -dnl in Samba's replacement library. In the future, this may also -dnl try to find these functions in libroken or GNUlib if libreplace can't be -dnl found. -AC_DEFUN(SMB_REPLACE_FUNCS, [ - AC_REQUIRE([SMB_LIBREPLACE])dnl - - if test -z "$replacedir" || test -f "$replacedir/libreplace.a" - then - LIBS="$LIBS $REPLACE_LIBS" - for f in $1 - do - AC_CHECK_FUNC($f, [], [ - AC_MSG_ERROR([Unable to find $f in the system. Consider - specifying the path to the replacement library]) - ]) - done - fi -]) -- cgit From 3e11f4c06131542565149496d659f0050411a68f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 02:07:44 +0000 Subject: r18127: Add macro AC_CHECK_DECL() for systems that don't have it. (This used to be commit 589a1c250934a61db0f86c1e98962e195e681c79) --- source4/lib/replace/libreplace.m4 | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index c396f11dfd..ce36ee39b4 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -1,3 +1,16 @@ +dnl see if a declaration exists for a function or variable +dnl defines HAVE_function_DECL if it exists +dnl AC_HAVE_DECL(var, includes) +AC_DEFUN(AC_HAVE_DECL, +[ + AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[ + AC_TRY_COMPILE([$2],[int i = (int)$1], + ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)]) + if test x"$ac_cv_have_$1_decl" = x"yes"; then + AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available]) + fi +]) + dnl find the libreplace sources. This is meant to work both for dnl libreplace standalone builds, and builds of packages using libreplace libreplacedir="" -- cgit From a983b06d37c3b87a02444d9a9862777b88629344 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 04:44:32 +0000 Subject: r18129: moved the system includes into libreplace - this gives much more isolation of our portability environment from the main code, and also simplifies the includes system (no separate #ifdef _SAMBA_BUILD for tdb. ldb etc now) (This used to be commit 77d1a468e06290aba789e2f3affc769fc5159a21) --- source4/lib/replace/libreplace.m4 | 1 + source4/lib/replace/replace.c | 18 +--- source4/lib/replace/replace.h | 16 ++- source4/lib/replace/system/README | 4 + source4/lib/replace/system/capability.h | 41 ++++++++ source4/lib/replace/system/config.m4 | 31 ++++++ source4/lib/replace/system/dir.h | 64 ++++++++++++ source4/lib/replace/system/filesys.h | 170 ++++++++++++++++++++++++++++++++ source4/lib/replace/system/glob.h | 33 +++++++ source4/lib/replace/system/iconv.h | 40 ++++++++ source4/lib/replace/system/kerberos.h | 133 +++++++++++++++++++++++++ source4/lib/replace/system/locale.h | 34 +++++++ source4/lib/replace/system/network.h | 103 +++++++++++++++++++ source4/lib/replace/system/passwd.h | 96 ++++++++++++++++++ source4/lib/replace/system/printing.h | 46 +++++++++ source4/lib/replace/system/readline.h | 48 +++++++++ source4/lib/replace/system/select.h | 42 ++++++++ source4/lib/replace/system/shmem.h | 51 ++++++++++ source4/lib/replace/system/syslog.h | 66 +++++++++++++ source4/lib/replace/system/terminal.h | 42 ++++++++ source4/lib/replace/system/time.h | 40 ++++++++ source4/lib/replace/system/wait.h | 37 +++++++ source4/lib/replace/test/testsuite.c | 45 ++++----- 23 files changed, 1160 insertions(+), 41 deletions(-) create mode 100644 source4/lib/replace/system/README create mode 100644 source4/lib/replace/system/capability.h create mode 100644 source4/lib/replace/system/config.m4 create mode 100644 source4/lib/replace/system/dir.h create mode 100644 source4/lib/replace/system/filesys.h create mode 100644 source4/lib/replace/system/glob.h create mode 100644 source4/lib/replace/system/iconv.h create mode 100644 source4/lib/replace/system/kerberos.h create mode 100644 source4/lib/replace/system/locale.h create mode 100644 source4/lib/replace/system/network.h create mode 100644 source4/lib/replace/system/passwd.h create mode 100644 source4/lib/replace/system/printing.h create mode 100644 source4/lib/replace/system/readline.h create mode 100644 source4/lib/replace/system/select.h create mode 100644 source4/lib/replace/system/shmem.h create mode 100644 source4/lib/replace/system/syslog.h create mode 100644 source4/lib/replace/system/terminal.h create mode 100644 source4/lib/replace/system/time.h create mode 100644 source4/lib/replace/system/wait.h (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index ce36ee39b4..1465756261 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -168,6 +168,7 @@ AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, m4_include(getpass.m4) m4_include(cc_features.m4) +m4_include(system/config.m4) LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes, c99_struct_initialization=no) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b9c106d582..733cb758bd 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -24,20 +24,10 @@ #include "replace.h" -#include -#include -#include -#include -#include -#include - -#if HAVE_SYS_SOCKET_H -#include -#endif - -#if HAVE_NETINET_IN_H -#include -#endif +#include "system/filesys.h" +#include "system/time.h" +#include "system/passwd.h" +#include "system/syslog.h" void replace_dummy(void); void replace_dummy(void) {} diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 566be225be..38b4e08704 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -29,8 +29,11 @@ #define _replace_h #include "config.h" + +#include #include #include +#include #if defined(_MSC_VER) || defined(__MINGW32__) #include "lib/replace/win32/replace.h" @@ -50,6 +53,15 @@ #include #endif +#ifdef HAVE_STRING_H +#include +#endif + +#ifdef HAVE_STRINGS_H +#include +#endif + + #ifndef HAVE_STRERROR extern char *sys_errlist[]; #define strerror(i) sys_errlist[i] @@ -70,7 +82,7 @@ void *rep_memmove(void *dest,const void *src,int size); #endif #if !defined(HAVE_MKTIME) || !defined(HAVE_TIMEGM) -#include +#include "system/time.h" #endif #ifndef HAVE_MKTIME @@ -286,6 +298,4 @@ typedef int bool; #define __STRING(x) #x #endif - - #endif diff --git a/source4/lib/replace/system/README b/source4/lib/replace/system/README new file mode 100644 index 0000000000..69a2b80b56 --- /dev/null +++ b/source4/lib/replace/system/README @@ -0,0 +1,4 @@ +This directory contains wrappers around logical groups of system +include files. The idea is to avoid #ifdef blocks in the main code, +and instead put all the necessary conditional includes in subsystem +specific header files in this directory. diff --git a/source4/lib/replace/system/capability.h b/source4/lib/replace/system/capability.h new file mode 100644 index 0000000000..6ed8ae8de0 --- /dev/null +++ b/source4/lib/replace/system/capability.h @@ -0,0 +1,41 @@ +#ifndef _system_capability_h +#define _system_capability_h +/* + Unix SMB/CIFS implementation. + + capability system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_SYS_CAPABILITY_H + +#if defined(BROKEN_REDHAT_7_SYSTEM_HEADERS) && !defined(_I386_STATFS_H) +#define _I386_STATFS_H +#define BROKEN_REDHAT_7_STATFS_WORKAROUND +#endif + +#include + +#ifdef BROKEN_REDHAT_7_STATFS_WORKAROUND +#undef _I386_STATFS_H +#undef BROKEN_REDHAT_7_STATFS_WORKAROUND +#endif + +#endif + +#endif diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 new file mode 100644 index 0000000000..4d66317a5e --- /dev/null +++ b/source4/lib/replace/system/config.m4 @@ -0,0 +1,31 @@ +# filesys +AC_HEADER_DIRENT +AC_CHECK_HEADERS(fcntl.h sys/fcntl.h sys/acl.h sys/resource.h sys/ioctl.h sys/mode.h sys/filio.h sys/fs/s5param.h sys/filsys.h ) + +# select +AC_CHECK_HEADERS(sys/select.h) + +# time +AC_CHECK_HEADERS(sys/time.h utime.h) +AC_HEADER_TIME + +# wait +AC_HEADER_SYS_WAIT + +# capability +AC_CHECK_HEADERS(sys/capability.h) + +# passwd +AC_CHECK_HEADERS(grp.h sys/id.h compat.h shadow.h sys/priv.h pwd.h sys/security.h) + +# locale +AC_CHECK_HEADERS(ctype.h locale.h) + +# glob +AC_CHECK_HEADERS(fnmatch.h) + +# shmem +AC_CHECK_HEADERS(sys/ipc.h sys/mman.h sys/shm.h ) + +# terminal +AC_CHECK_HEADERS(termios.h termio.h sys/termio.h ) diff --git a/source4/lib/replace/system/dir.h b/source4/lib/replace/system/dir.h new file mode 100644 index 0000000000..64e413c907 --- /dev/null +++ b/source4/lib/replace/system/dir.h @@ -0,0 +1,64 @@ +#ifndef _system_dir_h +#define _system_dir_h +/* + Unix SMB/CIFS implementation. + + directory system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#if HAVE_DIRENT_H +# include +# define NAMLEN(dirent) strlen((dirent)->d_name) +#else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# if HAVE_SYS_NDIR_H +# include +# endif +# if HAVE_SYS_DIR_H +# include +# endif +# if HAVE_NDIR_H +# include +# endif +#endif + +#ifndef HAVE_MKDIR_MODE +#define mkdir(dir, mode) mkdir(dir) +#endif + +/* Test whether a file name is the "." or ".." directory entries. + * These really should be inline functions. + */ +#ifndef ISDOT +#define ISDOT(path) ( \ + *((const char *)(path)) == '.' && \ + *(((const char *)(path)) + 1) == '\0' \ + ) +#endif + +#ifndef ISDOTDOT +#define ISDOTDOT(path) ( \ + *((const char *)(path)) == '.' && \ + *(((const char *)(path)) + 1) == '.' && \ + *(((const char *)(path)) + 2) == '\0' \ + ) +#endif + +#endif diff --git a/source4/lib/replace/system/filesys.h b/source4/lib/replace/system/filesys.h new file mode 100644 index 0000000000..1e48f7ab40 --- /dev/null +++ b/source4/lib/replace/system/filesys.h @@ -0,0 +1,170 @@ +#ifndef _system_filesys_h +#define _system_filesys_h +/* + Unix SMB/CIFS implementation. + + filesystem system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include +#include + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#ifdef HAVE_SYS_MOUNT_H +#include +#endif + +#ifdef HAVE_SYS_VFS_H +#include +#endif + +#ifdef HAVE_SYS_ACL_H +#include +#endif + +#ifdef HAVE_SYS_FS_S5PARAM_H +#include +#endif + +#if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY) +#include +#endif + +#ifdef HAVE_SYS_STATFS_H +# include +#endif + +#ifdef HAVE_DUSTAT_H +#include +#endif + +#ifdef HAVE_SYS_STATVFS_H +#include +#endif + +#ifdef HAVE_SYS_FILIO_H +#include +#endif + +#include + +#ifdef HAVE_FCNTL_H +#include +#else +#ifdef HAVE_SYS_FCNTL_H +#include +#endif +#endif + +#ifdef HAVE_SYS_MODE_H +/* apparently AIX needs this for S_ISLNK */ +#ifndef S_ISLNK +#include +#endif +#endif + +#ifdef HAVE_SYS_IOCTL_H +#include +#endif + +/* + * Veritas File System. Often in addition to native. + * Quotas different. + */ +#if defined(HAVE_SYS_FS_VX_QUOTA_H) +#define VXFS_QUOTA +#endif + +#if HAVE_SYS_ATTRIBUTES_H +#include +#endif + +/* mutually exclusive (SuSE 8.2) */ +#if HAVE_ATTR_XATTR_H +#include +#elif HAVE_SYS_XATTR_H +#include +#endif + + +#ifdef HAVE_SYS_RESOURCE_H +#include +#endif + +/* Some POSIX definitions for those without */ + +#ifndef S_IFDIR +#define S_IFDIR 0x4000 +#endif +#ifndef S_ISDIR +#define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR) +#endif +#ifndef S_IRWXU +#define S_IRWXU 00700 /* read, write, execute: owner */ +#endif +#ifndef S_IRUSR +#define S_IRUSR 00400 /* read permission: owner */ +#endif +#ifndef S_IWUSR +#define S_IWUSR 00200 /* write permission: owner */ +#endif +#ifndef S_IXUSR +#define S_IXUSR 00100 /* execute permission: owner */ +#endif +#ifndef S_IRWXG +#define S_IRWXG 00070 /* read, write, execute: group */ +#endif +#ifndef S_IRGRP +#define S_IRGRP 00040 /* read permission: group */ +#endif +#ifndef S_IWGRP +#define S_IWGRP 00020 /* write permission: group */ +#endif +#ifndef S_IXGRP +#define S_IXGRP 00010 /* execute permission: group */ +#endif +#ifndef S_IRWXO +#define S_IRWXO 00007 /* read, write, execute: other */ +#endif +#ifndef S_IROTH +#define S_IROTH 00004 /* read permission: other */ +#endif +#ifndef S_IWOTH +#define S_IWOTH 00002 /* write permission: other */ +#endif +#ifndef S_IXOTH +#define S_IXOTH 00001 /* execute permission: other */ +#endif + +#ifndef O_ACCMODE +#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) +#endif + +#ifndef MAXPATHLEN +#define MAXPATHLEN 256 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +#endif diff --git a/source4/lib/replace/system/glob.h b/source4/lib/replace/system/glob.h new file mode 100644 index 0000000000..0e51f397c6 --- /dev/null +++ b/source4/lib/replace/system/glob.h @@ -0,0 +1,33 @@ +#ifndef _system_glob_h +#define _system_glob_h +/* + Unix SMB/CIFS implementation. + + glob system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_GLOB_H +#include +#endif + +#ifdef HAVE_FNMATCH_H +#include +#endif + +#endif diff --git a/source4/lib/replace/system/iconv.h b/source4/lib/replace/system/iconv.h new file mode 100644 index 0000000000..75ee1d83ba --- /dev/null +++ b/source4/lib/replace/system/iconv.h @@ -0,0 +1,40 @@ +#ifndef _system_iconv_h +#define _system_iconv_h +/* + Unix SMB/CIFS implementation. + + iconv memory system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_NATIVE_ICONV +#ifdef HAVE_ICONV_H +#include +#endif +#ifdef HAVE_GICONV_H +#include +#endif +#endif + +/* needed for some systems without iconv. Doesn't really matter + what error code we use */ +#ifndef EILSEQ +#define EILSEQ EIO +#endif + +#endif diff --git a/source4/lib/replace/system/kerberos.h b/source4/lib/replace/system/kerberos.h new file mode 100644 index 0000000000..b24196fc25 --- /dev/null +++ b/source4/lib/replace/system/kerberos.h @@ -0,0 +1,133 @@ +#ifndef _system_kerberos_h +#define _system_kerberos_h + +/* + Unix SMB/CIFS implementation. + + kerberos system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_KRB5 +/* Whether the krb5_address struct has a addrtype property */ +/* #undef HAVE_ADDRTYPE_IN_KRB5_ADDRESS */ +/* Whether the krb5_address struct has a addr_type property */ +#define HAVE_ADDR_TYPE_IN_KRB5_ADDRESS 1 +/* Define to 1 if you have the `gsskrb5_extract_authz_data_from_sec_context' */ +#define HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT 1 +/* Define to 1 if you have the `gsskrb5_get_initiator_subkey' function. */ +#define HAVE_GSSKRB5_GET_INITIATOR_SUBKEY 1 +/* Define to 1 if you have the `gsskrb5_register_acceptor_identity' function. */ +#define HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY 1 +/* Define to 1 if you have the `gss_krb5_ccache_name' function. */ +#define HAVE_GSS_KRB5_CCACHE_NAME 1 +/* Define to 1 if you have the `krb5_addlog_func' function. */ +#define HAVE_KRB5_ADDLOG_FUNC 1 +/* Define to 1 if you have the `krb5_auth_con_setkey' function. */ +#define HAVE_KRB5_AUTH_CON_SETKEY 1 +/* Define to 1 if you have the `krb5_auth_con_setuseruserkey' function. */ +/* #undef HAVE_KRB5_AUTH_CON_SETUSERUSERKEY */ +/* Define to 1 if you have the `krb5_c_enctype_compare' function. */ +#define HAVE_KRB5_C_ENCTYPE_COMPARE 1 +/* Define to 1 if you have the `krb5_c_verify_checksum' function. */ +#define HAVE_KRB5_C_VERIFY_CHECKSUM 1 +/* Whether the type krb5_encrypt_block exists */ +/* #undef HAVE_KRB5_ENCRYPT_BLOCK */ +/* Define to 1 if you have the `krb5_encrypt_data' function. */ +/* #undef HAVE_KRB5_ENCRYPT_DATA */ +/* Define to 1 if you have the `krb5_enctypes_compatible_keys' function. */ +#define HAVE_KRB5_ENCTYPES_COMPATIBLE_KEYS 1 +/* Define to 1 if you have the `krb5_free_data_contents' function. */ +#define HAVE_KRB5_FREE_DATA_CONTENTS 1 +/* Define to 1 if you have the `krb5_free_error_string' function. */ +#define HAVE_KRB5_FREE_ERROR_STRING 1 +/* Define to 1 if you have the `krb5_free_keytab_entry_contents' function. */ +/* #undef HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS */ +/* Define to 1 if you have the `krb5_free_ktypes' function. */ +/* #undef HAVE_KRB5_FREE_KTYPES */ +/* Define to 1 if you have the `krb5_free_unparsed_name' function. */ +/* #undef HAVE_KRB5_FREE_UNPARSED_NAME */ +/* Define to 1 if you have the `krb5_get_default_in_tkt_etypes' function. */ +#define HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES 1 +/* Define to 1 if you have the `krb5_get_error_string' function. */ +#define HAVE_KRB5_GET_ERROR_STRING 1 +/* Define to 1 if you have the `krb5_get_permitted_enctypes' function. */ +/* #undef HAVE_KRB5_GET_PERMITTED_ENCTYPES */ +/* Define to 1 if you have the `krb5_get_pw_salt' function. */ +#define HAVE_KRB5_GET_PW_SALT 1 +/* Define to 1 if you have the header file. */ +#define HAVE_KRB5_H 1 +/* Define to 1 if you have the `krb5_initlog' function. */ +#define HAVE_KRB5_INITLOG 1 +/* Define to 1 if you have the `krb5_kdc_default_config' function. */ +#define HAVE_KRB5_KDC_DEFAULT_CONFIG 1 +/* Whether the krb5_creds struct has a keyblock property */ +/* #undef HAVE_KRB5_KEYBLOCK_IN_CREDS */ +/* Whether the krb5_keyblock struct has a keyvalue property */ +#define HAVE_KRB5_KEYBLOCK_KEYVALUE 1 +/* Whether krb5_keytab_entry has key member */ +/* #undef HAVE_KRB5_KEYTAB_ENTRY_KEY */ +/* Whether krb5_keytab_entry has keyblock member */ +#define HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK 1 +/* Define to 1 if you have the `krb5_krbhst_get_addrinfo' function. */ +#define HAVE_KRB5_KRBHST_GET_ADDRINFO 1 +/* Define to 1 if you have the `krb5_kt_compare' function. */ +#define HAVE_KRB5_KT_COMPARE 1 +/* Define to 1 if you have the `krb5_kt_free_entry' function. */ +#define HAVE_KRB5_KT_FREE_ENTRY 1 +/* Whether the type krb5_log_facility exists */ +#define HAVE_KRB5_LOG_FACILITY 1 +/* Define to 1 if you have the `krb5_mk_req_extended' function. */ +#define HAVE_KRB5_MK_REQ_EXTENDED 1 +/* Define to 1 if you have the `krb5_principal2salt' function. */ +/* #undef HAVE_KRB5_PRINCIPAL2SALT */ +/* Define to 1 if you have the `krb5_principal_get_comp_string' function. */ +#define HAVE_KRB5_PRINCIPAL_GET_COMP_STRING 1 +/* Whether krb5_princ_component is available */ +/* #undef HAVE_KRB5_PRINC_COMPONENT */ +/* Whether the krb5_creds struct has a session property */ +#define HAVE_KRB5_SESSION_IN_CREDS 1 +/* Define to 1 if you have the `krb5_set_default_in_tkt_etypes' function. */ +#define HAVE_KRB5_SET_DEFAULT_IN_TKT_ETYPES 1 +/* Define to 1 if you have the `krb5_set_default_tgs_ktypes' function. */ +/* #undef HAVE_KRB5_SET_DEFAULT_TGS_KTYPES */ +/* Define to 1 if you have the `krb5_set_real_time' function. */ +#define HAVE_KRB5_SET_REAL_TIME 1 +/* Define to 1 if you have the `krb5_set_warn_dest' function. */ +#define HAVE_KRB5_SET_WARN_DEST 1 +/* Define to 1 if you have the `krb5_string_to_key' function. */ +#define HAVE_KRB5_STRING_TO_KEY 1 +/* Define to 1 if you have the `krb5_string_to_key_salt' function. */ +#define HAVE_KRB5_STRING_TO_KEY_SALT 1 +/* Define to 1 if you have the `krb5_ticket_get_authorization_data_type' */ +#define HAVE_KRB5_TICKET_GET_AUTHORIZATION_DATA_TYPE 1 +/* Whether the krb5_ticket struct has a enc_part2 property */ +/* #undef HAVE_KRB5_TKT_ENC_PART2 */ +/* Define to 1 if you have the `krb5_use_enctype' function. */ +/* #undef HAVE_KRB5_USE_ENCTYPE */ +/* Define to 1 if you have the `krb5_verify_checksum' function. */ +#define HAVE_KRB5_VERIFY_CHECKSUM 1 +/* Whether krb5_princ_realm returns krb5_realm or krb5_data */ +#define KRB5_PRINC_REALM_RETURNS_REALM 1 + +#include "heimdal/lib/krb5/krb5.h" +#include "heimdal/lib/gssapi/gssapi.h" +#include "heimdal/lib/com_err/com_err.h" +#endif + +#endif diff --git a/source4/lib/replace/system/locale.h b/source4/lib/replace/system/locale.h new file mode 100644 index 0000000000..82b179dc5b --- /dev/null +++ b/source4/lib/replace/system/locale.h @@ -0,0 +1,34 @@ +#ifndef _system_locale_h +#define _system_locale_h + +/* + Unix SMB/CIFS implementation. + + locale include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_CTYPE_H +#include +#endif + +#ifdef HAVE_LOCALE_H +#include +#endif + +#endif diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h new file mode 100644 index 0000000000..9b73466924 --- /dev/null +++ b/source4/lib/replace/system/network.h @@ -0,0 +1,103 @@ +#ifndef _system_network_h +#define _system_network_h +/* + Unix SMB/CIFS implementation. + + networking system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +#ifdef HAVE_UNIXSOCKET +#include +#endif + +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#ifdef HAVE_NETDB_H +#include +#endif + +#ifdef HAVE_NETINET_TCP_H +#include +#endif + +/* + * The next three defines are needed to access the IPTOS_* options + * on some systems. + */ + +#ifdef HAVE_NETINET_IN_SYSTM_H +#include +#endif + +#ifdef HAVE_NETINET_IN_IP_H +#include +#endif + +#ifdef HAVE_NETINET_IP_H +#include +#endif + +#ifdef HAVE_NET_IF_H +#include +#endif + +#ifdef SOCKET_WRAPPER +#define SOCKET_WRAPPER_REPLACE +#include "lib/socket_wrapper/socket_wrapper.h" +#endif + +#ifdef REPLACE_INET_NTOA +char *rep_inet_ntoa(struct in_addr ip); +#define inet_ntoa rep_inet_ntoa +#endif + +/* + * glibc on linux doesn't seem to have MSG_WAITALL + * defined. I think the kernel has it though.. + */ +#ifndef MSG_WAITALL +#define MSG_WAITALL 0 +#endif + +/* + * Some older systems seem not to have MAXHOSTNAMELEN + * defined. + */ +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 254 +#endif + +#ifndef INADDR_LOOPBACK +#define INADDR_LOOPBACK 0x7f000001 +#endif + +#ifndef INADDR_NONE +#define INADDR_NONE 0xffffffff +#endif + +#endif diff --git a/source4/lib/replace/system/passwd.h b/source4/lib/replace/system/passwd.h new file mode 100644 index 0000000000..6f8d729a7c --- /dev/null +++ b/source4/lib/replace/system/passwd.h @@ -0,0 +1,96 @@ +#ifndef _system_passwd_h +#define _system_passwd_h + +/* + Unix SMB/CIFS implementation. + + passwd system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_PWD_H +#include +#endif +#ifdef HAVE_GRP_H +#include +#endif +#ifdef HAVE_SYS_PRIV_H +#include +#endif +#ifdef HAVE_SYS_ID_H +#include +#endif + +#ifdef HAVE_CRYPT_H +#include +#endif + +#ifdef HAVE_SHADOW_H +#include +#endif + +#ifdef HAVE_SYS_SECURITY_H +#include +#include +#define PASSWORD_LENGTH 16 +#endif /* HAVE_SYS_SECURITY_H */ + +#ifdef HAVE_GETPWANAM +#include +#include +#include +#endif + +#ifdef HAVE_COMPAT_H +#include +#endif + +#ifdef REPLACE_GETPASS +#define getpass(prompt) getsmbpass((prompt)) +#endif + +#ifndef NGROUPS_MAX +#define NGROUPS_MAX 32 /* Guess... */ +#endif + +/* what is the longest significant password available on your system? + Knowing this speeds up password searches a lot */ +#ifndef PASSWORD_LENGTH +#define PASSWORD_LENGTH 8 +#endif + +#if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS) +#define OSF1_ENH_SEC 1 +#endif + +#ifndef ALLOW_CHANGE_PASSWORD +#if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID)) +#define ALLOW_CHANGE_PASSWORD 1 +#endif +#endif + +#if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID) +#define ULTRIX_AUTH 1 +#endif + + +#ifndef HAVE_INITGROUPS +int initgroups(char *name,gid_t id); +#endif + +#endif diff --git a/source4/lib/replace/system/printing.h b/source4/lib/replace/system/printing.h new file mode 100644 index 0000000000..489ccb1da8 --- /dev/null +++ b/source4/lib/replace/system/printing.h @@ -0,0 +1,46 @@ +#ifndef _system_printing_h +#define _system_printing_h + +/* + Unix SMB/CIFS implementation. + + printing system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef AIX +#define DEFAULT_PRINTING PRINT_AIX +#define PRINTCAP_NAME "/etc/qconfig" +#endif + +#ifdef HPUX +#define DEFAULT_PRINTING PRINT_HPUX +#endif + +#ifdef QNX +#define DEFAULT_PRINTING PRINT_QNX +#endif + +#ifndef DEFAULT_PRINTING +#define DEFAULT_PRINTING PRINT_BSD +#endif +#ifndef PRINTCAP_NAME +#define PRINTCAP_NAME "/etc/printcap" +#endif + +#endif diff --git a/source4/lib/replace/system/readline.h b/source4/lib/replace/system/readline.h new file mode 100644 index 0000000000..4a64ef1376 --- /dev/null +++ b/source4/lib/replace/system/readline.h @@ -0,0 +1,48 @@ +#ifndef _system_readline_h +#define _system_readline_h +/* + Unix SMB/CIFS implementation. + + readline wrappers + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_LIBREADLINE +# ifdef HAVE_READLINE_READLINE_H +# include +# ifdef HAVE_READLINE_HISTORY_H +# include +# endif +# else +# ifdef HAVE_READLINE_H +# include +# ifdef HAVE_HISTORY_H +# include +# endif +# else +# undef HAVE_LIBREADLINE +# endif +# endif +#endif + +#ifdef HAVE_NEW_LIBREADLINE +# define RL_COMPLETION_CAST (rl_completion_func_t *) +#else +/* This type is missing from libreadline<4.0 (approximately) */ +# define RL_COMPLETION_CAST +#endif /* HAVE_NEW_LIBREADLINE */ + +#endif diff --git a/source4/lib/replace/system/select.h b/source4/lib/replace/system/select.h new file mode 100644 index 0000000000..0d1eabbc35 --- /dev/null +++ b/source4/lib/replace/system/select.h @@ -0,0 +1,42 @@ +#ifndef _system_select_h +#define _system_select_h +/* + Unix SMB/CIFS implementation. + + select system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#ifndef SELECT_CAST +#define SELECT_CAST +#endif + +/* use epoll if it is available */ +#if defined(HAVE_EPOLL_CREATE) && defined(HAVE_SYS_EPOLL_H) +#define WITH_EPOLL 1 +#endif + +#if WITH_EPOLL +#include +#endif + +#endif diff --git a/source4/lib/replace/system/shmem.h b/source4/lib/replace/system/shmem.h new file mode 100644 index 0000000000..9c0458363a --- /dev/null +++ b/source4/lib/replace/system/shmem.h @@ -0,0 +1,51 @@ +#ifndef _system_shmem_h +#define _system_shmem_h +/* + Unix SMB/CIFS implementation. + + shared memory system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#if defined(HAVE_SYS_IPC_H) +#include +#endif /* HAVE_SYS_IPC_H */ + +#if defined(HAVE_SYS_SHM_H) +#include +#endif /* HAVE_SYS_SHM_H */ + +#ifdef HAVE_SYS_MMAN_H +#include +#endif + +/* NetBSD doesn't have these */ +#ifndef SHM_R +#define SHM_R 0400 +#endif + +#ifndef SHM_W +#define SHM_W 0200 +#endif + + +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif + +#endif diff --git a/source4/lib/replace/system/syslog.h b/source4/lib/replace/system/syslog.h new file mode 100644 index 0000000000..e123830a70 --- /dev/null +++ b/source4/lib/replace/system/syslog.h @@ -0,0 +1,66 @@ +#ifndef _system_syslog_h +#define _system_syslog_h +/* + Unix SMB/CIFS implementation. + + syslog system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_SYSLOG_H +#include +#else +#ifdef HAVE_SYS_SYSLOG_H +#include +#endif +#endif + +/* For sys_adminlog(). */ +#ifndef LOG_EMERG +#define LOG_EMERG 0 /* system is unusable */ +#endif + +#ifndef LOG_ALERT +#define LOG_ALERT 1 /* action must be taken immediately */ +#endif + +#ifndef LOG_CRIT +#define LOG_CRIT 2 /* critical conditions */ +#endif + +#ifndef LOG_ERR +#define LOG_ERR 3 /* error conditions */ +#endif + +#ifndef LOG_WARNING +#define LOG_WARNING 4 /* warning conditions */ +#endif + +#ifndef LOG_NOTICE +#define LOG_NOTICE 5 /* normal but significant condition */ +#endif + +#ifndef LOG_INFO +#define LOG_INFO 6 /* informational */ +#endif + +#ifndef LOG_DEBUG +#define LOG_DEBUG 7 /* debug-level messages */ +#endif + +#endif diff --git a/source4/lib/replace/system/terminal.h b/source4/lib/replace/system/terminal.h new file mode 100644 index 0000000000..94d6b5cc98 --- /dev/null +++ b/source4/lib/replace/system/terminal.h @@ -0,0 +1,42 @@ +#ifndef _system_terminal_h +#define _system_terminal_h +/* + Unix SMB/CIFS implementation. + + terminal system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef SUNOS4 +/* on SUNOS4 termios.h conflicts with sys/ioctl.h */ +#undef HAVE_TERMIOS_H +#endif + + +#if defined(HAVE_TERMIOS_H) +/* POSIX terminal handling. */ +#include +#elif defined(HAVE_TERMIO_H) +/* Older SYSV terminal handling - don't use if we can avoid it. */ +#include +#elif defined(HAVE_SYS_TERMIO_H) +/* Older SYSV terminal handling - don't use if we can avoid it. */ +#include +#endif + +#endif diff --git a/source4/lib/replace/system/time.h b/source4/lib/replace/system/time.h new file mode 100644 index 0000000000..e7c88f133d --- /dev/null +++ b/source4/lib/replace/system/time.h @@ -0,0 +1,40 @@ +#ifndef _system_time_h +#define _system_time_h +/* + Unix SMB/CIFS implementation. + + time system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef TIME_WITH_SYS_TIME +#include +#include +#else +#ifdef HAVE_SYS_TIME_H +#include +#else +#include +#endif +#endif + +#ifdef HAVE_UTIME_H +#include +#endif + +#endif diff --git a/source4/lib/replace/system/wait.h b/source4/lib/replace/system/wait.h new file mode 100644 index 0000000000..be8c203f73 --- /dev/null +++ b/source4/lib/replace/system/wait.h @@ -0,0 +1,37 @@ +#ifndef _system_wait_h +#define _system_wait_h +/* + Unix SMB/CIFS implementation. + + waitpid system include wrappers + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_SYS_WAIT_H +#include +#endif + +#ifndef SIGCLD +#define SIGCLD SIGCHLD +#endif + +#ifndef SIGNAL_CAST +#define SIGNAL_CAST (RETSIGTYPE (*)(int)) +#endif + +#endif diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index af50edc2a3..9dddc017be 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -24,31 +24,28 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../replace.h" -#include +#include "replace.h" -#if HAVE_STDLIB_H -#include -#endif - -#if HAVE_SYS_TYPES_H -#include -#endif - -#if HAVE_SYS_STAT_H -#include -#endif - -#if HAVE_UNISTD_H -#include -#endif - -#if HAVE_STRING_H -#include -#endif - -#include -#include +/* + we include all the system/*.h include files here so that libreplace tests + them in the build farm +*/ +#include "system/capability.h" +#include "system/dir.h" +#include "system/filesys.h" +#include "system/glob.h" +#include "system/iconv.h" +#include "system/locale.h" +#include "system/network.h" +#include "system/passwd.h" +#include "system/printing.h" +#include "system/readline.h" +#include "system/select.h" +#include "system/shmem.h" +#include "system/syslog.h" +#include "system/terminal.h" +#include "system/time.h" +#include "system/wait.h" #define TESTFILE "testfile.dat" -- cgit From cdd352bfcb5aab71558961ee46068f7b89c1ba80 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 05:27:01 +0000 Subject: r18132: getpass can't depend on fns in lib/util/ (This used to be commit b346ab2f0573177e0a4654fd7c77a071225fc785) --- source4/lib/replace/getpass.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 1aac7c61ab..05fb7976b9 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -114,6 +114,32 @@ static int tcsetattr(int fd, int flags, struct sgttyb *_t) static struct termios t; #endif /* SYSV_TERMIO */ +static void catch_signal(int signum,void (*handler)(int )) +{ +#ifdef HAVE_SIGACTION + struct sigaction act; + struct sigaction oldact; + + memset(&act, 0, sizeof(act)); + + act.sa_handler = handler; +#ifdef SA_RESTART + /* + * We *want* SIGALRM to interrupt a system call. + */ + if(signum != SIGALRM) + act.sa_flags = SA_RESTART; +#endif + sigemptyset(&act.sa_mask); + sigaddset(&act.sa_mask,signum); + sigaction(signum,&act,&oldact); + return oldact.sa_handler; +#else /* !HAVE_SIGACTION */ + /* FIXME: need to handle sigvec and systems with broken signal() */ + return signal(signum, handler); +#endif +} + char *getsmbpass(const char *prompt) { FILE *in, *out; @@ -123,7 +149,7 @@ char *getsmbpass(const char *prompt) size_t nread; /* Catch problematic signals */ - CatchSignal(SIGINT, SIGNAL_CAST SIG_IGN); + catch_signal(SIGINT, SIGNAL_CAST SIG_IGN); /* Try to write to and read from the terminal if we can. If we can't open the terminal, use stderr and stdin. */ @@ -175,7 +201,7 @@ char *getsmbpass(const char *prompt) fclose (in); /* Catch problematic signals */ - CatchSignal(SIGINT, SIGNAL_CAST SIG_DFL); + catch_signal(SIGINT, SIGNAL_CAST SIG_DFL); printf("\n"); return buf; -- cgit From 01dee6e3dd80ace0bd341adb613fc25874e57764 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 6 Sep 2006 06:05:58 +0000 Subject: r18138: LIBREPLACE provides stuff from -ldl so it should depend on it metze (This used to be commit b4e4c115ab23bcc3b116a3736ddf2e88bab6f4cf) --- source4/lib/replace/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 2482c69636..49a1e7fe1b 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -14,6 +14,6 @@ OBJ_FILES = replace.o \ snprintf.o \ dlfcn.o \ getpass.o -PUBLIC_DEPENDENCIES = REPLACE_READDIR +PUBLIC_DEPENDENCIES = REPLACE_READDIR DL # End SUBSYSTEM LIBREPLACE ############################## -- cgit From 9ac11823bb874dde0cc6341662825f6cd8c38a07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 06:12:36 +0000 Subject: r18139: irix needs system/network.h here (This used to be commit f46ab799b41c0ec520739ec11979771316781ce4) --- source4/lib/replace/replace.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 733cb758bd..79ec2b75b9 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -28,6 +28,7 @@ #include "system/time.h" #include "system/passwd.h" #include "system/syslog.h" +#include "system/network.h" void replace_dummy(void); void replace_dummy(void) {} -- cgit From 92ff10f7b0bafb9260fff5d4abe6c596ac034e23 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 06:14:40 +0000 Subject: r18140: and this reduces warnings about toupper() (This used to be commit 41419e54d5e79d08a71cd9c94585be3448b1e9fc) --- source4/lib/replace/replace.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 79ec2b75b9..db07e49941 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -29,6 +29,7 @@ #include "system/passwd.h" #include "system/syslog.h" #include "system/network.h" +#include "system/locale.h" void replace_dummy(void); void replace_dummy(void) {} -- cgit From 90f485eecd86490ba03fb3b46fef00f9d0c6c6b1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 06:20:29 +0000 Subject: r18141: an accidental nested C comment! (This used to be commit 47c305c7dc5d2b2b61afe9f42f77ee3652c61a79) --- source4/lib/replace/test/testsuite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 9dddc017be..ddc9550f61 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -27,7 +27,7 @@ #include "replace.h" /* - we include all the system/*.h include files here so that libreplace tests + we include all the system/ include files here so that libreplace tests them in the build farm */ #include "system/capability.h" -- cgit From ed356c798974a302036b7e68c7e6b703c50bf09d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 07:11:09 +0000 Subject: r18143: the 'showflags' convention from Samba is useful for the other packages (This used to be commit a4d1f1d2229e1a0b1523bf14fab59278207abbc0) --- source4/lib/replace/Makefile.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 502dacbd2a..b2075d953b 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -17,7 +17,12 @@ CFLAGS=-I. -I@libreplacedir@ @CFLAGS@ OBJS = @LIBREPLACEOBJ@ -all: libreplace.a testsuite +all: showflags libreplace.a testsuite + +showflags: + @echo 'libreplace will be compiled with flags:' + @echo ' CFLAGS = $(CFLAGS)' + @echo ' LIBS = $(LIBS)' install: all mkdir -p $(libdir) -- cgit From 68d172c5063c3e84977e4238c1147cdc40d4b0be Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 6 Sep 2006 08:27:07 +0000 Subject: r18144: make the logic a bit more cut&paste friendly metze (This used to be commit da9be10dc602d21871d970a10015e970650942fe) --- source4/lib/replace/cc_features.m4 | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/cc_features.m4 b/source4/lib/replace/cc_features.m4 index a109dfb414..255009dd55 100644 --- a/source4/lib/replace/cc_features.m4 +++ b/source4/lib/replace/cc_features.m4 @@ -8,18 +8,22 @@ dnl adapted for libreplace by Andrew Tridgell ############################################ # Check if the compiler handles c99 struct initialization, and if not try -AC99 and -c99 flags -# Usage: LIBREPLACE_CC_SUPPORTS_C99_STRUCT_INIT(success-action,failure-action) +# Usage: LIBREPLACE_C99_STRUCT_INIT(success-action,failure-action) # changes CFLAGS to add -AC99 or -c99 if needed AC_DEFUN([LIBREPLACE_C99_STRUCT_INIT], [ -AC_MSG_CHECKING(for C99 designated initializers) saved_CFLAGS="$CFLAGS"; -AC_TRY_COMPILE([#include ], - [ struct foo {int x;char y;}; - struct foo bar = { .y = 'X', .x = 1 }; - ], - [AC_MSG_RESULT(yes); c99_init=yes; $1], [c99_init=no; AC_MSG_RESULT(no)]) +c99_init=no +if test x"$c99_init" = x"no"; then + AC_MSG_CHECKING(for C99 designated initializers) + CFLAGS="$saved_CFLAGS"; + AC_TRY_COMPILE([#include ], + [ struct foo {int x;char y;}; + struct foo bar = { .y = 'X', .x = 1 }; + ], + [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) +fi if test x"$c99_init" = x"no"; then AC_MSG_CHECKING(for C99 designated initializers with -AC99) CFLAGS="$saved_CFLAGS -AC99"; @@ -27,7 +31,7 @@ if test x"$c99_init" = x"no"; then [ struct foo {int x;char y;}; struct foo bar = { .y = 'X', .x = 1 }; ], - [AC_MSG_RESULT(yes); c99_init=yes; $1],[AC_MSG_RESULT(no)]) + [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) fi if test x"$c99_init" = x"no"; then AC_MSG_CHECKING(for C99 designated initializers with -c99) @@ -36,7 +40,14 @@ if test x"$c99_init" = x"no"; then [ struct foo {int x;char y;}; struct foo bar = { .y = 'X', .x = 1 }; ], - [AC_MSG_RESULT(yes); $1],[AC_MSG_RESULT(no);CFLAGS="$saved_CFLAGS"; $2]) + [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) +fi +if test x"$c99_init" = x"yes"; then + saved_CFLAGS="" + $1 +else + CFLAGS="$saved_CFLAGS" + saved_CFLAGS="" + $2 fi ]) - -- cgit From e997a767aae255992b0f1d229d15eb4f2b00484c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 6 Sep 2006 08:30:56 +0000 Subject: r18145: rename cc_feature.m4 into libreplace_macros.m4 metze (This used to be commit d0f40dd3e5ca8b46ee9b2c4332b393f519383aae) --- source4/lib/replace/cc_features.m4 | 53 -------------------------------- source4/lib/replace/libreplace.m4 | 2 +- source4/lib/replace/libreplace_macros.m4 | 53 ++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 54 deletions(-) delete mode 100644 source4/lib/replace/cc_features.m4 create mode 100644 source4/lib/replace/libreplace_macros.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/cc_features.m4 b/source4/lib/replace/cc_features.m4 deleted file mode 100644 index 255009dd55..0000000000 --- a/source4/lib/replace/cc_features.m4 +++ /dev/null @@ -1,53 +0,0 @@ -dnl C99 compiler check -dnl ------------------------------------------------------- -dnl Copyright (C) Stefan (metze) Metzmacher 2004,2005 -dnl Released under the GNU GPL -dnl ------------------------------------------------------- -dnl -dnl adapted for libreplace by Andrew Tridgell - -############################################ -# Check if the compiler handles c99 struct initialization, and if not try -AC99 and -c99 flags -# Usage: LIBREPLACE_C99_STRUCT_INIT(success-action,failure-action) -# changes CFLAGS to add -AC99 or -c99 if needed - -AC_DEFUN([LIBREPLACE_C99_STRUCT_INIT], -[ -saved_CFLAGS="$CFLAGS"; -c99_init=no -if test x"$c99_init" = x"no"; then - AC_MSG_CHECKING(for C99 designated initializers) - CFLAGS="$saved_CFLAGS"; - AC_TRY_COMPILE([#include ], - [ struct foo {int x;char y;}; - struct foo bar = { .y = 'X', .x = 1 }; - ], - [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) -fi -if test x"$c99_init" = x"no"; then - AC_MSG_CHECKING(for C99 designated initializers with -AC99) - CFLAGS="$saved_CFLAGS -AC99"; - AC_TRY_COMPILE([#include ], - [ struct foo {int x;char y;}; - struct foo bar = { .y = 'X', .x = 1 }; - ], - [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) -fi -if test x"$c99_init" = x"no"; then - AC_MSG_CHECKING(for C99 designated initializers with -c99) - CFLAGS="$saved_CFLAGS -c99" - AC_TRY_COMPILE([#include ], - [ struct foo {int x;char y;}; - struct foo bar = { .y = 'X', .x = 1 }; - ], - [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) -fi -if test x"$c99_init" = x"yes"; then - saved_CFLAGS="" - $1 -else - CFLAGS="$saved_CFLAGS" - saved_CFLAGS="" - $2 -fi -]) diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 1465756261..0c1d089217 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -167,7 +167,7 @@ AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) m4_include(getpass.m4) -m4_include(cc_features.m4) +m4_include(libreplace_macros.m4) m4_include(system/config.m4) LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes, diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 new file mode 100644 index 0000000000..255009dd55 --- /dev/null +++ b/source4/lib/replace/libreplace_macros.m4 @@ -0,0 +1,53 @@ +dnl C99 compiler check +dnl ------------------------------------------------------- +dnl Copyright (C) Stefan (metze) Metzmacher 2004,2005 +dnl Released under the GNU GPL +dnl ------------------------------------------------------- +dnl +dnl adapted for libreplace by Andrew Tridgell + +############################################ +# Check if the compiler handles c99 struct initialization, and if not try -AC99 and -c99 flags +# Usage: LIBREPLACE_C99_STRUCT_INIT(success-action,failure-action) +# changes CFLAGS to add -AC99 or -c99 if needed + +AC_DEFUN([LIBREPLACE_C99_STRUCT_INIT], +[ +saved_CFLAGS="$CFLAGS"; +c99_init=no +if test x"$c99_init" = x"no"; then + AC_MSG_CHECKING(for C99 designated initializers) + CFLAGS="$saved_CFLAGS"; + AC_TRY_COMPILE([#include ], + [ struct foo {int x;char y;}; + struct foo bar = { .y = 'X', .x = 1 }; + ], + [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) +fi +if test x"$c99_init" = x"no"; then + AC_MSG_CHECKING(for C99 designated initializers with -AC99) + CFLAGS="$saved_CFLAGS -AC99"; + AC_TRY_COMPILE([#include ], + [ struct foo {int x;char y;}; + struct foo bar = { .y = 'X', .x = 1 }; + ], + [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) +fi +if test x"$c99_init" = x"no"; then + AC_MSG_CHECKING(for C99 designated initializers with -c99) + CFLAGS="$saved_CFLAGS -c99" + AC_TRY_COMPILE([#include ], + [ struct foo {int x;char y;}; + struct foo bar = { .y = 'X', .x = 1 }; + ], + [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) +fi +if test x"$c99_init" = x"yes"; then + saved_CFLAGS="" + $1 +else + CFLAGS="$saved_CFLAGS" + saved_CFLAGS="" + $2 +fi +]) -- cgit From fed41fd9b19b5fe84bc7cabd07fef23299fbb4c6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 08:43:33 +0000 Subject: r18146: we need signal.h in some places (This used to be commit f226645d73c85011fea32a9b6e26eb41dd2c4336) --- source4/lib/replace/system/wait.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/wait.h b/source4/lib/replace/system/wait.h index be8c203f73..c2041a5938 100644 --- a/source4/lib/replace/system/wait.h +++ b/source4/lib/replace/system/wait.h @@ -26,6 +26,8 @@ #include #endif +#include + #ifndef SIGCLD #define SIGCLD SIGCHLD #endif -- cgit From ce8ed3a961b1284d211d104e650ee56ba6ad11bc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 6 Sep 2006 08:47:32 +0000 Subject: r18147: add make realdistclean metze (This used to be commit 20543e0306b129ee89c6ad21dd41205ac0263d7d) --- source4/lib/replace/Makefile.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index b2075d953b..36d99260d0 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -52,8 +52,8 @@ clean: distclean: clean rm -f *~ */*~ - rm -rf autom4te.cache - rm -f configure \ - config.log config.status \ - replace_config.h + rm -f config.log config.status config.h rm -f Makefile + +realdistclean: distclean + rm -f configure config.h.in -- cgit From 53a78afe301ebcaec234b8fb97de88e2a5bb6fa3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 6 Sep 2006 09:47:02 +0000 Subject: r18151: remove testfile metze (This used to be commit 6ffebfb9b7b8175eb312df6b9bc9fbd0db61b2e1) --- source4/lib/replace/Makefile.in | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 36d99260d0..d300458485 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -49,6 +49,7 @@ testsuite: libreplace.a $(TEST_OBJS) clean: rm -f *.o test/*.o *.a testsuite + rm -f testfile.dat distclean: clean rm -f *~ */*~ -- cgit From 6150443532ef714fcd060e4fe384db11552eb673 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 6 Sep 2006 09:52:16 +0000 Subject: r18152: move our AC macros into lib/replace/libreplace_macros.m4 and include them from there metze (This used to be commit 38f9e90a120b4e62f005a1bac89139ee87f63071) --- source4/lib/replace/aclocal.m4 | 1 + source4/lib/replace/libreplace.m4 | 15 +-- source4/lib/replace/libreplace_macros.m4 | 187 +++++++++++++++++++++++++++++-- 3 files changed, 182 insertions(+), 21 deletions(-) create mode 100644 source4/lib/replace/aclocal.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/aclocal.m4 b/source4/lib/replace/aclocal.m4 new file mode 100644 index 0000000000..2a7ad94963 --- /dev/null +++ b/source4/lib/replace/aclocal.m4 @@ -0,0 +1 @@ +m4_include(libreplace_macros.m4) diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 0c1d089217..1b3258e184 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -1,15 +1,5 @@ -dnl see if a declaration exists for a function or variable -dnl defines HAVE_function_DECL if it exists -dnl AC_HAVE_DECL(var, includes) -AC_DEFUN(AC_HAVE_DECL, -[ - AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[ - AC_TRY_COMPILE([$2],[int i = (int)$1], - ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)]) - if test x"$ac_cv_have_$1_decl" = x"yes"; then - AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available]) - fi -]) + +LIBREPLACE_C99_STRUCT_INIT([],[]) dnl find the libreplace sources. This is meant to work both for dnl libreplace standalone builds, and builds of packages using libreplace @@ -167,7 +157,6 @@ AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) m4_include(getpass.m4) -m4_include(libreplace_macros.m4) m4_include(system/config.m4) LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes, diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 255009dd55..9cf06c1a37 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -1,16 +1,11 @@ -dnl C99 compiler check -dnl ------------------------------------------------------- -dnl Copyright (C) Stefan (metze) Metzmacher 2004,2005 -dnl Released under the GNU GPL -dnl ------------------------------------------------------- -dnl -dnl adapted for libreplace by Andrew Tridgell +# +# This is a collection of useful autoconf macros +# ############################################ # Check if the compiler handles c99 struct initialization, and if not try -AC99 and -c99 flags # Usage: LIBREPLACE_C99_STRUCT_INIT(success-action,failure-action) # changes CFLAGS to add -AC99 or -c99 if needed - AC_DEFUN([LIBREPLACE_C99_STRUCT_INIT], [ saved_CFLAGS="$CFLAGS"; @@ -51,3 +46,179 @@ else $2 fi ]) + +dnl AC_PROG_CC_FLAG(flag) +AC_DEFUN(AC_PROG_CC_FLAG, +[AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1, +[echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then + ac_cv_prog_cc_$1=yes +else + ac_cv_prog_cc_$1=no +fi +rm -f conftest* +])]) + +dnl see if a declaration exists for a function or variable +dnl defines HAVE_function_DECL if it exists +dnl AC_HAVE_DECL(var, includes) +AC_DEFUN(AC_HAVE_DECL, +[ + AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[ + AC_TRY_COMPILE([$2],[int i = (int)$1], + ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)]) + if test x"$ac_cv_have_$1_decl" = x"yes"; then + AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available]) + fi +]) + + +# AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION], +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +# [ADD-ACTION-IF-FOUND],[OTHER-LIBRARIES]) +# ------------------------------------------------------ +# +# Use a cache variable name containing both the library and function name, +# because the test really is for library $1 defining function $3, not +# just for library $1. Separate tests with the same $1 and different $3s +# may have different results. +# +# Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$3]) +# is asking for trouble, since AC_CHECK_LIB($lib, fun) would give +# ac_cv_lib_$lib_fun, which is definitely not what was meant. Hence +# the AS_LITERAL_IF indirection. +# +# FIXME: This macro is extremely suspicious. It DEFINEs unconditionally, +# whatever the FUNCTION, in addition to not being a *S macro. Note +# that the cache does depend upon the function we are looking for. +# +# It is on purpose we used `ac_check_lib_ext_save_LIBS' and not just +# `ac_save_LIBS': there are many macros which don't want to see `LIBS' +# changed but still want to use AC_CHECK_LIB_EXT, so they save `LIBS'. +# And ``ac_save_LIBS' is too tempting a name, so let's leave them some +# freedom. +AC_DEFUN([AC_CHECK_LIB_EXT], +[ +AH_CHECK_LIB_EXT([$1]) +ac_check_lib_ext_save_LIBS=$LIBS +LIBS="-l$1 $$2 $7 $LIBS" +AS_LITERAL_IF([$1], + [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1])], + [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1''])])dnl + +m4_ifval([$3], + [ + AH_CHECK_FUNC_EXT([$3]) + AS_LITERAL_IF([$1], + [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1_$3])], + [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1''_$3])])dnl + AC_CACHE_CHECK([for $3 in -l$1], ac_Lib_func, + [AC_TRY_LINK_FUNC($3, + [AS_VAR_SET(ac_Lib_func, yes); + AS_VAR_SET(ac_Lib_ext, yes)], + [AS_VAR_SET(ac_Lib_func, no); + AS_VAR_SET(ac_Lib_ext, no)]) + ]) + AS_IF([test AS_VAR_GET(ac_Lib_func) = yes], + [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3))])dnl + AS_VAR_POPDEF([ac_Lib_func])dnl + ],[ + AC_CACHE_CHECK([for -l$1], ac_Lib_ext, + [AC_TRY_LINK_FUNC([main], + [AS_VAR_SET(ac_Lib_ext, yes)], + [AS_VAR_SET(ac_Lib_ext, no)]) + ]) + ]) +LIBS=$ac_check_lib_ext_save_LIBS + +AS_IF([test AS_VAR_GET(ac_Lib_ext) = yes], + [m4_default([$4], + [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1)) + case "$$2" in + *-l$1*) + ;; + *) + $2="-l$1 $$2" + ;; + esac]) + [$6] + ], + [$5])dnl +AS_VAR_POPDEF([ac_Lib_ext])dnl +])# AC_CHECK_LIB_EXT + +# AH_CHECK_LIB_EXT(LIBNAME) +# --------------------- +m4_define([AH_CHECK_LIB_EXT], +[AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1), + [Define to 1 if you have the `]$1[' library (-l]$1[).])]) + +dnl AC_SEARCH_LIBS_EXT(FUNCTION, SEARCH-LIBS, EXT_LIBS, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +dnl [OTHER-LIBRARIES]) +dnl -------------------------------------------------------- +dnl Search for a library defining FUNC, if it's not already available. +AC_DEFUN([AC_SEARCH_LIBS_EXT], +[AC_CACHE_CHECK([for library containing $1], [ac_cv_search_ext_$1], +[ +ac_func_search_ext_save_LIBS=$LIBS +ac_cv_search_ext_$1=no +AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], + [ac_cv_search_ext_$1="none required"]) +if test "$ac_cv_search_ext_$1" = no; then + for ac_lib in $2; do + LIBS="-l$ac_lib $$3 $6 $ac_func_search_save_ext_LIBS" + AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], + [ac_cv_search_ext_$1="-l$ac_lib" +break]) + done +fi +LIBS=$ac_func_search_ext_save_LIBS]) +AS_IF([test "$ac_cv_search_ext_$1" != no], + [test "$ac_cv_search_ext_$1" = "none required" || $3="$ac_cv_search_ext_$1 $$3" + $4], + [$5])dnl +]) + +dnl check for a function in a $LIBS and $OTHER_LIBS libraries variable. +dnl AC_CHECK_FUNC_EXT(func,OTHER_LIBS,IF-TRUE,IF-FALSE) +AC_DEFUN([AC_CHECK_FUNC_EXT], +[ + AH_CHECK_FUNC_EXT($1) + ac_check_func_ext_save_LIBS=$LIBS + LIBS="$2 $LIBS" + AS_VAR_PUSHDEF([ac_var], [ac_cv_func_ext_$1])dnl + AC_CACHE_CHECK([for $1], ac_var, + [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])], + [AS_VAR_SET(ac_var, yes)], + [AS_VAR_SET(ac_var, no)])]) + LIBS=$ac_check_func_ext_save_LIBS + AS_IF([test AS_VAR_GET(ac_var) = yes], + [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3], + [$4])dnl +AS_VAR_POPDEF([ac_var])dnl +])# AC_CHECK_FUNC + +# AH_CHECK_FUNC_EXT(FUNCNAME) +# --------------------- +m4_define([AH_CHECK_FUNC_EXT], +[AH_TEMPLATE(AS_TR_CPP(HAVE_$1), + [Define to 1 if you have the `]$1[' function.])]) + +dnl Define an AC_DEFINE with ifndef guard. +dnl AC_N_DEFINE(VARIABLE [, VALUE]) +define(AC_N_DEFINE, +[cat >> confdefs.h <<\EOF +[#ifndef] $1 +[#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1) +[#endif] +EOF +]) + +dnl Add an #include +dnl AC_ADD_INCLUDE(VARIABLE) +define(AC_ADD_INCLUDE, +[cat >> confdefs.h <<\EOF +[#include] $1 +EOF +]) -- cgit From 70b6211c98a15faf95a917b454a5f33961248e88 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 10:40:36 +0000 Subject: r18156: fix platforms that need timegm replacement (This used to be commit 859fefc3b9d4241c3db2b2642e3340dffd93f1dd) --- source4/lib/replace/config.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index 49a1e7fe1b..dd338ac305 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -13,7 +13,8 @@ CFLAGS = -Ilib/replace OBJ_FILES = replace.o \ snprintf.o \ dlfcn.o \ - getpass.o + getpass.o \ + timegm.o PUBLIC_DEPENDENCIES = REPLACE_READDIR DL # End SUBSYSTEM LIBREPLACE ############################## -- cgit From d093b28b55bac53c32cf3bf35424ca967b55bfc5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 6 Sep 2006 11:20:43 +0000 Subject: r18159: always recreate the the archive and use -s (which does the same as ranlib) and see how portable it is metze (This used to be commit 47b4509db909e0848842c1601f2058183d36bda7) --- source4/lib/replace/Makefile.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index d300458485..adaf0cd956 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -29,8 +29,7 @@ install: all $(INSTALL) libreplace.a $(libdir) libreplace.a: $(OBJS) - ar -rv $@ $(OBJS) - @-ranlib $@ + ar -rcsv $@ $(OBJS) test: testsuite ./testsuite -- cgit From 3ca73facc59ed8a97abbc28c1b4bedde87e109a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 11:31:59 +0000 Subject: r18160: - pread and pwrite replacements need to be non-static - replacing rename() is pointless - all platforms have it (and the #define of rename breaks some code) - use system/locale.h in snprintf.c - fix passwd.h for initgroups - stdlib is in replace.h, not needed elsewhere - fix the initgroups replacement - fix mapping of dl functions to rep_* (This used to be commit 57cd0ca176387d6a3acabf9fedeef4f2a3a3dad7) --- source4/lib/replace/dlfcn.c | 3 +-- source4/lib/replace/getpass.c | 1 - source4/lib/replace/replace.c | 29 +++++++---------------------- source4/lib/replace/replace.h | 34 +++++++++++++++++++++++++++------- source4/lib/replace/snprintf.c | 17 +---------------- source4/lib/replace/system/passwd.h | 5 ----- source4/lib/replace/test/testsuite.c | 7 ------- 7 files changed, 36 insertions(+), 60 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c index 79005c0d2b..e25ac9dfe5 100644 --- a/source4/lib/replace/dlfcn.c +++ b/source4/lib/replace/dlfcn.c @@ -24,7 +24,6 @@ */ #include "replace.h" -#include #ifndef HAVE_DLOPEN void *dlopen(const char *name, int flags) @@ -41,7 +40,7 @@ void *dlsym(void *handle, const char *symbol) #endif #ifndef HAVE_DLERROR -const char *dlerror(void) +char *dlerror(void) { return "dynamic loading of objects not supported on this platform"; } diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 05fb7976b9..2ccbf7b733 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -19,7 +19,6 @@ Cambridge, MA 02139, USA. */ /* Modified to use with samba by Jeremy Allison, 8th July 1995. */ #include "replace.h" -#include #if defined(HAVE_TERMIOS_H) /* POSIX terminal handling. */ diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index db07e49941..048ea3a998 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -30,6 +30,7 @@ #include "system/syslog.h" #include "system/network.h" #include "system/locale.h" +#include "system/wait.h" void replace_dummy(void); void replace_dummy(void) {} @@ -42,7 +43,7 @@ int rep_ftruncate(int f, off_t l) { #ifdef HAVE_CHSIZE return chsize(f,l); -#else +#elif defined(F_FREESP) struct flock fl; fl.l_whence = 0; @@ -50,6 +51,8 @@ int rep_ftruncate(int f, off_t l) fl.l_start = l; fl.l_type = F_WRLCK; return fcntl(f, F_FREESP, &fl); +#else +#error "you must have a ftruncate function" #endif } #endif /* HAVE_FTRUNCATE */ @@ -151,24 +154,6 @@ time_t rep_mktime(struct tm *t) #endif /* !HAVE_MKTIME */ - -#ifndef HAVE_RENAME -/* Rename a file. (from libiberty in GNU binutils) */ -int rep_rename(const char *zfrom, const char *zto) -{ - if (link (zfrom, zto) < 0) - { - if (errno != EEXIST) - return -1; - if (unlink (zto) < 0 - || link (zfrom, zto) < 0) - return -1; - } - return unlink (zfrom); -} -#endif /* HAVE_RENAME */ - - #ifndef HAVE_INNETGR #if defined(HAVE_SETNETGRENT) && defined(HAVE_GETNETGRENT) && defined(HAVE_ENDNETGRENT) /* @@ -211,7 +196,7 @@ int rep_initgroups(char *name, gid_t id) #include gid_t *grouplst = NULL; - int max_gr = groups_max(); + int max_gr = 32; int ret; int i,j; struct group *g; @@ -481,7 +466,7 @@ char *rep_mkdtemp(char *template) #endif #ifndef HAVE_PREAD -static ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) +ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) { if (lseek(__fd, __offset, SEEK_SET) != __offset) { return -1; @@ -491,7 +476,7 @@ static ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) #endif #ifndef HAVE_PWRITE -static ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) +ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) { if (lseek(__fd, __offset, SEEK_SET) != __offset) { return -1; diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 38b4e08704..90fd994ca5 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -61,7 +61,6 @@ #include #endif - #ifndef HAVE_STRERROR extern char *sys_errlist[]; #define strerror(i) sys_errlist[i] @@ -121,11 +120,6 @@ size_t rep_strnlen(const char *s, size_t n); int rep_setenv(const char *name, const char *value, int overwrite); #endif -#ifndef HAVE_RENAME -#define rename rep_rename -int rep_rename(const char *zfrom, const char *zto); -#endif - #ifndef HAVE_STRCASESTR #define strcasestr rep_strcasestr char *rep_strcasestr(const char *haystack, const char *needle); @@ -148,13 +142,38 @@ unsigned long long int rep_strtoull(const char *str, char **endptr, int base); #ifndef HAVE_FTRUNCATE #define ftruncate rep_ftruncate -int rep_ftruncate(int f,long l); +int rep_ftruncate(int,off_t); +#endif + +#ifndef HAVE_INITGROUPS +#define ftruncate rep_ftruncate +int rep_initgroups(char *name, gid_t id); #endif #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET) #define bzero(a,b) memset((a),'\0',(b)) #endif +#ifndef HAVE_DLERROR +#define dlerror rep_dlerror +char *rep_dlerror(void); +#endif + +#ifndef HAVE_DLOPEN +#define dlopen rep_dlopen +void *rep_dlopen(const char *name, int flags); +#endif + +#ifndef HAVE_DLSYM +#define dlsym rep_dlsym +void *rep_dlsym(void *handle, const char *symbol); +#endif + +#ifndef HAVE_DLCLOSE +#define dlclose rep_dlclose +int rep_dlclose(void *handle); +#endif + #ifndef PRINTF_ATTRIBUTE #if __GNUC__ >= 3 @@ -195,6 +214,7 @@ int rep_asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); #ifndef HAVE_VA_COPY +#undef va_copy #ifdef HAVE___VA_COPY #define va_copy(dest, src) __va_copy(dest, src) #else diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index dd41ca3306..5416a9d3e2 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -104,6 +104,7 @@ **************************************************************/ #include "replace.h" +#include "system/locale.h" #ifdef TEST_SNPRINTF /* need math library headers for testing */ @@ -117,22 +118,6 @@ # include #endif /* TEST_SNPRINTF */ -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_STRINGS_H -#include -#endif -#ifdef HAVE_CTYPE_H -#include -#endif -#include -#include -#ifdef HAVE_STDLIB_H -#include -#endif - #if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF) /* only include stdio.h if we are not re-defining snprintf or vsnprintf */ #include diff --git a/source4/lib/replace/system/passwd.h b/source4/lib/replace/system/passwd.h index 6f8d729a7c..21f31f0388 100644 --- a/source4/lib/replace/system/passwd.h +++ b/source4/lib/replace/system/passwd.h @@ -88,9 +88,4 @@ #define ULTRIX_AUTH 1 #endif - -#ifndef HAVE_INITGROUPS -int initgroups(char *name,gid_t id); -#endif - #endif diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index ddc9550f61..33270d9a4a 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -120,12 +120,6 @@ static int test_mktime(void) return true; } -static int test_rename(void) -{ - /* FIXME */ - return true; -} - static int test_innetgr(void) { /* FIXME */ @@ -378,7 +372,6 @@ int torture_local_replace(void *ctx) ret &= test_strlcpy(); ret &= test_strlcat(); ret &= test_mktime(); - ret &= test_rename(); ret &= test_innetgr(); ret &= test_initgroups(); ret &= test_memmove(); -- cgit From 6b5e86f47b21b560827c3ca24ee09f92f80fad3b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 6 Sep 2006 15:28:20 +0000 Subject: r18183: - add LIBREPLACE globaly and add LIBREPLACE_HOSTCC - also specify USE_HOSTCC = YES on binaries that use HOSTCC I also disable autodependecies as this change let make run forever, I hopefully fix that tomorrow metze (This used to be commit 159f74570233a8707dc1deb70fb1917a854213f8) --- source4/lib/replace/config.mk | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index dd338ac305..1e940b0a71 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -18,3 +18,12 @@ OBJ_FILES = replace.o \ PUBLIC_DEPENDENCIES = REPLACE_READDIR DL # End SUBSYSTEM LIBREPLACE ############################## + +[SUBSYSTEM::LIBREPLACE_HOSTCC] +CFLAGS = -Ilib/replace +OBJ_FILES = replace.ho \ + snprintf.ho \ + dlfcn.ho \ + getpass.ho \ + timegm.ho + -- cgit From 26a3023cc8a23c949c3f85989ed9c8e7771f9303 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 7 Sep 2006 07:23:58 +0000 Subject: r18205: need rep_ macros for seteuid and setegid (This used to be commit dd7af58b83815620114795aa49bc30b2440bd81b) --- source4/lib/replace/replace.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 90fd994ca5..4757046b6e 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -120,6 +120,16 @@ size_t rep_strnlen(const char *s, size_t n); int rep_setenv(const char *name, const char *value, int overwrite); #endif +#ifndef HAVE_SETEUID +#define seteuid rep_seteuid +int rep_seteuid(uid_t); +#endif + +#ifndef HAVE_SETEGID +#define setegid rep_setegid +int rep_setegid(gid_t); +#endif + #ifndef HAVE_STRCASESTR #define strcasestr rep_strcasestr char *rep_strcasestr(const char *haystack, const char *needle); -- cgit From 8717b5e3e65cc604293a03a55ba6f74f90355005 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 7 Sep 2006 07:26:02 +0000 Subject: r18206: need rep_ macro for setlinebuf (This used to be commit 6a48f75eaef031538c3e5b98d8672919bba7c409) --- source4/lib/replace/replace.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 4757046b6e..1a6e1588cb 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -130,6 +130,11 @@ int rep_seteuid(uid_t); int rep_setegid(gid_t); #endif +#ifndef HAVE_SETLINEBUF +#define setlinebuf rep_setlinebuf +int rep_setlinebuf(FILE *); +#endif + #ifndef HAVE_STRCASESTR #define strcasestr rep_strcasestr char *rep_strcasestr(const char *haystack, const char *needle); -- cgit From b7f937bdbbb419c85c2fe2682dc48aa247b621fc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 7 Sep 2006 10:50:33 +0000 Subject: r18216: a special override for the broken HP-UX C compiler. It does support C99 initialisers without any flags, but if you don't give it -AC99 then it dies when those initialisers are very complex (This used to be commit 46f72d7e3f285d08a043b4e8551f22c4dffe65e5) --- source4/lib/replace/libreplace_macros.m4 | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 9cf06c1a37..a50104cd1c 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -37,6 +37,16 @@ if test x"$c99_init" = x"no"; then ], [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) fi + +if test "`uname`" = "HP-UX"; then + if test "$ac_cv_c_compiler_gnu" = no; then + # special override for broken HP-UX compiler - I can't find a way to test + # this properly (its a compiler bug) + CFLAGS="$CFLAGS -AC99"; + c99_init=yes; + fi +fi + if test x"$c99_init" = x"yes"; then saved_CFLAGS="" $1 -- cgit From 24f4b6eff2ed9216be93674310ffcc44b7893895 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 7 Sep 2006 12:10:06 +0000 Subject: r18219: move some more portability checks out of samba4 and info lib/replace (This used to be commit 50318dc55ed5eb70adb02a5680498fad3c3e590d) --- source4/lib/replace/libreplace.m4 | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 1b3258e184..c72de29b1e 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -14,6 +14,8 @@ done LIBREPLACEOBJ="dlfcn.o getpass.o replace.o snprintf.o timegm.o" AC_SUBST(LIBREPLACEOBJ) +AC_SYS_LARGEFILE + AC_CHECK_HEADERS([stdint.h inttypes.h]) AC_CHECK_TYPE(uint_t, unsigned int) AC_CHECK_TYPE(uint8_t, unsigned char) @@ -25,6 +27,22 @@ AC_CHECK_TYPE(intptr_t, unsigned long long) AC_CHECK_TYPE(uint32_t, unsigned long) AC_CHECK_TYPE(ssize_t, int) +AC_TYPE_SIGNAL +AC_TYPE_UID_T +AC_TYPE_MODE_T +AC_TYPE_OFF_T +AC_TYPE_SIZE_T +AC_TYPE_PID_T +AC_STRUCT_ST_RDEV +AC_CHECK_TYPE(ino_t,unsigned) +AC_CHECK_TYPE(loff_t,off_t) +AC_CHECK_TYPE(offset_t,loff_t) +AC_CHECK_TYPES(long long) + +AC_FUNC_MEMCMP + +AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer) + AC_CHECK_HEADERS(stdbool.h) AC_CHECK_TYPE(bool, @@ -229,3 +247,16 @@ if test x"$samba_cv_sig_atomic_t" = x"yes"; then fi +AC_CACHE_CHECK([for O_DIRECT flag to open(2)],samba_cv_HAVE_OPEN_O_DIRECT,[ +AC_TRY_COMPILE([ +#include +#ifdef HAVE_FCNTL_H +#include +#endif], +[int fd = open("/dev/null", O_DIRECT);], +samba_cv_HAVE_OPEN_O_DIRECT=yes,samba_cv_HAVE_OPEN_O_DIRECT=no)]) +if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then + AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT]) +fi + + -- cgit From afe2fde6fd842f86166e48c2d008e8cf040eec72 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 7 Sep 2006 13:11:47 +0000 Subject: r18221: moved more configure checks into lib/replace/ (This used to be commit d853dcfda771888f80a80e14ffabb1c0e58a340e) --- source4/lib/replace/libreplace.m4 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index c72de29b1e..cdd83113ed 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -1,3 +1,7 @@ +dnl needed before AC_TRY_COMPILE +AC_ISC_POSIX + +AC_C_INLINE LIBREPLACE_C99_STRUCT_INIT([],[]) @@ -16,6 +20,16 @@ AC_SUBST(LIBREPLACEOBJ) AC_SYS_LARGEFILE +dnl Add #include for broken IRIX header files +case "$host_os" in + *irix6*) AC_ADD_INCLUDE() + ;; +esac + +AC_C_BIGENDIAN +AC_HEADER_STDC + + AC_CHECK_HEADERS([stdint.h inttypes.h]) AC_CHECK_TYPE(uint_t, unsigned int) AC_CHECK_TYPE(uint8_t, unsigned char) @@ -260,3 +274,21 @@ if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then fi +AC_CACHE_CHECK([that the C compiler can precompile header files],samba_cv_precompiled_headers, [ + dnl Check whether the compiler can generate precompiled headers + touch conftest.h + if ${CC-cc} conftest.h 2> /dev/null && test -f conftest.h.gch; then + precompiled_headers=yes + else + precompiled_headers=no + fi]) +AC_SUBST(precompiled_headers) + + +dnl Check if the C compiler understands volatile (it should, being ANSI). +AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [ + AC_TRY_COMPILE([#include ],[volatile int i = 0], + samba_cv_volatile=yes,samba_cv_volatile=no)]) +if test x"$samba_cv_volatile" = x"yes"; then + AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile]) +fi -- cgit From f64b2474be0d4f0f5ad20c511400f02b1cb981f0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Sep 2006 01:49:38 +0000 Subject: r18278: move more header checks and _GNU_SOURCE into libreplace (This used to be commit 77c442cd469ba881215e025c87ce632c876eb617) --- source4/lib/replace/libreplace.m4 | 3 ++- source4/lib/replace/replace.h | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index cdd83113ed..2fe58bf1e8 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -1,5 +1,6 @@ dnl needed before AC_TRY_COMPILE AC_ISC_POSIX +AC_USE_SYSTEM_EXTENSIONS AC_C_INLINE @@ -57,7 +58,7 @@ AC_FUNC_MEMCMP AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer) -AC_CHECK_HEADERS(stdbool.h) +AC_CHECK_HEADERS(stdbool.h stddef.h) AC_CHECK_TYPE(bool, [AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],, diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 1a6e1588cb..3bf884c80c 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -61,6 +61,14 @@ #include #endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_STDDEF_H +#include +#endif + #ifndef HAVE_STRERROR extern char *sys_errlist[]; #define strerror(i) sys_errlist[i] -- cgit From c2387587cb9c43c5f642554be9f08cc4ab0badc9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Sep 2006 02:12:09 +0000 Subject: r18280: more portability tidyups, ensuring we use libreplace everywhere (This used to be commit 4860d0256547b33709cdc109bdf7bb0310c2a5b6) --- source4/lib/replace/libreplace.m4 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 2fe58bf1e8..6a24c053e3 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -1,11 +1,3 @@ -dnl needed before AC_TRY_COMPILE -AC_ISC_POSIX -AC_USE_SYSTEM_EXTENSIONS - -AC_C_INLINE - -LIBREPLACE_C99_STRUCT_INIT([],[]) - dnl find the libreplace sources. This is meant to work both for dnl libreplace standalone builds, and builds of packages using libreplace libreplacedir="" @@ -19,6 +11,14 @@ done LIBREPLACEOBJ="dlfcn.o getpass.o replace.o snprintf.o timegm.o" AC_SUBST(LIBREPLACEOBJ) +dnl needed before AC_TRY_COMPILE +AC_ISC_POSIX +AC_USE_SYSTEM_EXTENSIONS +AC_C_INLINE +AC_PROG_CC + +LIBREPLACE_C99_STRUCT_INIT([],[]) + AC_SYS_LARGEFILE dnl Add #include for broken IRIX header files @@ -30,6 +30,10 @@ esac AC_C_BIGENDIAN AC_HEADER_STDC +AC_CHECK_SIZEOF(off_t,cross) +AC_CHECK_SIZEOF(size_t,cross) +AC_CHECK_SIZEOF(ssize_t,cross) +AC_FUNC_MMAP AC_CHECK_HEADERS([stdint.h inttypes.h]) AC_CHECK_TYPE(uint_t, unsigned int) -- cgit From e6b457d55031f1987c8fa5719c5bbf46743281a0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Sep 2006 02:52:41 +0000 Subject: r18283: libreplace.m4 needs to be early in configure.ac in other packages too (This used to be commit 03f9c67c066d772d9a544f1183fbee609ab8137b) --- source4/lib/replace/configure.ac | 2 -- source4/lib/replace/libreplace.m4 | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index bd500ae8d4..aaf404e373 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -5,8 +5,6 @@ AC_PREREQ(2.50) AC_INIT(dlfcn.c) AC_CONFIG_SRCDIR([dlfcn.c]) AC_CONFIG_HEADER(config.h) -AC_PROG_INSTALL -AC_PROG_CC if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings" diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 6a24c053e3..519b911de5 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -16,6 +16,7 @@ AC_ISC_POSIX AC_USE_SYSTEM_EXTENSIONS AC_C_INLINE AC_PROG_CC +AC_PROG_INSTALL LIBREPLACE_C99_STRUCT_INIT([],[]) @@ -30,6 +31,7 @@ esac AC_C_BIGENDIAN AC_HEADER_STDC + AC_CHECK_SIZEOF(off_t,cross) AC_CHECK_SIZEOF(size_t,cross) AC_CHECK_SIZEOF(ssize_t,cross) -- cgit From 55a760ddf3cd146ac68af1ff460d6a26ae209c04 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Sep 2006 03:16:05 +0000 Subject: r18284: enable _XOPEN_SOURCE_EXTENDED to fix a HP-UX bug with the definition of sendfile() (This used to be commit 3e0f262b384b73183452aefabca93c01d53387a8) --- source4/lib/replace/libreplace.m4 | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 519b911de5..ef8087607e 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -18,6 +18,12 @@ AC_C_INLINE AC_PROG_CC AC_PROG_INSTALL +AH_VERBATIM([_XOPEN_SOURCE_EXTENDED], +[/* Enable XOPEN extensions on systems that have them. */ +#ifndef _XOPEN_SOURCE_EXTENDED +# define _XOPEN_SOURCE_EXTENDED 1 +#endif]) + LIBREPLACE_C99_STRUCT_INIT([],[]) AC_SYS_LARGEFILE -- cgit From 05f98cdbfc64b549f4530a5e6aba0dcf3f536a87 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Sep 2006 03:45:04 +0000 Subject: r18287: add support for the -qlanglvl=extc99 and -qlanglvl=stdc99 flags, needed on AIX 5.2 for C99 structures (This used to be commit 2dc9239a3621f48fbb410a60fee61d70f85ada91) --- source4/lib/replace/libreplace_macros.m4 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index a50104cd1c..03ef97d157 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -28,6 +28,24 @@ if test x"$c99_init" = x"no"; then ], [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) fi +if test x"$c99_init" = x"no"; then + AC_MSG_CHECKING(for C99 designated initializers with -qlanglvl=extc99) + CFLAGS="$saved_CFLAGS -qlanglvl=extc99"; + AC_TRY_COMPILE([#include ], + [ struct foo {int x;char y;}; + struct foo bar = { .y = 'X', .x = 1 }; + ], + [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) +fi +if test x"$c99_init" = x"no"; then + AC_MSG_CHECKING(for C99 designated initializers with -qlanglvl=stdc99) + CFLAGS="$saved_CFLAGS -qlanglvl=stdc99"; + AC_TRY_COMPILE([#include ], + [ struct foo {int x;char y;}; + struct foo bar = { .y = 'X', .x = 1 }; + ], + [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)]) +fi if test x"$c99_init" = x"no"; then AC_MSG_CHECKING(for C99 designated initializers with -c99) CFLAGS="$saved_CFLAGS -c99" -- cgit From 5c3c8e09f9f5aefcd7600928597f01b1fc676e72 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Sep 2006 06:22:57 +0000 Subject: r18288: autoconf already has a C99 test builtin! If this works well, we can remove our own test (This used to be commit b4b028e65e242b0fa1d74454bfa0b292917088eb) --- source4/lib/replace/libreplace.m4 | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index ef8087607e..cf15734090 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -15,6 +15,7 @@ dnl needed before AC_TRY_COMPILE AC_ISC_POSIX AC_USE_SYSTEM_EXTENSIONS AC_C_INLINE +AC_PROG_CC_C99 AC_PROG_CC AC_PROG_INSTALL -- cgit From 594781270e107f9fbc6061e6223f2c693bec6b58 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Sep 2006 06:24:13 +0000 Subject: r18289: don't check for inline till we've worked out the main compiler flags (This used to be commit 46ab2b9971c100afa2ed2cb8da0390cfaa9b7032) --- source4/lib/replace/libreplace.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index cf15734090..6c8c01d687 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -14,9 +14,9 @@ AC_SUBST(LIBREPLACEOBJ) dnl needed before AC_TRY_COMPILE AC_ISC_POSIX AC_USE_SYSTEM_EXTENSIONS -AC_C_INLINE AC_PROG_CC_C99 AC_PROG_CC +AC_C_INLINE AC_PROG_INSTALL AH_VERBATIM([_XOPEN_SOURCE_EXTENDED], -- cgit From 6d8a03b5f5ba42fcfc449b1aaf64f120e42b226f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 9 Sep 2006 08:34:48 +0000 Subject: r18292: import some autoconf 2.60 specific macros, so that older autoconf versions still work metze (This used to be commit 43970e6d081e56837e38856a9d05c8b9c303955e) --- source4/lib/replace/autoconf-2.60.m4 | 197 +++++++++++++++++++++++++++++++ source4/lib/replace/libreplace_macros.m4 | 2 + 2 files changed, 199 insertions(+) create mode 100644 source4/lib/replace/autoconf-2.60.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/autoconf-2.60.m4 b/source4/lib/replace/autoconf-2.60.m4 new file mode 100644 index 0000000000..5360fff5d2 --- /dev/null +++ b/source4/lib/replace/autoconf-2.60.m4 @@ -0,0 +1,197 @@ +# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST, +# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE) +# -------------------------------------------------------------- +# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99') +# by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails, +# try again with each compiler option in the space-separated OPTION-LIST; if one +# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE, +# else ACTION-IF-UNAVAILABLE. +AC_DEFUN([_AC_C_STD_TRY], +[AC_MSG_CHECKING([for $CC option to accept ISO ]m4_translit($1, [c], [C])) +AC_CACHE_VAL(ac_cv_prog_cc_$1, +[ac_cv_prog_cc_$1=no +ac_save_CC=$CC +AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])]) +for ac_arg in '' $4 +do + CC="$ac_save_CC $ac_arg" + _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg]) + test "x$ac_cv_prog_cc_$1" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC +])# AC_CACHE_VAL +case "x$ac_cv_prog_cc_$1" in + x) + AC_MSG_RESULT([none needed]) ;; + xno) + AC_MSG_RESULT([unsupported]) ;; + *) + CC="$CC $ac_cv_prog_cc_$1" + AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;; +esac +AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6]) +])# _AC_C_STD_TRY + +# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# ---------------------------------------------------------------- +# If the C compiler is not in ISO C99 mode by default, try to add an +# option to output variable CC to make it so. This macro tries +# various options that select ISO C99 on some system or another. It +# considers the compiler to be in ISO C99 mode if it handles mixed +# code and declarations, _Bool, inline and restrict. +AC_DEFUN([_AC_PROG_CC_C99], +[_AC_C_STD_TRY([c99], +[[#include +#include +#include +#include +#include + +struct incomplete_array +{ + int datasize; + double data[]; +}; + +struct named_init { + int number; + const wchar_t *name; + double average; +}; + +typedef const char *ccp; + +static inline int +test_restrict(ccp restrict text) +{ + // See if C++-style comments work. + // Iterate through items via the restricted pointer. + // Also check for declarations in for loops. + for (unsigned int i = 0; *(text+i) != '\0'; ++i) + continue; + return 0; +} + +// Check varargs and va_copy work. +static void +test_varargs(const char *format, ...) +{ + va_list args; + va_start(args, format); + va_list args_copy; + va_copy(args_copy, args); + + const char *str; + int number; + float fnumber; + + while (*format) + { + switch (*format++) + { + case 's': // string + str = va_arg(args_copy, const char *); + break; + case 'd': // int + number = va_arg(args_copy, int); + break; + case 'f': // float + fnumber = (float) va_arg(args_copy, double); + break; + default: + break; + } + } + va_end(args_copy); + va_end(args); +} +]], +[[ + // Check bool and long long datatypes. + _Bool success = false; + long long int bignum = -1234567890LL; + unsigned long long int ubignum = 1234567890uLL; + + // Check restrict. + if (test_restrict("String literal") != 0) + success = true; + char *restrict newvar = "Another string"; + + // Check varargs. + test_varargs("s, d' f .", "string", 65, 34.234); + + // Check incomplete arrays work. + struct incomplete_array *ia = + malloc(sizeof(struct incomplete_array) + (sizeof(double) * 10)); + ia->datasize = 10; + for (int i = 0; i < ia->datasize; ++i) + ia->data[i] = (double) i * 1.234; + + // Check named initialisers. + struct named_init ni = { + .number = 34, + .name = L"Test wide string", + .average = 543.34343, + }; + + ni.number = 58; + + int dynamic_array[ni.number]; + dynamic_array[43] = 543; + + // work around unused variable warnings + return bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'; +]], +dnl Try +dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999) +dnl AIX -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99) +dnl Intel ICC -c99 +dnl IRIX -c99 +dnl Solaris (unused because it causes the compiler to assume C99 semantics for +dnl library functions, and this is invalid before Solaris 10: -xc99) +dnl Tru64 -c99 +dnl with extended modes being tried first. +[[-std=gnu99 -c99 -qlanglvl=extc99]], [$1], [$2])[]dnl +])# _AC_PROG_CC_C99 + +# AC_PROG_CC_C99 +# -------------- +AC_DEFUN([AC_PROG_CC_C99], +[ AC_REQUIRE([AC_PROG_CC])dnl + _AC_PROG_CC_C99 +]) + +# AC_USE_SYSTEM_EXTENSIONS +# ------------------------ +# Enable extensions on systems that normally disable them, +# typically due to standards-conformance issues. +AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], +[ + AC_BEFORE([$0], [AC_COMPILE_IFELSE]) + AC_BEFORE([$0], [AC_RUN_IFELSE]) + + AC_REQUIRE([AC_GNU_SOURCE]) + AC_REQUIRE([AC_AIX]) + AC_REQUIRE([AC_MINIX]) + + AH_VERBATIM([__EXTENSIONS__], +[/* Enable extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif]) + AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], + [ac_cv_safe_to_define___extensions__], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ +# define __EXTENSIONS__ 1 + AC_INCLUDES_DEFAULT])], + [ac_cv_safe_to_define___extensions__=yes], + [ac_cv_safe_to_define___extensions__=no])]) + test $ac_cv_safe_to_define___extensions__ = yes && + AC_DEFINE([__EXTENSIONS__]) + AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) +]) diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 03ef97d157..71ef64337b 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -250,3 +250,5 @@ define(AC_ADD_INCLUDE, [#include] $1 EOF ]) + +m4_include(autoconf-2.60.m4) -- cgit From 4e99d06ee72ca032856e7c1200ebef9e0feab74f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Sep 2006 10:29:13 +0000 Subject: r18304: fixed misuse of size_t in dopr() (This used to be commit d082a3c5f5785e9d7775d94542ce9cc8ef098f63) --- source4/lib/replace/snprintf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 5416a9d3e2..c06e8d76a3 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -224,7 +224,7 @@ struct pr_chunk_x { int num; }; -static size_t dopr(char *buffer, size_t maxlen, const char *format, +static int dopr(char *buffer, size_t maxlen, const char *format, va_list args_in); static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max); @@ -237,7 +237,7 @@ static struct pr_chunk *new_chunk(void); static int add_cnk_list_entry(struct pr_chunk_x **list, int max_num, struct pr_chunk *chunk); -static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args_in) +static int dopr(char *buffer, size_t maxlen, const char *format, va_list args_in) { char ch; int state; @@ -251,7 +251,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args struct pr_chunk *cnk = NULL; struct pr_chunk_x *clist = NULL; int max_pos; - size_t ret = -1; + int ret = -1; VA_COPY(args, args_in); -- cgit From 9adf2883efc275b359d8e50c493023c48883eef6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Sep 2006 10:00:42 +0000 Subject: r18321: fixed some warnings on AIX (This used to be commit 449fab2c264aa50601f9a2d3310f1910ba97706b) --- source4/lib/replace/snprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index c06e8d76a3..1ff3c1e324 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -914,7 +914,7 @@ static LLONG ROUND(LDOUBLE value) static double my_modf(double x0, double *iptr) { int i; - LLONG l; + LLONG l=0; double x = x0; double f = 1.0; -- cgit From fc8960ee9aec25db398d2ed4df124484f70abcfb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Sep 2006 11:47:21 +0000 Subject: r18332: added back in our shared mmap test code (This used to be commit 6ff100b26698a50ba79b587a687cc0d440f73b55) --- source4/lib/replace/libreplace.m4 | 10 ++++- source4/lib/replace/test/shared_mmap.c | 68 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 source4/lib/replace/test/shared_mmap.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 6c8c01d687..cd9d171662 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -42,7 +42,6 @@ AC_HEADER_STDC AC_CHECK_SIZEOF(off_t,cross) AC_CHECK_SIZEOF(size_t,cross) AC_CHECK_SIZEOF(ssize_t,cross) -AC_FUNC_MMAP AC_CHECK_HEADERS([stdint.h inttypes.h]) AC_CHECK_TYPE(uint_t, unsigned int) @@ -83,9 +82,18 @@ AC_INCLUDES_DEFAULT ) +AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[ +AC_TRY_RUN([#include "$libreplacedir/test/shared_mmap.c"], + samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)]) +if test x"$samba_cv_HAVE_MMAP" = x"yes"; then + AC_DEFINE(HAVE_MMAP,1,[Whether mmap works]) +fi + + AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ #include +#include #include #include #ifdef HAVE_ARPA_INET_H diff --git a/source4/lib/replace/test/shared_mmap.c b/source4/lib/replace/test/shared_mmap.c new file mode 100644 index 0000000000..50dad8d696 --- /dev/null +++ b/source4/lib/replace/test/shared_mmap.c @@ -0,0 +1,68 @@ +/* this tests whether we can use a shared writeable mmap on a file - + as needed for the mmap variant of FAST_SHARE_MODES */ + +#if defined(HAVE_UNISTD_H) +#include +#endif +#include +#include +#include +#include + +#define DATA "conftest.mmap" + +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif + +main() +{ + int *buf; + int i; + int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666); + int count=7; + + if (fd == -1) exit(1); + + for (i=0;i<10000;i++) { + write(fd,&i,sizeof(i)); + } + + close(fd); + + if (fork() == 0) { + fd = open(DATA,O_RDWR); + if (fd == -1) exit(1); + + buf = (int *)mmap(NULL, 10000*sizeof(int), + (PROT_READ | PROT_WRITE), + MAP_FILE | MAP_SHARED, + fd, 0); + + while (count-- && buf[9124] != 55732) sleep(1); + + if (count <= 0) exit(1); + + buf[1763] = 7268; + exit(0); + } + + fd = open(DATA,O_RDWR); + if (fd == -1) exit(1); + + buf = (int *)mmap(NULL, 10000*sizeof(int), + (PROT_READ | PROT_WRITE), + MAP_FILE | MAP_SHARED, + fd, 0); + + if (buf == (int *)-1) exit(1); + + buf[9124] = 55732; + + while (count-- && buf[1763] != 7268) sleep(1); + + unlink(DATA); + + if (count > 0) exit(0); + exit(1); +} -- cgit From 3f8383cd6169eeefdb06172fc1388b6743ad3ae0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Sep 2006 12:23:47 +0000 Subject: r18335: more portable bool tests (This used to be commit 45a3a6a566de020578c24feb5788367efd685f29) --- source4/lib/replace/libreplace.m4 | 9 +++++++++ source4/lib/replace/replace.h | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index cd9d171662..a734704ae8 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -81,6 +81,15 @@ AC_INCLUDES_DEFAULT #endif] ) +AC_CHECK_TYPE(_Bool, +[AC_DEFINE(HAVE__Bool, 1, [Whether the _Bool type is available])],, +[ +AC_INCLUDES_DEFAULT +#ifdef HAVE_STDBOOL_H +#include +#endif] +) + AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[ AC_TRY_RUN([#include "$libreplacedir/test/shared_mmap.c"], diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 3bf884c80c..88fec3f4d7 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -310,12 +310,23 @@ char *rep_mkdtemp(char *template); #ifdef HAVE_STDBOOL_H #include -#elif !defined(HAVE_BOOL) +#endif + +#if !defined(HAVE_BOOL) +#ifdef HAVE__Bool +#define bool _Bool +#else #define __bool_true_false_are_defined typedef int bool; -#define false (0) +#endif +#endif + +#ifndef true #define true (1) #endif +#ifndef false +#define false (0) +#endif #ifndef HAVE_FUNCTION_MACRO #ifdef HAVE_func_MACRO -- cgit From 2e24543b2185a43c9d3c328ff3be9488a899c915 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Sep 2006 12:38:32 +0000 Subject: r18336: autoconf tries to force on C89 mode on HP-UX, using the -Ae flag. Unfortunately that flag conflicts with the -AC99 flag, and we get lots of breakage. This is a trick to force off the -Ae option (This used to be commit eb93fb8e54c46df35904e03870063c4532599442) --- source4/lib/replace/libreplace.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index a734704ae8..19830bc989 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -11,6 +11,10 @@ done LIBREPLACEOBJ="dlfcn.o getpass.o replace.o snprintf.o timegm.o" AC_SUBST(LIBREPLACEOBJ) +dnl stop the C89 attempt by autoconf - if autoconf detects -Ae it will enable it +dnl which conflicts with C99 on HPUX +ac_cv_prog_cc_Ae=no + dnl needed before AC_TRY_COMPILE AC_ISC_POSIX AC_USE_SYSTEM_EXTENSIONS -- cgit From d82ed849cc3d0e9b3f97653664068faa9433c1df Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Sep 2006 12:45:37 +0000 Subject: r18337: more -Ae tests in check_cc.m4 honor the MMAP_BLACKLIST (This used to be commit c2f2dbb5d1c082ee1391908073336a9dfc10f712) --- source4/lib/replace/replace.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 88fec3f4d7..ee86a81b5d 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -352,4 +352,8 @@ typedef int bool; #define __STRING(x) #x #endif +#if MMAP_BLACKLIST +#undef HAVE_MMAP +#endif + #endif -- cgit From 5c104c1d2fcb06ae52c340919d9e2e0cfba9a409 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Sep 2006 13:02:54 +0000 Subject: r18339: need these checks for roken.h on hpux (This used to be commit e98e0a28a0cb79e272c0caa0bcb3b5fb6bf3a17b) --- source4/lib/replace/libreplace.m4 | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 19830bc989..cfefb44e9c 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -58,6 +58,17 @@ AC_CHECK_TYPE(intptr_t, unsigned long long) AC_CHECK_TYPE(uint32_t, unsigned long) AC_CHECK_TYPE(ssize_t, int) +dnl these are needed for heimdal roken.h +AC_CHECK_TYPE(struct sockaddr, [], [], [ +AC_INCLUDES_DEFAULT +#include ]) +AC_CHECK_TYPE(struct sockaddr_storage, [], [], [ +AC_INCLUDES_DEFAULT +#include ]) +AC_CHECK_TYPE(struct addrinfo, [], [], [ +AC_INCLUDES_DEFAULT +#include ]) + AC_TYPE_SIGNAL AC_TYPE_UID_T AC_TYPE_MODE_T -- cgit From a9aa66ab32f8b0cb3d486f317a293ae0972f62e4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Sep 2006 13:16:27 +0000 Subject: r18340: some HPUX boxes don't have ptrdiff_t (This used to be commit f3b24ea48a70268be5a3af601b5bb923d446c5d5) --- source4/lib/replace/libreplace.m4 | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index cfefb44e9c..dbc1d10326 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -57,6 +57,7 @@ AC_CHECK_TYPE(int32_t, long) AC_CHECK_TYPE(intptr_t, unsigned long long) AC_CHECK_TYPE(uint32_t, unsigned long) AC_CHECK_TYPE(ssize_t, int) +AC_CHECK_TYPE(ptrdiff_t, unsigned long long) dnl these are needed for heimdal roken.h AC_CHECK_TYPE(struct sockaddr, [], [], [ -- cgit From a8421e81078b91ae97ada3be352416eae26a9c7b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Sep 2006 14:19:38 +0000 Subject: r18343: fixed setlinebuf() prototype, added test for it, and use it in two places to avoid a #ifdef (This used to be commit 095b8057740a4bb207e24e4c63a2dcb53521a72f) --- source4/lib/replace/replace.c | 4 ++-- source4/lib/replace/replace.h | 2 +- source4/lib/replace/test/testsuite.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 048ea3a998..aa3e8717c2 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -338,9 +338,9 @@ char *rep_inet_ntoa(struct in_addr ip) #endif #ifndef HAVE_SETLINEBUF -int rep_setlinebuf(FILE *stream) +void rep_setlinebuf(FILE *stream) { - return setvbuf(stream, (char *)NULL, _IOLBF, 0); + setvbuf(stream, (char *)NULL, _IOLBF, 0); } #endif /* HAVE_SETLINEBUF */ diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index ee86a81b5d..7664c51a5d 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -140,7 +140,7 @@ int rep_setegid(gid_t); #ifndef HAVE_SETLINEBUF #define setlinebuf rep_setlinebuf -int rep_setlinebuf(FILE *); +void rep_setlinebuf(FILE *); #endif #ifndef HAVE_STRCASESTR diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 33270d9a4a..89d2ae6a88 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -146,7 +146,8 @@ static int test_strdup(void) static int test_setlinebuf(void) { - /* FIXME */ + printf("testing setlinebuf\n"); + setlinebuf(stdout); return true; } -- cgit From 620a1488b326d76a22128c1268cadd577904deac Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Sep 2006 00:50:57 +0000 Subject: r18350: we have to check for lstat() to keep roken happen on hpux (This used to be commit e251c211f7fa67e2e32d684f10a742b496913284) --- source4/lib/replace/libreplace.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index dbc1d10326..b87f2b12a7 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -84,7 +84,7 @@ AC_CHECK_TYPES(long long) AC_FUNC_MEMCMP -AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer) +AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat) AC_CHECK_HEADERS(stdbool.h stddef.h) -- cgit From 691ba583afaaeb1f6f96befa75396536aed57e97 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Sep 2006 01:38:50 +0000 Subject: r18353: try to fix the assumption of NULL being handled in printf() permanently by replacing printf() on systems that don't have a C99 printf lib (This used to be commit eacb5357c347255817a0a47abe7dadfaf24301fa) --- source4/lib/replace/snprintf.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 1ff3c1e324..93285a5e57 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -1209,6 +1209,27 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, } #endif +#ifndef HAVE_C99_VSNPRINTF + int printf(const char *fmt, ...) +{ + va_list ap; + int ret; + char *s; + + s = NULL; + va_start(ap, fmt); + ret = vasprintf(&s, fmt, ap); + va_end(ap); + + if (s) { + fwrite(s, 1, strlen(s), stdout); + } + free(s); + + return ret; +} +#endif + #endif #ifndef HAVE_VASPRINTF -- cgit From cb487062c80c39eadfbedd97e86ae8339d036931 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Sep 2006 04:47:48 +0000 Subject: r18359: better handling of child process killing in standard mode (This used to be commit 3752cc2b5767950b26b57e79fa87a70f8d93173d) --- source4/lib/replace/libreplace.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index b87f2b12a7..060d0feefa 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -84,7 +84,7 @@ AC_CHECK_TYPES(long long) AC_FUNC_MEMCMP -AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat) +AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat getpgrp) AC_CHECK_HEADERS(stdbool.h stddef.h) -- cgit From 3f513415282a8d6e1633fcb36e04979d63fd254a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Sep 2006 10:32:39 +0000 Subject: r18378: try enabling _OSF_SOURCE to see if it fixes the tru64 build problems - thanks to volker for the suggestion (This used to be commit 03ed41515b2228d130f669a2c0cf916a21182f30) --- source4/lib/replace/libreplace.m4 | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 060d0feefa..b428870a87 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -29,6 +29,12 @@ AH_VERBATIM([_XOPEN_SOURCE_EXTENDED], # define _XOPEN_SOURCE_EXTENDED 1 #endif]) +AH_VERBATIM([_OSF_SOURCE], +[/* Enable OSF extensions on systems that have them. */ +#ifndef _OSF_SOURCE +# define _OSF_SOURCE 1 +#endif]) + LIBREPLACE_C99_STRUCT_INIT([],[]) AC_SYS_LARGEFILE -- cgit From 70028b82a9d1f4c6b2a797c76b1e7d0e1da7480f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 11 Sep 2006 12:47:40 +0000 Subject: r18381: make sure autoconf doesn't add '-O2' to CFLAGS metze (This used to be commit ec6365b5f18eea7035b6963c8005e75b9f4e3437) --- source4/lib/replace/libreplace.m4 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index b428870a87..52e1b5fe1d 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -15,11 +15,12 @@ dnl stop the C89 attempt by autoconf - if autoconf detects -Ae it will enable it dnl which conflicts with C99 on HPUX ac_cv_prog_cc_Ae=no -dnl needed before AC_TRY_COMPILE +savedCFLAGS=$CFLAGS +AC_PROG_CC +CFLAGS=$savedCFLAGS AC_ISC_POSIX AC_USE_SYSTEM_EXTENSIONS AC_PROG_CC_C99 -AC_PROG_CC AC_C_INLINE AC_PROG_INSTALL -- cgit From d40dcaebdac67bc85fda5ecffc2180b0fbc9423c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 11 Sep 2006 13:47:29 +0000 Subject: r18382: define _XOPEN_SOURCE to hopefully bring in MAP_FAILED in sys/mman.h on Tru64 metze (This used to be commit 8109eb9d28c9043c359d48319efe91aed2714431) --- source4/lib/replace/libreplace.m4 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 52e1b5fe1d..8b1486c5c1 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -24,6 +24,12 @@ AC_PROG_CC_C99 AC_C_INLINE AC_PROG_INSTALL +AH_VERBATIM([_XOPEN_SOURCE], +[/* Enable XOPEN on systems that have them. */ +#ifndef _XOPEN_SOURCE +# define _XOPEN_SOURCE 1 +#endif]) + AH_VERBATIM([_XOPEN_SOURCE_EXTENDED], [/* Enable XOPEN extensions on systems that have them. */ #ifndef _XOPEN_SOURCE_EXTENDED @@ -113,7 +119,6 @@ AC_INCLUDES_DEFAULT #endif] ) - AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[ AC_TRY_RUN([#include "$libreplacedir/test/shared_mmap.c"], samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)]) -- cgit From 27964734a643b814f89b9521ab3b9a1b20787049 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 11 Sep 2006 14:08:51 +0000 Subject: r18383: ok we need _XOPEN_SOURCE 500 and include standards.h on Tru64 to get MAP_FAILED metze (This used to be commit 0f48c8ad7c066ba33cb8d4491083e15b24c5046e) --- source4/lib/replace/libreplace.m4 | 4 +++- source4/lib/replace/replace.h | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 8b1486c5c1..cbbc16db4e 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -27,7 +27,7 @@ AC_PROG_INSTALL AH_VERBATIM([_XOPEN_SOURCE], [/* Enable XOPEN on systems that have them. */ #ifndef _XOPEN_SOURCE -# define _XOPEN_SOURCE 1 +# define _XOPEN_SOURCE 500 #endif]) AH_VERBATIM([_XOPEN_SOURCE_EXTENDED], @@ -52,6 +52,8 @@ case "$host_os" in ;; esac +AC_CHECK_HEADERS([standards.h]) + AC_C_BIGENDIAN AC_HEADER_STDC diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 7664c51a5d..70fd89e3b9 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -30,6 +30,10 @@ #include "config.h" +#ifdef HAVE_STANDARDS_H +#include +#endif + #include #include #include -- cgit From 497ca8527f3a729e81563397f2b92a9652c55e54 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 11 Sep 2006 16:02:36 +0000 Subject: r18388: remove _XOPEN_SOURCE it causes trouble on BSD and IRIX I need to find a way to define it only on Tru64 maybe. metze (This used to be commit aca8a3f8c0bb3cce0ef8c5fd945011581d19586d) --- source4/lib/replace/libreplace.m4 | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index cbbc16db4e..c21f59e163 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -24,12 +24,6 @@ AC_PROG_CC_C99 AC_C_INLINE AC_PROG_INSTALL -AH_VERBATIM([_XOPEN_SOURCE], -[/* Enable XOPEN on systems that have them. */ -#ifndef _XOPEN_SOURCE -# define _XOPEN_SOURCE 500 -#endif]) - AH_VERBATIM([_XOPEN_SOURCE_EXTENDED], [/* Enable XOPEN extensions on systems that have them. */ #ifndef _XOPEN_SOURCE_EXTENDED -- cgit From 513568b7e2da1fe3ba26fb02228d616b453112ea Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Sep 2006 21:25:06 +0000 Subject: r18400: move MAP_FAILED define to lib/replace/system/shmem.h (This used to be commit 025b142ff268498cfb36fc0e7e9e25a2c5963d38) --- source4/lib/replace/system/shmem.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/shmem.h b/source4/lib/replace/system/shmem.h index 9c0458363a..26fa7c8d43 100644 --- a/source4/lib/replace/system/shmem.h +++ b/source4/lib/replace/system/shmem.h @@ -48,4 +48,8 @@ #define MAP_FILE 0 #endif +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + #endif -- cgit From ac3e41af378cc7a462b5731473909bca3c841d42 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Sep 2006 21:32:08 +0000 Subject: r18401: some of our code also relies on fprintf() handling C99 semantics. Easiest to just replace it if it doesn't. (This used to be commit 5fc756a770b6f457bf103e2a8a240ca020fd1a02) --- source4/lib/replace/snprintf.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 93285a5e57..b38d8dad34 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -1230,6 +1230,27 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, } #endif +#ifndef HAVE_C99_VSNPRINTF + int fprintf(FILE *stream, const char *fmt, ...) +{ + va_list ap; + int ret; + char *s; + + s = NULL; + va_start(ap, fmt); + ret = vasprintf(&s, fmt, ap); + va_end(ap); + + if (s) { + fwrite(s, 1, strlen(s), stream); + } + free(s); + + return ret; +} +#endif + #endif #ifndef HAVE_VASPRINTF -- cgit From a8c17f8ed3f1d5e2d4aed6d9b2af63f3e5059e51 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Sep 2006 22:25:50 +0000 Subject: r18407: test for epoll.h and select.h (This used to be commit 3ddb77c1e3dce5e05771b3fcaf86f8ae9ff21a52) --- source4/lib/replace/libreplace.m4 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index c21f59e163..4dff22b4aa 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -95,7 +95,10 @@ AC_FUNC_MEMCMP AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat getpgrp) -AC_CHECK_HEADERS(stdbool.h stddef.h) +AC_CHECK_HEADERS(stdbool.h stddef.h sys/select.h) + +AC_CHECK_HEADERS(sys/epoll.h) +AC_CHECK_FUNCS(epoll_create) AC_CHECK_TYPE(bool, [AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],, -- cgit From 566466319e3113ab872499c2ed7eb430ac2260ab Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 12 Sep 2006 07:04:12 +0000 Subject: r18418: Tru64 has a different prototype for seekdir() returning int when _OSF_SOURCE is defined metze (This used to be commit 5279656a15e42e6dd96ddfa181597c71fc993ff3) --- source4/lib/replace/repdir/repdir.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir/repdir.c b/source4/lib/replace/repdir/repdir.c index 07b9568dc1..2f8264000b 100644 --- a/source4/lib/replace/repdir/repdir.c +++ b/source4/lib/replace/repdir/repdir.c @@ -118,7 +118,11 @@ long telldir(DIR *dir) return d->seekpos + d->ofs; } +#ifdef _OSF_SOURCE +int seekdir(DIR *dir, long ofs) +#else void seekdir(DIR *dir, long ofs) +#endif { struct dir_buf *d = (struct dir_buf *)dir; d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET); @@ -127,6 +131,9 @@ void seekdir(DIR *dir, long ofs) while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) { if (readdir(dir) == NULL) break; } +#ifdef _OSF_SOURCE + return -1; +#else } void rewinddir(DIR *dir) -- cgit From 68201cc76b430c1122c0f3c665c9af649ba54311 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 12 Sep 2006 07:05:41 +0000 Subject: r18419: fix include paths of the configure tests metze (This used to be commit 8774eeb0dc8a72a9871d42bf1652ce4f7d4a29b7) --- source4/lib/replace/getpass.m4 | 7 ++- source4/lib/replace/repdir/config.m4 | 6 +- source4/lib/replace/replace.h | 6 +- source4/lib/replace/test/os2_delete.c | 110 ++++++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+), 9 deletions(-) create mode 100644 source4/lib/replace/test/os2_delete.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.m4 b/source4/lib/replace/getpass.m4 index d66be30564..3f008bbf4e 100644 --- a/source4/lib/replace/getpass.m4 +++ b/source4/lib/replace/getpass.m4 @@ -1,11 +1,12 @@ AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[ SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/smbwrapper" +CPPFLAGS="$CPPFLAGS -I$libreplacedir/" AC_TRY_COMPILE([ +#include "confdefs.h" +#define _LIBREPLACE_REPLACE_H #define REPLACE_GETPASS 1 -#define NO_CONFIG_H 1 #define main dont_declare_main -#include "${srcdir-.}/lib/replace/getpass.c" +#include "$libreplacedir/getpass.c" #undef main ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no) CPPFLAGS="$SAVE_CPPFLAGS" diff --git a/source4/lib/replace/repdir/config.m4 b/source4/lib/replace/repdir/config.m4 index b17c92e7d6..b2a20ccee6 100644 --- a/source4/lib/replace/repdir/config.m4 +++ b/source4/lib/replace/repdir/config.m4 @@ -1,5 +1,5 @@ AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[ - AC_TRY_RUN([#include "${srcdir-.}/build/tests/os2_delete.c"], + AC_TRY_RUN([#include "$libreplacedir/test/os2_delete.c"], [samba_cv_HAVE_BROKEN_READDIR=no], [samba_cv_HAVE_BROKEN_READDIR=yes], [samba_cv_HAVE_BROKEN_READDIR="assuming not"])]) @@ -7,8 +7,8 @@ AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[ if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[ AC_TRY_RUN([ -#include "${srcdir-.}/lib/replace/repdir/repdir.c" -#include "${srcdir-.}/build/tests/os2_delete.c"], +#include "$libreplacedir/repdir/repdir.c" +#include "$libreplacedir/test/os2_delete.c"], samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)]) fi diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 70fd89e3b9..0c37b60feb 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -25,8 +25,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _replace_h -#define _replace_h +#ifndef _LIBREPLACE_REPLACE_H +#define _LIBREPLACE_REPLACE_H #include "config.h" @@ -360,4 +360,4 @@ typedef int bool; #undef HAVE_MMAP #endif -#endif +#endif /* _LIBREPLACE_REPLACE_H */ diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c new file mode 100644 index 0000000000..288e4a5d8f --- /dev/null +++ b/source4/lib/replace/test/os2_delete.c @@ -0,0 +1,110 @@ +/* + test readdir/unlink pattern that OS/2 uses + tridge@samba.org July 2005 +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef REPLACE_READDIR +#include "lib/replace/repdir/repdir.h" +#endif + +#define NUM_FILES 700 +#define READDIR_SIZE 100 +#define DELETE_SIZE 4 + +#define TESTDIR "test.dir" + +#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) + +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +static void cleanup(void) +{ + /* I'm a lazy bastard */ + system("rm -rf " TESTDIR); + mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); +} + +static void create_files() +{ + int i; + for (i=0;id_name); + } + + if (i == 0) { + return 0; + } + + /* delete the first few */ + for (j=0; jd_name, ".") == 0 || FAILED("match ."); + de = readdir(d); + strcmp(de->d_name, "..") == 0 || FAILED("match .."); + + while (1) { + int n = os2_delete(d); + if (n == 0) break; + total_deleted += n; + } + closedir(d); + + printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); + + rmdir(TESTDIR) == 0 || FAILED("rmdir"); + + return 0; +} -- cgit From 26e9619c1791c1fef67926815ac0e8fec03e8e37 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 12 Sep 2006 07:25:16 +0000 Subject: r18420: fix the build... metze (This used to be commit a7ce2c6c53f1bbb2320fd8afe44ec12e504d95c9) --- source4/lib/replace/repdir/repdir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir/repdir.c b/source4/lib/replace/repdir/repdir.c index 2f8264000b..eca1ecc9d5 100644 --- a/source4/lib/replace/repdir/repdir.c +++ b/source4/lib/replace/repdir/repdir.c @@ -133,7 +133,7 @@ void seekdir(DIR *dir, long ofs) } #ifdef _OSF_SOURCE return -1; -#else +#endif } void rewinddir(DIR *dir) -- cgit From daff791c273cb3970add7abdb586745bb816db2a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 12 Sep 2006 18:45:05 +0000 Subject: r18432: ensure roken doesn't try to include both inttypes.h and stdint.h. The two conflict on irix. (This used to be commit 4dd949c80d4400c3a80571cc28f599c37c1fcf7b) --- source4/lib/replace/replace.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 0c37b60feb..a7ad58dd56 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -53,6 +53,9 @@ #ifdef HAVE_STDINT_H #include +/* force off HAVE_INTTYPES_H so that roken doesn't try to include both, + which causes a warning storm on irix */ +#undef HAVE_INTTYPES_H #elif HAVE_INTTYPES_H #include #endif -- cgit From 764f74c565e4d5472c68ac9d820b6d1b1dbd598a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 06:11:53 +0000 Subject: r18442: run the os2_delete test in the testsuite too that shows that Tru64 is broken... It doesn't have getdirent() and the the replacement code doesn't work there. tridge: do you have any idea how to fix this? metze (This used to be commit a5ebfd0ab71f4f4288697f6fd3183a440ce7506b) --- source4/lib/replace/Makefile.in | 2 +- source4/lib/replace/repdir/config.m4 | 16 +++++++++++----- source4/lib/replace/test/os2_delete.c | 10 +++++----- source4/lib/replace/test/testsuite.c | 9 ++++++++- 4 files changed, 25 insertions(+), 12 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index adaf0cd956..6940673a78 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -36,7 +36,7 @@ test: testsuite installcheck: install test -TEST_OBJS = test/testsuite.o +TEST_OBJS = test/testsuite.o test/os2_delete.o testsuite: libreplace.a $(TEST_OBJS) $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace diff --git a/source4/lib/replace/repdir/config.m4 b/source4/lib/replace/repdir/config.m4 index b2a20ccee6..cc91f2a97a 100644 --- a/source4/lib/replace/repdir/config.m4 +++ b/source4/lib/replace/repdir/config.m4 @@ -1,15 +1,21 @@ AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[ - AC_TRY_RUN([#include "$libreplacedir/test/os2_delete.c"], - [samba_cv_HAVE_BROKEN_READDIR=no], - [samba_cv_HAVE_BROKEN_READDIR=yes], - [samba_cv_HAVE_BROKEN_READDIR="assuming not"])]) + AC_TRY_RUN([ +#define test_readdir_os2_delete main +#include "$libreplacedir/test/os2_delete.c"], + [samba_cv_HAVE_BROKEN_READDIR=no], + [samba_cv_HAVE_BROKEN_READDIR=yes], + [samba_cv_HAVE_BROKEN_READDIR="assuming not"]) +]) if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[ AC_TRY_RUN([ #include "$libreplacedir/repdir/repdir.c" +#define test_readdir_os2_delete main #include "$libreplacedir/test/os2_delete.c"], - samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)]) + [samba_cv_REPLACE_READDIR=yes], + [samba_cv_REPLACE_READDIR=no]) +]) fi SMB_ENABLE(REPLACE_READDIR, NO) diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index 288e4a5d8f..c73b7e54cd 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -12,9 +12,6 @@ #include #include #include -#ifdef REPLACE_READDIR -#include "lib/replace/repdir/repdir.h" -#endif #define NUM_FILES 700 #define READDIR_SIZE 100 @@ -22,7 +19,10 @@ #define TESTDIR "test.dir" -#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) +static int test_readdir_os2_delete_ret; + +#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) +#define CHECK do { if (test_readdir_os2_delete_ret != 0) return test_readdir_os2_delete_ret; } while (0) #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -78,7 +78,7 @@ static int os2_delete(DIR *d) return j; } -int main(void) +int test_readdir_os2_delete(void) { int total_deleted = 0; DIR *d; diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 89d2ae6a88..6644fce6bd 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -229,8 +229,15 @@ static int test_opendir(void) return true; } -static int test_readdir(void) +extern int test_readdir_os2_delete(void); + +static bool test_readdir(void) { + printf("testing readdir\n"); + if (test_readdir_os2_delete() != 0) { + return false; + } + /* FIXME */ return true; } -- cgit From 9768393b3b91b8e508beae30e7e8bd942292b7f0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 06:28:14 +0000 Subject: r18443: add object files only when needed metze (This used to be commit 5fddb66def8dd29a9f8d13b4b679df26aca6cfab) --- source4/lib/replace/getpass.m4 | 1 + source4/lib/replace/libreplace.m4 | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.m4 b/source4/lib/replace/getpass.m4 index 3f008bbf4e..20d04a63f6 100644 --- a/source4/lib/replace/getpass.m4 +++ b/source4/lib/replace/getpass.m4 @@ -13,4 +13,5 @@ CPPFLAGS="$SAVE_CPPFLAGS" ]) if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced]) + LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o" fi diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 4dff22b4aa..43ed3e39a2 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -8,9 +8,11 @@ for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../librep break; fi done -LIBREPLACEOBJ="dlfcn.o getpass.o replace.o snprintf.o timegm.o" +LIBREPLACEOBJ="replace.o" AC_SUBST(LIBREPLACEOBJ) +LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o snprintf.o timegm.o" + dnl stop the C89 attempt by autoconf - if autoconf detects -Ae it will enable it dnl which conflicts with C99 on HPUX ac_cv_prog_cc_Ae=no -- cgit From cac47350c23793842cc2a5f5a0f17da739044729 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 07:35:42 +0000 Subject: r18444: return the correct value on error metze (This used to be commit d65e94fea910ff435b5cb6fe146f81b01df9abf6) --- source4/lib/replace/test/os2_delete.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index c73b7e54cd..641b8c8d93 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -22,7 +22,6 @@ static int test_readdir_os2_delete_ret; #define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) -#define CHECK do { if (test_readdir_os2_delete_ret != 0) return test_readdir_os2_delete_ret; } while (0) #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -84,6 +83,8 @@ int test_readdir_os2_delete(void) DIR *d; struct dirent *de; + test_readdir_os2_delete_ret = 0; + cleanup(); create_files(); @@ -106,5 +107,5 @@ int test_readdir_os2_delete(void) rmdir(TESTDIR) == 0 || FAILED("rmdir"); - return 0; + return test_readdir_os2_delete_ret; } -- cgit From e18547d489075d46d865ac50d0b5acd760d74709 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 08:14:10 +0000 Subject: r18445: splitout the dlfcn related tests metze (This used to be commit 8662e1481504c50a45416ae09ec19b834164e77c) --- source4/lib/replace/dlfcn.m4 | 18 ++++++++++++++++++ source4/lib/replace/libreplace.m4 | 12 ++---------- 2 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 source4/lib/replace/dlfcn.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.m4 b/source4/lib/replace/dlfcn.m4 new file mode 100644 index 0000000000..0f099f4bac --- /dev/null +++ b/source4/lib/replace/dlfcn.m4 @@ -0,0 +1,18 @@ +dnl dummies provided by dlfcn.c if not available +save_LIBS="$LIBS" +LIBS="" + +AC_SEARCH_LIBS(dlopen, dl) + +AC_CHECK_HEADERS(dlfcn.h) + +libreplace_dlfcn=no +AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_dlfcn=yes]) + +if test x"${libreplace_dlfcn}" = x"yes";then + LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o" +fi + +LIBDL="$LIBS" +AC_SUBST(LIBDL) +LIBS="$save_LIBS" diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 43ed3e39a2..202a60ff35 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -11,7 +11,7 @@ done LIBREPLACEOBJ="replace.o" AC_SUBST(LIBREPLACEOBJ) -LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o snprintf.o timegm.o" +LIBREPLACEOBJ="${LIBREPLACEOBJ} snprintf.o timegm.o" dnl stop the C89 attempt by autoconf - if autoconf detects -Ae it will enable it dnl which conflicts with C99 on HPUX @@ -235,19 +235,11 @@ if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf]) fi -dnl dummies provided by dlfcn.c if not available -save_LIBS="$LIBS" -LIBS="" -AC_SEARCH_LIBS(dlopen, dl) -AC_CHECK_HEADERS(dlfcn.h) -AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose) -LIBDL="$LIBS" -AC_SUBST(LIBDL) -LIBS="$save_LIBS" AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) +m4_include(dlfcn.m4) m4_include(getpass.m4) m4_include(system/config.m4) -- cgit From 0584c108dbf6072d28b97ca3dcd70ef25ff4359c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 09:47:41 +0000 Subject: r18450: - autogenerate the OBJ_FILES for LIBREPLACE - remove samba specific stuff from libreplace - and include the readdir replacement stuff in the standalone builds metze (This used to be commit 3cac61152ef9a32313d7f7e5d38651f03a31f251) --- source4/lib/replace/config.mk | 29 ----------------------------- source4/lib/replace/configure.ac | 12 ++++-------- source4/lib/replace/libreplace.m4 | 16 +++++++++------- source4/lib/replace/repdir/config.m4 | 29 +++++++++++++++++------------ source4/lib/replace/samba.m4 | 23 +++++++++++++++++++++++ 5 files changed, 53 insertions(+), 56 deletions(-) delete mode 100644 source4/lib/replace/config.mk create mode 100644 source4/lib/replace/samba.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk deleted file mode 100644 index 1e940b0a71..0000000000 --- a/source4/lib/replace/config.mk +++ /dev/null @@ -1,29 +0,0 @@ -############################## -# Start SUBSYSTEM REPLACE_READDIR -[SUBSYSTEM::REPLACE_READDIR] -OBJ_FILES = \ - repdir/repdir.o -# End SUBSYSTEM REPLACE_READDIR -############################## - -############################## -# Start SUBSYSTEM LIBREPLACE -[SUBSYSTEM::LIBREPLACE] -CFLAGS = -Ilib/replace -OBJ_FILES = replace.o \ - snprintf.o \ - dlfcn.o \ - getpass.o \ - timegm.o -PUBLIC_DEPENDENCIES = REPLACE_READDIR DL -# End SUBSYSTEM LIBREPLACE -############################## - -[SUBSYSTEM::LIBREPLACE_HOSTCC] -CFLAGS = -Ilib/replace -OBJ_FILES = replace.ho \ - snprintf.ho \ - dlfcn.ho \ - getpass.ho \ - timegm.ho - diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index aaf404e373..b506b791eb 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -1,16 +1,12 @@ -AC_DEFUN([SMB_EXT_LIB], [echo -n ""]) -AC_DEFUN([SMB_ENABLE], [echo -n ""]) - AC_PREREQ(2.50) -AC_INIT(dlfcn.c) -AC_CONFIG_SRCDIR([dlfcn.c]) +AC_INIT(replace.c) +AC_CONFIG_SRCDIR([replace.c]) AC_CONFIG_HEADER(config.h) +m4_include(libreplace.m4) + if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings" fi -m4_include(libreplace.m4) -m4_include(win32/config.m4) -m4_include(repdir/config.m4) AC_OUTPUT(Makefile) diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 202a60ff35..074dd1a1b4 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -236,13 +236,6 @@ if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then fi -AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, - [AC_MSG_ERROR([Required function not found])]) - -m4_include(dlfcn.m4) -m4_include(getpass.m4) -m4_include(system/config.m4) - LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes, c99_struct_initialization=no) @@ -344,3 +337,12 @@ AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [ if test x"$samba_cv_volatile" = x"yes"; then AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile]) fi + +m4_include(dlfcn.m4) +m4_include(getpass.m4) +m4_include(system/config.m4) +m4_include(win32/config.m4) +m4_include(repdir/config.m4) + +AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, + [AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/repdir/config.m4 b/source4/lib/replace/repdir/config.m4 index cc91f2a97a..eda8f42ba9 100644 --- a/source4/lib/replace/repdir/config.m4 +++ b/source4/lib/replace/repdir/config.m4 @@ -1,25 +1,30 @@ -AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[ +AC_CACHE_CHECK([for broken readdir],libreplace_READDIR_NEEDED,[ AC_TRY_RUN([ #define test_readdir_os2_delete main +#error #include "$libreplacedir/test/os2_delete.c"], - [samba_cv_HAVE_BROKEN_READDIR=no], - [samba_cv_HAVE_BROKEN_READDIR=yes], - [samba_cv_HAVE_BROKEN_READDIR="assuming not"]) + [libreplace_READDIR_NEEDED=no], + [libreplace_READDIR_NEEDED=yes], + [libreplace_READDIR_NEEDED="assuming not"]) ]) -if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then -AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[ +# +# try to replace with getdents() if needed +# +if test x"$libreplace_READDIR_NEEDED" = x"yes"; then +AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_READDIR_GETDENTS,[ AC_TRY_RUN([ +#include "confdefs.h" #include "$libreplacedir/repdir/repdir.c" #define test_readdir_os2_delete main #include "$libreplacedir/test/os2_delete.c"], - [samba_cv_REPLACE_READDIR=yes], - [samba_cv_REPLACE_READDIR=no]) + [libreplace_READDIR_GETDENTS=yes], + [libreplace_READDIR_GETDENTS=no]) ]) fi - -SMB_ENABLE(REPLACE_READDIR, NO) -if test x"$samba_cv_REPLACE_READDIR" = x"yes"; then +if test x"$libreplace_READDIR_GETDENTS" = x"yes"; then AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) - SMB_ENABLE(REPLACE_READDIR, YES) + AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()]) + LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir/repdir.o" + libreplace_READDIR_NEEDED=no fi diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4 new file mode 100644 index 0000000000..c6c5e63b7f --- /dev/null +++ b/source4/lib/replace/samba.m4 @@ -0,0 +1,23 @@ +m4_include(lib/replace/libreplace.m4) + +SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}]) +SMB_ENABLE(LIBREPLACE_EXT) + +LIBREPLACE_DIR=`echo ${libreplacedir} |sed -e 's/^\.\///g'` + +LIBREPLACE_OBJS="" +for obj in ${LIBREPLACEOBJ}; do + LIBREPLACE_OBJS="${LIBREPLACE_OBJS} ${LIBREPLACE_DIR}/${obj}" +done + +SMB_SUBSYSTEM(LIBREPLACE, + [${LIBREPLACE_OBJS}], + [LIBREPLACE_EXT], + [-Ilib/replace]) + +LIBREPLACE_HOSTCC_OBJS=`echo ${LIBREPLACE_OBJS} |sed -e 's/\.o/\.ho/g'` + +SMB_SUBSYSTEM(LIBREPLACE_HOSTCC, + [${LIBREPLACE_HOSTCC_OBJS}], + [], + [-Ilib/replace]) -- cgit From c564344766c1e888c0ab3f866ea4b3318135d0e5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 09:56:21 +0000 Subject: r18451: move repdir/ into the top dir metze (This used to be commit a564194817d9b78e353abb6bf0548b2dd9eb130b) --- source4/lib/replace/libreplace.m4 | 2 +- source4/lib/replace/repdir.m4 | 30 +++++++ source4/lib/replace/repdir/config.m4 | 30 ------- source4/lib/replace/repdir/repdir.c | 162 ---------------------------------- source4/lib/replace/repdir_getdents.c | 162 ++++++++++++++++++++++++++++++++++ 5 files changed, 193 insertions(+), 193 deletions(-) create mode 100644 source4/lib/replace/repdir.m4 delete mode 100644 source4/lib/replace/repdir/config.m4 delete mode 100644 source4/lib/replace/repdir/repdir.c create mode 100644 source4/lib/replace/repdir_getdents.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 074dd1a1b4..febee6409e 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -342,7 +342,7 @@ m4_include(dlfcn.m4) m4_include(getpass.m4) m4_include(system/config.m4) m4_include(win32/config.m4) -m4_include(repdir/config.m4) +m4_include(repdir.m4) AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/repdir.m4 b/source4/lib/replace/repdir.m4 new file mode 100644 index 0000000000..d15e4cb7af --- /dev/null +++ b/source4/lib/replace/repdir.m4 @@ -0,0 +1,30 @@ +AC_CACHE_CHECK([for broken readdir],libreplace_READDIR_NEEDED,[ + AC_TRY_RUN([ +#define test_readdir_os2_delete main +#error +#include "$libreplacedir/test/os2_delete.c"], + [libreplace_READDIR_NEEDED=no], + [libreplace_READDIR_NEEDED=yes], + [libreplace_READDIR_NEEDED="assuming not"]) +]) + +# +# try to replace with getdents() if needed +# +if test x"$libreplace_READDIR_NEEDED" = x"yes"; then +AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_READDIR_GETDENTS,[ + AC_TRY_RUN([ +#include "confdefs.h" +#include "$libreplacedir/repdir_getdents.c" +#define test_readdir_os2_delete main +#include "$libreplacedir/test/os2_delete.c"], + [libreplace_READDIR_GETDENTS=yes], + [libreplace_READDIR_GETDENTS=no]) +]) +fi +if test x"$libreplace_READDIR_GETDENTS" = x"yes"; then + AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) + AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()]) + LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdents.o" + libreplace_READDIR_NEEDED=no +fi diff --git a/source4/lib/replace/repdir/config.m4 b/source4/lib/replace/repdir/config.m4 deleted file mode 100644 index eda8f42ba9..0000000000 --- a/source4/lib/replace/repdir/config.m4 +++ /dev/null @@ -1,30 +0,0 @@ -AC_CACHE_CHECK([for broken readdir],libreplace_READDIR_NEEDED,[ - AC_TRY_RUN([ -#define test_readdir_os2_delete main -#error -#include "$libreplacedir/test/os2_delete.c"], - [libreplace_READDIR_NEEDED=no], - [libreplace_READDIR_NEEDED=yes], - [libreplace_READDIR_NEEDED="assuming not"]) -]) - -# -# try to replace with getdents() if needed -# -if test x"$libreplace_READDIR_NEEDED" = x"yes"; then -AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_READDIR_GETDENTS,[ - AC_TRY_RUN([ -#include "confdefs.h" -#include "$libreplacedir/repdir/repdir.c" -#define test_readdir_os2_delete main -#include "$libreplacedir/test/os2_delete.c"], - [libreplace_READDIR_GETDENTS=yes], - [libreplace_READDIR_GETDENTS=no]) -]) -fi -if test x"$libreplace_READDIR_GETDENTS" = x"yes"; then - AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) - AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()]) - LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir/repdir.o" - libreplace_READDIR_NEEDED=no -fi diff --git a/source4/lib/replace/repdir/repdir.c b/source4/lib/replace/repdir/repdir.c deleted file mode 100644 index eca1ecc9d5..0000000000 --- a/source4/lib/replace/repdir/repdir.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Copyright (C) Andrew Tridgell 2005 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - a replacement for opendir/readdir/telldir/seekdir/closedir for BSD systems - - This is needed because the existing directory handling in FreeBSD - and OpenBSD (and possibly NetBSD) doesn't correctly handle unlink() - on files in a directory where telldir() has been used. On a block - boundary it will occasionally miss a file when seekdir() is used to - return to a position previously recorded with telldir(). - - This also fixes a severe performance and memory usage problem with - telldir() on BSD systems. Each call to telldir() in BSD adds an - entry to a linked list, and those entries are cleaned up on - closedir(). This means with a large directory closedir() can take an - arbitrary amount of time, causing network timeouts as millions of - telldir() entries are freed - - Note! This replacement code is not portable. It relies on getdents() - always leaving the file descriptor at a seek offset that is a - multiple of DIR_BUF_SIZE. If the code detects that this doesn't - happen then it will abort(). It also does not handle directories - with offsets larger than can be stored in a long, - - This code is available under other free software licenses as - well. Contact the author. -*/ - -#include -#include -#include -#include -#include -#include -#include - -#define DIR_BUF_BITS 9 -#define DIR_BUF_SIZE (1<fd = open(dname, O_RDONLY); - if (d->fd == -1) { - free(d); - return NULL; - } - d->ofs = 0; - d->seekpos = 0; - d->nbytes = 0; - return (DIR *)d; -} - -struct dirent *readdir(DIR *dir) -{ - struct dir_buf *d = (struct dir_buf *)dir; - struct dirent *de; - - if (d->ofs >= d->nbytes) { - d->seekpos = lseek(d->fd, 0, SEEK_CUR); - d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE); - d->ofs = 0; - } - if (d->ofs >= d->nbytes) { - return NULL; - } - de = (struct dirent *)&d->buf[d->ofs]; - d->ofs += de->d_reclen; - return de; -} - -long telldir(DIR *dir) -{ - struct dir_buf *d = (struct dir_buf *)dir; - if (d->ofs >= d->nbytes) { - d->seekpos = lseek(d->fd, 0, SEEK_CUR); - d->ofs = 0; - d->nbytes = 0; - } - /* this relies on seekpos always being a multiple of - DIR_BUF_SIZE. Is that always true on BSD systems? */ - if (d->seekpos & (DIR_BUF_SIZE-1)) { - abort(); - } - return d->seekpos + d->ofs; -} - -#ifdef _OSF_SOURCE -int seekdir(DIR *dir, long ofs) -#else -void seekdir(DIR *dir, long ofs) -#endif -{ - struct dir_buf *d = (struct dir_buf *)dir; - d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET); - d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE); - d->ofs = 0; - while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) { - if (readdir(dir) == NULL) break; - } -#ifdef _OSF_SOURCE - return -1; -#endif -} - -void rewinddir(DIR *dir) -{ - seekdir(dir, 0); -} - -int closedir(DIR *dir) -{ - struct dir_buf *d = (struct dir_buf *)dir; - int r = close(d->fd); - if (r != 0) { - return r; - } - free(d); - return 0; -} - -#ifndef dirfd -/* darn, this is a macro on some systems. */ -int dirfd(DIR *dir) -{ - struct dir_buf *d = (struct dir_buf *)dir; - return d->fd; -} -#endif diff --git a/source4/lib/replace/repdir_getdents.c b/source4/lib/replace/repdir_getdents.c new file mode 100644 index 0000000000..eca1ecc9d5 --- /dev/null +++ b/source4/lib/replace/repdir_getdents.c @@ -0,0 +1,162 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (C) Andrew Tridgell 2005 + + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/* + a replacement for opendir/readdir/telldir/seekdir/closedir for BSD systems + + This is needed because the existing directory handling in FreeBSD + and OpenBSD (and possibly NetBSD) doesn't correctly handle unlink() + on files in a directory where telldir() has been used. On a block + boundary it will occasionally miss a file when seekdir() is used to + return to a position previously recorded with telldir(). + + This also fixes a severe performance and memory usage problem with + telldir() on BSD systems. Each call to telldir() in BSD adds an + entry to a linked list, and those entries are cleaned up on + closedir(). This means with a large directory closedir() can take an + arbitrary amount of time, causing network timeouts as millions of + telldir() entries are freed + + Note! This replacement code is not portable. It relies on getdents() + always leaving the file descriptor at a seek offset that is a + multiple of DIR_BUF_SIZE. If the code detects that this doesn't + happen then it will abort(). It also does not handle directories + with offsets larger than can be stored in a long, + + This code is available under other free software licenses as + well. Contact the author. +*/ + +#include +#include +#include +#include +#include +#include +#include + +#define DIR_BUF_BITS 9 +#define DIR_BUF_SIZE (1<fd = open(dname, O_RDONLY); + if (d->fd == -1) { + free(d); + return NULL; + } + d->ofs = 0; + d->seekpos = 0; + d->nbytes = 0; + return (DIR *)d; +} + +struct dirent *readdir(DIR *dir) +{ + struct dir_buf *d = (struct dir_buf *)dir; + struct dirent *de; + + if (d->ofs >= d->nbytes) { + d->seekpos = lseek(d->fd, 0, SEEK_CUR); + d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE); + d->ofs = 0; + } + if (d->ofs >= d->nbytes) { + return NULL; + } + de = (struct dirent *)&d->buf[d->ofs]; + d->ofs += de->d_reclen; + return de; +} + +long telldir(DIR *dir) +{ + struct dir_buf *d = (struct dir_buf *)dir; + if (d->ofs >= d->nbytes) { + d->seekpos = lseek(d->fd, 0, SEEK_CUR); + d->ofs = 0; + d->nbytes = 0; + } + /* this relies on seekpos always being a multiple of + DIR_BUF_SIZE. Is that always true on BSD systems? */ + if (d->seekpos & (DIR_BUF_SIZE-1)) { + abort(); + } + return d->seekpos + d->ofs; +} + +#ifdef _OSF_SOURCE +int seekdir(DIR *dir, long ofs) +#else +void seekdir(DIR *dir, long ofs) +#endif +{ + struct dir_buf *d = (struct dir_buf *)dir; + d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET); + d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE); + d->ofs = 0; + while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) { + if (readdir(dir) == NULL) break; + } +#ifdef _OSF_SOURCE + return -1; +#endif +} + +void rewinddir(DIR *dir) +{ + seekdir(dir, 0); +} + +int closedir(DIR *dir) +{ + struct dir_buf *d = (struct dir_buf *)dir; + int r = close(d->fd); + if (r != 0) { + return r; + } + free(d); + return 0; +} + +#ifndef dirfd +/* darn, this is a macro on some systems. */ +int dirfd(DIR *dir) +{ + struct dir_buf *d = (struct dir_buf *)dir; + return d->fd; +} +#endif -- cgit From dfef2dc22fd8188b5ac577c7c87ab6f58ebb6440 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 10:00:45 +0000 Subject: r18452: add configure test for a getdirentries() based replacement for broken readdir() Tru64 need this, linux also has getdirentries() but the native readdir() works but it means we can write the code on linux and when it works it may work on Tru64 too. tridge: can you try to implement this? metze (This used to be commit dd791d255ca61159b38a59b89f954a61fc5e9cf6) --- source4/lib/replace/repdir.m4 | 25 +++++++++++++++++++++++++ source4/lib/replace/repdir_getdirentries.c | 1 + 2 files changed, 26 insertions(+) create mode 100644 source4/lib/replace/repdir_getdirentries.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir.m4 b/source4/lib/replace/repdir.m4 index d15e4cb7af..a2f7bfa009 100644 --- a/source4/lib/replace/repdir.m4 +++ b/source4/lib/replace/repdir.m4 @@ -28,3 +28,28 @@ if test x"$libreplace_READDIR_GETDENTS" = x"yes"; then LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdents.o" libreplace_READDIR_NEEDED=no fi + +# +# try to replace with getdirentries() if needed +# +if test x"$libreplace_READDIR_NEEDED" = x"yes"; then +AC_CACHE_CHECK([for replacing readdir using getdirentries()],libreplace_READDIR_GETDIRENTRIES,[ + AC_TRY_RUN([ +#include "confdefs.h" +#include "$libreplacedir/repdir_getdirentries.c" +#define test_readdir_os2_delete main +#include "$libreplacedir/test/os2_delete.c"], + [libreplace_READDIR_GETDIRENTRIES=yes], + [libreplace_READDIR_GETDIRENTRIES=no]) +]) +fi +if test x"$libreplace_READDIR_GETDIRENTRIES" = x"yes"; then + AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) + AC_DEFINE(REPLACE_READDIR_GETDIRENTRIES,1,[replace readdir using getdirentries()]) + LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdirentries.o" + libreplace_READDIR_NEEDED=no +fi + +if test x"$libreplace_READDIR_NEEDED" = x"yes"; then + AC_MSG_WARN([the provides readdir() is broken]) +fi diff --git a/source4/lib/replace/repdir_getdirentries.c b/source4/lib/replace/repdir_getdirentries.c new file mode 100644 index 0000000000..ff93ed4ea3 --- /dev/null +++ b/source4/lib/replace/repdir_getdirentries.c @@ -0,0 +1 @@ +#error "the readdir() replacement using getdirentried() isn't implemented yet" -- cgit From b270dd3fd604b15147fb33491fff39ff718db959 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 10:04:46 +0000 Subject: r18454: this was just for debugging... metze (This used to be commit f9f14a94297d72af13b043db99fa892e5e3dcb46) --- source4/lib/replace/repdir.m4 | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir.m4 b/source4/lib/replace/repdir.m4 index a2f7bfa009..1e23306f28 100644 --- a/source4/lib/replace/repdir.m4 +++ b/source4/lib/replace/repdir.m4 @@ -1,7 +1,6 @@ AC_CACHE_CHECK([for broken readdir],libreplace_READDIR_NEEDED,[ AC_TRY_RUN([ #define test_readdir_os2_delete main -#error #include "$libreplacedir/test/os2_delete.c"], [libreplace_READDIR_NEEDED=no], [libreplace_READDIR_NEEDED=yes], -- cgit From bf071a91aabe50a26fb8a63e05a5e264b21b66ab Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 10:10:20 +0000 Subject: r18455: check if getdents() and getdirentries() are available. (only for the nicer configure output) metze (This used to be commit d53eb6bd10903d696c5ed9aad3bca3ddf35b2b51) --- source4/lib/replace/repdir.m4 | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir.m4 b/source4/lib/replace/repdir.m4 index 1e23306f28..e2f94263e8 100644 --- a/source4/lib/replace/repdir.m4 +++ b/source4/lib/replace/repdir.m4 @@ -11,6 +11,7 @@ AC_CACHE_CHECK([for broken readdir],libreplace_READDIR_NEEDED,[ # try to replace with getdents() if needed # if test x"$libreplace_READDIR_NEEDED" = x"yes"; then +AC_CHECK_FUNCS(getdents) AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_READDIR_GETDENTS,[ AC_TRY_RUN([ #include "confdefs.h" @@ -32,6 +33,7 @@ fi # try to replace with getdirentries() if needed # if test x"$libreplace_READDIR_NEEDED" = x"yes"; then +AC_CHECK_FUNCS(getdirentries) AC_CACHE_CHECK([for replacing readdir using getdirentries()],libreplace_READDIR_GETDIRENTRIES,[ AC_TRY_RUN([ #include "confdefs.h" -- cgit From 2c3dc50953341c4f59cb46aed05be358dd9c3e81 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 10:12:03 +0000 Subject: r18456: Tru64 doesn't have getdents() so we don't need this ifdef's... metze (This used to be commit 5af86eb3f07e26aead67ab0dd46576e0aefe8eb4) --- source4/lib/replace/repdir_getdents.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir_getdents.c b/source4/lib/replace/repdir_getdents.c index eca1ecc9d5..07b9568dc1 100644 --- a/source4/lib/replace/repdir_getdents.c +++ b/source4/lib/replace/repdir_getdents.c @@ -118,11 +118,7 @@ long telldir(DIR *dir) return d->seekpos + d->ofs; } -#ifdef _OSF_SOURCE -int seekdir(DIR *dir, long ofs) -#else void seekdir(DIR *dir, long ofs) -#endif { struct dir_buf *d = (struct dir_buf *)dir; d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET); @@ -131,9 +127,6 @@ void seekdir(DIR *dir, long ofs) while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) { if (readdir(dir) == NULL) break; } -#ifdef _OSF_SOURCE - return -1; -#endif } void rewinddir(DIR *dir) -- cgit From c706319c8f0fe0af828da5f75c2dc673cecadf36 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 10:13:01 +0000 Subject: r18458: move wins32 stuff to the top dir metze (This used to be commit 521e94f2693eab9053d9e3f1bbc56cdf2e0adbcd) --- source4/lib/replace/libreplace.m4 | 5 +- source4/lib/replace/replace.h | 2 +- source4/lib/replace/win32.m4 | 20 +++++ source4/lib/replace/win32/config.m4 | 20 ----- source4/lib/replace/win32/replace.h | 159 ------------------------------------ source4/lib/replace/win32_replace.h | 159 ++++++++++++++++++++++++++++++++++++ 6 files changed, 183 insertions(+), 182 deletions(-) create mode 100644 source4/lib/replace/win32.m4 delete mode 100644 source4/lib/replace/win32/config.m4 delete mode 100644 source4/lib/replace/win32/replace.h create mode 100644 source4/lib/replace/win32_replace.h (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index febee6409e..3a40b39da2 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -340,9 +340,10 @@ fi m4_include(dlfcn.m4) m4_include(getpass.m4) -m4_include(system/config.m4) -m4_include(win32/config.m4) +m4_include(win32.m4) m4_include(repdir.m4) +m4_include(system/config.m4) + AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index a7ad58dd56..e35f1da44e 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -40,7 +40,7 @@ #include #if defined(_MSC_VER) || defined(__MINGW32__) -#include "lib/replace/win32/replace.h" +#include "win32_replace.h" #endif #ifdef __COMPAR_FN_T diff --git a/source4/lib/replace/win32.m4 b/source4/lib/replace/win32.m4 new file mode 100644 index 0000000000..9ac84cdf2a --- /dev/null +++ b/source4/lib/replace/win32.m4 @@ -0,0 +1,20 @@ +AC_CHECK_HEADERS(direct.h windows.h winsock2.h ws2tcpip.h) + +####################################### +# Check for mkdir mode +AC_CACHE_CHECK( [whether mkdir supports mode], ac_mkdir_has_mode, + AC_TRY_COMPILE([ + #include + #ifdef HAVE_DIRECT_H + #include + #endif],[ + mkdir("foo",0777); + return 0; + ], + ac_mkdir_has_mode="yes", + ac_mkdir_has_mode="no") ) + +if test "$ac_mkdir_has_mode" = "yes" +then + AC_DEFINE(HAVE_MKDIR_MODE, 1, [Define if target mkdir supports mode option]) +fi diff --git a/source4/lib/replace/win32/config.m4 b/source4/lib/replace/win32/config.m4 deleted file mode 100644 index 9ac84cdf2a..0000000000 --- a/source4/lib/replace/win32/config.m4 +++ /dev/null @@ -1,20 +0,0 @@ -AC_CHECK_HEADERS(direct.h windows.h winsock2.h ws2tcpip.h) - -####################################### -# Check for mkdir mode -AC_CACHE_CHECK( [whether mkdir supports mode], ac_mkdir_has_mode, - AC_TRY_COMPILE([ - #include - #ifdef HAVE_DIRECT_H - #include - #endif],[ - mkdir("foo",0777); - return 0; - ], - ac_mkdir_has_mode="yes", - ac_mkdir_has_mode="no") ) - -if test "$ac_mkdir_has_mode" = "yes" -then - AC_DEFINE(HAVE_MKDIR_MODE, 1, [Define if target mkdir supports mode option]) -fi diff --git a/source4/lib/replace/win32/replace.h b/source4/lib/replace/win32/replace.h deleted file mode 100644 index 9901e72f6e..0000000000 --- a/source4/lib/replace/win32/replace.h +++ /dev/null @@ -1,159 +0,0 @@ -#ifndef _WIN32_REPLACE_H -#define _WIN32_REPLACE_H - -#ifdef HAVE_WINSOCK2_H -#include -#endif - -#ifdef HAVE_WS2TCPIP_H -#include -#endif - -#ifdef HAVE_WINDOWS_H -#include -#endif - -/* Map BSD Socket errorcodes to the WSA errorcodes (if possible) */ - -#define EAFNOSUPPORT WSAEAFNOSUPPORT -#define ECONNREFUSED WSAECONNREFUSED -#define EINPROGRESS WSAEINPROGRESS -#define EMSGSIZE WSAEMSGSIZE -#define ENOBUFS WSAENOBUFS -#define ENOTSOCK WSAENOTSOCK -#define ENETUNREACH WSAENETUNREACH -#define ENOPROTOOPT WSAENOPROTOOPT -#define ENOTCONN WSAENOTCONN -#define ENOTSUP 134 - -/* We undefine the following constants due to conflicts with the w32api headers - * and the Windows Platform SDK/DDK. - */ - -#undef interface - -#undef ERROR_INVALID_PARAMETER -#undef ERROR_INSUFFICIENT_BUFFER -#undef ERROR_INVALID_DATATYPE - -#undef FILE_GENERIC_READ -#undef FILE_GENERIC_WRITE -#undef FILE_GENERIC_EXECUTE -#undef FILE_ATTRIBUTE_READONLY -#undef FILE_ATTRIBUTE_HIDDEN -#undef FILE_ATTRIBUTE_SYSTEM -#undef FILE_ATTRIBUTE_DIRECTORY -#undef FILE_ATTRIBUTE_ARCHIVE -#undef FILE_ATTRIBUTE_DEVICE -#undef FILE_ATTRIBUTE_NORMAL -#undef FILE_ATTRIBUTE_TEMPORARY -#undef FILE_ATTRIBUTE_REPARSE_POINT -#undef FILE_ATTRIBUTE_COMPRESSED -#undef FILE_ATTRIBUTE_OFFLINE -#undef FILE_ATTRIBUTE_ENCRYPTED -#undef FILE_FLAG_WRITE_THROUGH -#undef FILE_FLAG_NO_BUFFERING -#undef FILE_FLAG_RANDOM_ACCESS -#undef FILE_FLAG_SEQUENTIAL_SCAN -#undef FILE_FLAG_DELETE_ON_CLOSE -#undef FILE_FLAG_BACKUP_SEMANTICS -#undef FILE_FLAG_POSIX_SEMANTICS -#undef FILE_TYPE_DISK -#undef FILE_TYPE_UNKNOWN -#undef FILE_CASE_SENSITIVE_SEARCH -#undef FILE_CASE_PRESERVED_NAMES -#undef FILE_UNICODE_ON_DISK -#undef FILE_PERSISTENT_ACLS -#undef FILE_FILE_COMPRESSION -#undef FILE_VOLUME_QUOTAS -#undef FILE_VOLUME_IS_COMPRESSED -#undef FILE_NOTIFY_CHANGE_FILE_NAME -#undef FILE_NOTIFY_CHANGE_DIR_NAME -#undef FILE_NOTIFY_CHANGE_ATTRIBUTES -#undef FILE_NOTIFY_CHANGE_SIZE -#undef FILE_NOTIFY_CHANGE_LAST_WRITE -#undef FILE_NOTIFY_CHANGE_LAST_ACCESS -#undef FILE_NOTIFY_CHANGE_CREATION -#undef FILE_NOTIFY_CHANGE_EA -#undef FILE_NOTIFY_CHANGE_SECURITY -#undef FILE_NOTIFY_CHANGE_STREAM_NAME -#undef FILE_NOTIFY_CHANGE_STREAM_SIZE -#undef FILE_NOTIFY_CHANGE_STREAM_WRITE -#undef FILE_NOTIFY_CHANGE_NAME - -#undef PRINTER_ATTRIBUTE_QUEUED -#undef PRINTER_ATTRIBUTE_DIRECT -#undef PRINTER_ATTRIBUTE_DEFAULT -#undef PRINTER_ATTRIBUTE_SHARED -#undef PRINTER_ATTRIBUTE_NETWORK -#undef PRINTER_ATTRIBUTE_HIDDEN -#undef PRINTER_ATTRIBUTE_LOCAL -#undef PRINTER_ATTRIBUTE_ENABLE_DEVQ -#undef PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS -#undef PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST -#undef PRINTER_ATTRIBUTE_WORK_OFFLINE -#undef PRINTER_ATTRIBUTE_ENABLE_BIDI -#undef PRINTER_ATTRIBUTE_RAW_ONLY -#undef PRINTER_ATTRIBUTE_PUBLISHED -#undef PRINTER_ENUM_DEFAULT -#undef PRINTER_ENUM_LOCAL -#undef PRINTER_ENUM_CONNECTIONS -#undef PRINTER_ENUM_FAVORITE -#undef PRINTER_ENUM_NAME -#undef PRINTER_ENUM_REMOTE -#undef PRINTER_ENUM_SHARED -#undef PRINTER_ENUM_NETWORK -#undef PRINTER_ENUM_EXPAND -#undef PRINTER_ENUM_CONTAINER -#undef PRINTER_ENUM_ICON1 -#undef PRINTER_ENUM_ICON2 -#undef PRINTER_ENUM_ICON3 -#undef PRINTER_ENUM_ICON4 -#undef PRINTER_ENUM_ICON5 -#undef PRINTER_ENUM_ICON6 -#undef PRINTER_ENUM_ICON7 -#undef PRINTER_ENUM_ICON8 -#undef PRINTER_STATUS_PAUSED -#undef PRINTER_STATUS_ERROR -#undef PRINTER_STATUS_PENDING_DELETION -#undef PRINTER_STATUS_PAPER_JAM -#undef PRINTER_STATUS_PAPER_OUT -#undef PRINTER_STATUS_MANUAL_FEED -#undef PRINTER_STATUS_PAPER_PROBLEM -#undef PRINTER_STATUS_OFFLINE -#undef PRINTER_STATUS_IO_ACTIVE -#undef PRINTER_STATUS_BUSY -#undef PRINTER_STATUS_PRINTING -#undef PRINTER_STATUS_OUTPUT_BIN_FULL -#undef PRINTER_STATUS_NOT_AVAILABLE -#undef PRINTER_STATUS_WAITING -#undef PRINTER_STATUS_PROCESSING -#undef PRINTER_STATUS_INITIALIZING -#undef PRINTER_STATUS_WARMING_UP -#undef PRINTER_STATUS_TONER_LOW -#undef PRINTER_STATUS_NO_TONER -#undef PRINTER_STATUS_PAGE_PUNT -#undef PRINTER_STATUS_USER_INTERVENTION -#undef PRINTER_STATUS_OUT_OF_MEMORY -#undef PRINTER_STATUS_DOOR_OPEN -#undef PRINTER_STATUS_SERVER_UNKNOWN -#undef PRINTER_STATUS_POWER_SAVE - -#undef DWORD -#undef HKEY_CLASSES_ROOT -#undef HKEY_CURRENT_USER -#undef HKEY_LOCAL_MACHINE -#undef HKEY_USERS -#undef HKEY_PERFORMANCE_DATA -#undef HKEY_CURRENT_CONFIG -#undef HKEY_DYN_DATA -#undef REG_DWORD -#undef REG_QWORD - -#undef SERVICE_STATE_ALL - -#undef SE_GROUP_MANDATORY -#undef SE_GROUP_ENABLED_BY_DEFAULT -#undef SE_GROUP_ENABLED - -#endif /* _WIN32_REPLACE_H */ diff --git a/source4/lib/replace/win32_replace.h b/source4/lib/replace/win32_replace.h new file mode 100644 index 0000000000..9901e72f6e --- /dev/null +++ b/source4/lib/replace/win32_replace.h @@ -0,0 +1,159 @@ +#ifndef _WIN32_REPLACE_H +#define _WIN32_REPLACE_H + +#ifdef HAVE_WINSOCK2_H +#include +#endif + +#ifdef HAVE_WS2TCPIP_H +#include +#endif + +#ifdef HAVE_WINDOWS_H +#include +#endif + +/* Map BSD Socket errorcodes to the WSA errorcodes (if possible) */ + +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#define ECONNREFUSED WSAECONNREFUSED +#define EINPROGRESS WSAEINPROGRESS +#define EMSGSIZE WSAEMSGSIZE +#define ENOBUFS WSAENOBUFS +#define ENOTSOCK WSAENOTSOCK +#define ENETUNREACH WSAENETUNREACH +#define ENOPROTOOPT WSAENOPROTOOPT +#define ENOTCONN WSAENOTCONN +#define ENOTSUP 134 + +/* We undefine the following constants due to conflicts with the w32api headers + * and the Windows Platform SDK/DDK. + */ + +#undef interface + +#undef ERROR_INVALID_PARAMETER +#undef ERROR_INSUFFICIENT_BUFFER +#undef ERROR_INVALID_DATATYPE + +#undef FILE_GENERIC_READ +#undef FILE_GENERIC_WRITE +#undef FILE_GENERIC_EXECUTE +#undef FILE_ATTRIBUTE_READONLY +#undef FILE_ATTRIBUTE_HIDDEN +#undef FILE_ATTRIBUTE_SYSTEM +#undef FILE_ATTRIBUTE_DIRECTORY +#undef FILE_ATTRIBUTE_ARCHIVE +#undef FILE_ATTRIBUTE_DEVICE +#undef FILE_ATTRIBUTE_NORMAL +#undef FILE_ATTRIBUTE_TEMPORARY +#undef FILE_ATTRIBUTE_REPARSE_POINT +#undef FILE_ATTRIBUTE_COMPRESSED +#undef FILE_ATTRIBUTE_OFFLINE +#undef FILE_ATTRIBUTE_ENCRYPTED +#undef FILE_FLAG_WRITE_THROUGH +#undef FILE_FLAG_NO_BUFFERING +#undef FILE_FLAG_RANDOM_ACCESS +#undef FILE_FLAG_SEQUENTIAL_SCAN +#undef FILE_FLAG_DELETE_ON_CLOSE +#undef FILE_FLAG_BACKUP_SEMANTICS +#undef FILE_FLAG_POSIX_SEMANTICS +#undef FILE_TYPE_DISK +#undef FILE_TYPE_UNKNOWN +#undef FILE_CASE_SENSITIVE_SEARCH +#undef FILE_CASE_PRESERVED_NAMES +#undef FILE_UNICODE_ON_DISK +#undef FILE_PERSISTENT_ACLS +#undef FILE_FILE_COMPRESSION +#undef FILE_VOLUME_QUOTAS +#undef FILE_VOLUME_IS_COMPRESSED +#undef FILE_NOTIFY_CHANGE_FILE_NAME +#undef FILE_NOTIFY_CHANGE_DIR_NAME +#undef FILE_NOTIFY_CHANGE_ATTRIBUTES +#undef FILE_NOTIFY_CHANGE_SIZE +#undef FILE_NOTIFY_CHANGE_LAST_WRITE +#undef FILE_NOTIFY_CHANGE_LAST_ACCESS +#undef FILE_NOTIFY_CHANGE_CREATION +#undef FILE_NOTIFY_CHANGE_EA +#undef FILE_NOTIFY_CHANGE_SECURITY +#undef FILE_NOTIFY_CHANGE_STREAM_NAME +#undef FILE_NOTIFY_CHANGE_STREAM_SIZE +#undef FILE_NOTIFY_CHANGE_STREAM_WRITE +#undef FILE_NOTIFY_CHANGE_NAME + +#undef PRINTER_ATTRIBUTE_QUEUED +#undef PRINTER_ATTRIBUTE_DIRECT +#undef PRINTER_ATTRIBUTE_DEFAULT +#undef PRINTER_ATTRIBUTE_SHARED +#undef PRINTER_ATTRIBUTE_NETWORK +#undef PRINTER_ATTRIBUTE_HIDDEN +#undef PRINTER_ATTRIBUTE_LOCAL +#undef PRINTER_ATTRIBUTE_ENABLE_DEVQ +#undef PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS +#undef PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST +#undef PRINTER_ATTRIBUTE_WORK_OFFLINE +#undef PRINTER_ATTRIBUTE_ENABLE_BIDI +#undef PRINTER_ATTRIBUTE_RAW_ONLY +#undef PRINTER_ATTRIBUTE_PUBLISHED +#undef PRINTER_ENUM_DEFAULT +#undef PRINTER_ENUM_LOCAL +#undef PRINTER_ENUM_CONNECTIONS +#undef PRINTER_ENUM_FAVORITE +#undef PRINTER_ENUM_NAME +#undef PRINTER_ENUM_REMOTE +#undef PRINTER_ENUM_SHARED +#undef PRINTER_ENUM_NETWORK +#undef PRINTER_ENUM_EXPAND +#undef PRINTER_ENUM_CONTAINER +#undef PRINTER_ENUM_ICON1 +#undef PRINTER_ENUM_ICON2 +#undef PRINTER_ENUM_ICON3 +#undef PRINTER_ENUM_ICON4 +#undef PRINTER_ENUM_ICON5 +#undef PRINTER_ENUM_ICON6 +#undef PRINTER_ENUM_ICON7 +#undef PRINTER_ENUM_ICON8 +#undef PRINTER_STATUS_PAUSED +#undef PRINTER_STATUS_ERROR +#undef PRINTER_STATUS_PENDING_DELETION +#undef PRINTER_STATUS_PAPER_JAM +#undef PRINTER_STATUS_PAPER_OUT +#undef PRINTER_STATUS_MANUAL_FEED +#undef PRINTER_STATUS_PAPER_PROBLEM +#undef PRINTER_STATUS_OFFLINE +#undef PRINTER_STATUS_IO_ACTIVE +#undef PRINTER_STATUS_BUSY +#undef PRINTER_STATUS_PRINTING +#undef PRINTER_STATUS_OUTPUT_BIN_FULL +#undef PRINTER_STATUS_NOT_AVAILABLE +#undef PRINTER_STATUS_WAITING +#undef PRINTER_STATUS_PROCESSING +#undef PRINTER_STATUS_INITIALIZING +#undef PRINTER_STATUS_WARMING_UP +#undef PRINTER_STATUS_TONER_LOW +#undef PRINTER_STATUS_NO_TONER +#undef PRINTER_STATUS_PAGE_PUNT +#undef PRINTER_STATUS_USER_INTERVENTION +#undef PRINTER_STATUS_OUT_OF_MEMORY +#undef PRINTER_STATUS_DOOR_OPEN +#undef PRINTER_STATUS_SERVER_UNKNOWN +#undef PRINTER_STATUS_POWER_SAVE + +#undef DWORD +#undef HKEY_CLASSES_ROOT +#undef HKEY_CURRENT_USER +#undef HKEY_LOCAL_MACHINE +#undef HKEY_USERS +#undef HKEY_PERFORMANCE_DATA +#undef HKEY_CURRENT_CONFIG +#undef HKEY_DYN_DATA +#undef REG_DWORD +#undef REG_QWORD + +#undef SERVICE_STATE_ALL + +#undef SE_GROUP_MANDATORY +#undef SE_GROUP_ENABLED_BY_DEFAULT +#undef SE_GROUP_ENABLED + +#endif /* _WIN32_REPLACE_H */ -- cgit From 4c0b19277a495b33869f447166d03a0e1e163b72 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 10:51:26 +0000 Subject: r18460: split out timegm test and only add timegm.o when needed metze (This used to be commit f9bff4dbdad8c7acc649d13a5666b58967bf5d92) --- source4/lib/replace/libreplace.m4 | 9 +++++---- source4/lib/replace/timegm.c | 14 +------------- source4/lib/replace/timegm.m4 | 1 + 3 files changed, 7 insertions(+), 17 deletions(-) create mode 100644 source4/lib/replace/timegm.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 3a40b39da2..8649a50bba 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -11,7 +11,7 @@ done LIBREPLACEOBJ="replace.o" AC_SUBST(LIBREPLACEOBJ) -LIBREPLACEOBJ="${LIBREPLACEOBJ} snprintf.o timegm.o" +LIBREPLACEOBJ="${LIBREPLACEOBJ} snprintf.o" dnl stop the C89 attempt by autoconf - if autoconf detects -Ae it will enable it dnl which conflicts with C99 on HPUX @@ -279,7 +279,7 @@ AC_CHECK_HEADERS([sys/param.h limits.h]) AC_CHECK_TYPE(comparison_fn_t, [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) -AC_CHECK_FUNCS(timegm strnlen setenv) +AC_CHECK_FUNCS(strnlen setenv) AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) # this test disabled as we don't actually need __VA_ARGS__ yet @@ -338,12 +338,13 @@ if test x"$samba_cv_volatile" = x"yes"; then AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile]) fi +m4_include(system/config.m4) + m4_include(dlfcn.m4) m4_include(getpass.m4) m4_include(win32.m4) +m4_include(timegm.m4) m4_include(repdir.m4) -m4_include(system/config.m4) - AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c index bd20da703f..ff90626d44 100644 --- a/source4/lib/replace/timegm.c +++ b/source4/lib/replace/timegm.c @@ -36,17 +36,7 @@ */ #include "replace.h" -#include - -#ifndef HAVE_TIMEGM - -#ifdef HAVE_SYS_TIME_H -#include -#endif - -#ifdef HAVE_TIME_H -#include -#endif +#include "system/time.h" static int is_leap(unsigned y) { @@ -76,5 +66,3 @@ time_t timegm(struct tm *tm) res += tm->tm_sec; return res; } - -#endif /* HAVE_TIMEGM */ diff --git a/source4/lib/replace/timegm.m4 b/source4/lib/replace/timegm.m4 new file mode 100644 index 0000000000..59f3ae0521 --- /dev/null +++ b/source4/lib/replace/timegm.m4 @@ -0,0 +1 @@ +AC_CHECK_FUNCS(timegm,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} timegm.o"]) -- cgit From dca9292c1562aadf45195b49dbfd19d036fbad45 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 10:58:40 +0000 Subject: r18461: - extend make showflags - let make test trigger showflags metze (This used to be commit 43c1d775b900b305345afe394383b78e83e4e5cb) --- source4/lib/replace/Makefile.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 6940673a78..23a4239913 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -21,8 +21,9 @@ all: showflags libreplace.a testsuite showflags: @echo 'libreplace will be compiled with flags:' + @echo ' CC = $(CC)' @echo ' CFLAGS = $(CFLAGS)' - @echo ' LIBS = $(LIBS)' + @echo ' LIBS = $(LIBS)' install: all mkdir -p $(libdir) @@ -31,7 +32,7 @@ install: all libreplace.a: $(OBJS) ar -rcsv $@ $(OBJS) -test: testsuite +test: all ./testsuite installcheck: install test -- cgit From 63d284c91220535456e036623f97ccd2cc44c000 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 11:08:50 +0000 Subject: r18462: make the output a bit nicer metze (This used to be commit 0b61ea3ed7b833dbb5a7ca8ef2bb29c1b68f5cad) --- source4/lib/replace/repdir.m4 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir.m4 b/source4/lib/replace/repdir.m4 index e2f94263e8..06a01964a8 100644 --- a/source4/lib/replace/repdir.m4 +++ b/source4/lib/replace/repdir.m4 @@ -51,6 +51,10 @@ if test x"$libreplace_READDIR_GETDIRENTRIES" = x"yes"; then libreplace_READDIR_NEEDED=no fi +AC_MSG_CHECKING([a usable readdir()]) if test x"$libreplace_READDIR_NEEDED" = x"yes"; then - AC_MSG_WARN([the provides readdir() is broken]) + AC_MSG_RESULT(no) + AC_MSG_WARN([the provided readdir() is broken]) +else + AC_MSG_RESULT(yes) fi -- cgit From f6de92d47c669088299debfcc77dd571c97cf15c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 11:39:40 +0000 Subject: r18463: add some more warning flags, tested with gcc 2.95.3 on SuSE 7.3 metze (This used to be commit 553a90cbe200d2030e4caefe949b48d63abe382d) --- source4/lib/replace/configure.ac | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index b506b791eb..cf1fe8defc 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -6,7 +6,17 @@ AC_CONFIG_HEADER(config.h) m4_include(libreplace.m4) if test "$ac_cv_prog_gcc" = yes; then - CFLAGS="$CFLAGS -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings" + CFLAGS="$CFLAGS -Wall" + CFLAGS="$CFLAGS -W" + CFLAGS="$CFLAGS -Wshadow" + CFLAGS="$CFLAGS -Wstrict-prototypes" + CFLAGS="$CFLAGS -Wpointer-arith" + CFLAGS="$CFLAGS -Wcast-qual" + CFLAGS="$CFLAGS -Wcast-align" + CFLAGS="$CFLAGS -Wwrite-strings" + CFLAGS="$CFLAGS -Werror-implicit-function-declaration" + CFLAGS="$CFLAGS -Wformat=2" + CFLAGS="$CFLAGS -Wno-format-y2k" fi AC_OUTPUT(Makefile) -- cgit From 84a56aca154a9c9a7ae9465db739bf173424cef0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 12:32:27 +0000 Subject: r18465: much better fix for a roken specifiv problem metze (This used to be commit 1ae1e68fe9e1004f1a11847714b2e71715a1ce03) --- source4/lib/replace/libreplace.m4 | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 8649a50bba..2fe48d4e22 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -70,17 +70,6 @@ AC_CHECK_TYPE(uint32_t, unsigned long) AC_CHECK_TYPE(ssize_t, int) AC_CHECK_TYPE(ptrdiff_t, unsigned long long) -dnl these are needed for heimdal roken.h -AC_CHECK_TYPE(struct sockaddr, [], [], [ -AC_INCLUDES_DEFAULT -#include ]) -AC_CHECK_TYPE(struct sockaddr_storage, [], [], [ -AC_INCLUDES_DEFAULT -#include ]) -AC_CHECK_TYPE(struct addrinfo, [], [], [ -AC_INCLUDES_DEFAULT -#include ]) - AC_TYPE_SIGNAL AC_TYPE_UID_T AC_TYPE_MODE_T -- cgit From 4e355095d11a907cecf14dbe28d4c05f527d4cba Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 13:50:51 +0000 Subject: r18472: - use STDC_HEADERS for stdlib.h and stddef.h as autoconf does - AC_HEADERS_STDC is not explicit needed metze (This used to be commit 8f20d2cfe564164ea049dbb9f52d885e11098c2a) --- source4/lib/replace/libreplace.m4 | 7 ++----- source4/lib/replace/replace.h | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 2fe48d4e22..a96890ba54 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -24,6 +24,7 @@ AC_ISC_POSIX AC_USE_SYSTEM_EXTENSIONS AC_PROG_CC_C99 AC_C_INLINE +AC_C_BIGENDIAN AC_PROG_INSTALL AH_VERBATIM([_XOPEN_SOURCE_EXTENDED], @@ -50,10 +51,6 @@ esac AC_CHECK_HEADERS([standards.h]) -AC_C_BIGENDIAN -AC_HEADER_STDC - - AC_CHECK_SIZEOF(off_t,cross) AC_CHECK_SIZEOF(size_t,cross) AC_CHECK_SIZEOF(ssize_t,cross) @@ -86,7 +83,7 @@ AC_FUNC_MEMCMP AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat getpgrp) -AC_CHECK_HEADERS(stdbool.h stddef.h sys/select.h) +AC_CHECK_HEADERS(stdbool.h sys/select.h) AC_CHECK_HEADERS(sys/epoll.h) AC_CHECK_FUNCS(epoll_create) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index e35f1da44e..ca315131f1 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -72,7 +72,8 @@ #include #endif -#ifdef HAVE_STDDEF_H +#if STDC_HEADERS +#include #include #endif -- cgit From 8e65d33d7d856eb4516971bd5689255cc4de3c06 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 14:10:25 +0000 Subject: r18474: - we don't need to explicit check stdint.h and inttypes.h alsready done by autoconf magic - display the sizes of all standard C types - check for int64_t and uint64_t metze (This used to be commit 371a33a871b67f12af177696bae6aa87d2c1d9f9) --- source4/lib/replace/libreplace.m4 | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index a96890ba54..fa89830110 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -51,20 +51,30 @@ esac AC_CHECK_HEADERS([standards.h]) -AC_CHECK_SIZEOF(off_t,cross) -AC_CHECK_SIZEOF(size_t,cross) -AC_CHECK_SIZEOF(ssize_t,cross) - -AC_CHECK_HEADERS([stdint.h inttypes.h]) AC_CHECK_TYPE(uint_t, unsigned int) -AC_CHECK_TYPE(uint8_t, unsigned char) AC_CHECK_TYPE(int8_t, char) +AC_CHECK_TYPE(uint8_t, unsigned char) AC_CHECK_TYPE(int16_t, short) AC_CHECK_TYPE(uint16_t, unsigned short) AC_CHECK_TYPE(int32_t, long) -AC_CHECK_TYPE(intptr_t, unsigned long long) AC_CHECK_TYPE(uint32_t, unsigned long) +AC_CHECK_TYPE(int64_t, long long) +AC_CHECK_TYPE(uint64_t, unsigned long long) + +AC_CHECK_TYPE(size_t, unsigned int) AC_CHECK_TYPE(ssize_t, int) + +AC_CHECK_SIZEOF(int) +AC_CHECK_SIZEOF(char) +AC_CHECK_SIZEOF(short) +AC_CHECK_SIZEOF(long) +AC_CHECK_SIZEOF(long long) + +AC_CHECK_SIZEOF(off_t) +AC_CHECK_SIZEOF(size_t) +AC_CHECK_SIZEOF(ssize_t) + +AC_CHECK_TYPE(intptr_t, unsigned long long) AC_CHECK_TYPE(ptrdiff_t, unsigned long long) AC_TYPE_SIGNAL @@ -77,7 +87,6 @@ AC_STRUCT_ST_RDEV AC_CHECK_TYPE(ino_t,unsigned) AC_CHECK_TYPE(loff_t,off_t) AC_CHECK_TYPE(offset_t,loff_t) -AC_CHECK_TYPES(long long) AC_FUNC_MEMCMP -- cgit From 3de6b469ccadfbaa0c16535c3f17049ffb96aef1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 16:15:38 +0000 Subject: r18479: start hiding libreplace configure tests behind macros AC_LIBREPLACE_CC_CHECKS AC_LIBREPLACE_BROKEN_CHECKS and AC_LIBREPLACE_ALL_CHECKS which calls the 2 others I'll add some more, so that samba3/samba4 can later call them in the wanted order and all standalone builds use AC_LIBREPLACE_ALL_CHECKS. metze (This used to be commit e7a30456c76f4bf9a79cdcff6b15c894bc20c954) --- source4/lib/replace/libreplace.m4 | 89 ++++++++-------------------- source4/lib/replace/libreplace_cc.m4 | 99 ++++++++++++++++++++++++++++++++ source4/lib/replace/libreplace_macros.m4 | 2 + 3 files changed, 126 insertions(+), 64 deletions(-) create mode 100644 source4/lib/replace/libreplace_cc.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index fa89830110..293b2380a8 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -1,3 +1,7 @@ +AC_DEFUN_ONCE(AC_LIBREPLACE_BROKEN_CHECKS, +[ +echo "LIBREPLACE_BROKEN_CHECKS: START" + dnl find the libreplace sources. This is meant to work both for dnl libreplace standalone builds, and builds of packages using libreplace libreplacedir="" @@ -13,70 +17,6 @@ AC_SUBST(LIBREPLACEOBJ) LIBREPLACEOBJ="${LIBREPLACEOBJ} snprintf.o" -dnl stop the C89 attempt by autoconf - if autoconf detects -Ae it will enable it -dnl which conflicts with C99 on HPUX -ac_cv_prog_cc_Ae=no - -savedCFLAGS=$CFLAGS -AC_PROG_CC -CFLAGS=$savedCFLAGS -AC_ISC_POSIX -AC_USE_SYSTEM_EXTENSIONS -AC_PROG_CC_C99 -AC_C_INLINE -AC_C_BIGENDIAN -AC_PROG_INSTALL - -AH_VERBATIM([_XOPEN_SOURCE_EXTENDED], -[/* Enable XOPEN extensions on systems that have them. */ -#ifndef _XOPEN_SOURCE_EXTENDED -# define _XOPEN_SOURCE_EXTENDED 1 -#endif]) - -AH_VERBATIM([_OSF_SOURCE], -[/* Enable OSF extensions on systems that have them. */ -#ifndef _OSF_SOURCE -# define _OSF_SOURCE 1 -#endif]) - -LIBREPLACE_C99_STRUCT_INIT([],[]) - -AC_SYS_LARGEFILE - -dnl Add #include for broken IRIX header files -case "$host_os" in - *irix6*) AC_ADD_INCLUDE() - ;; -esac - -AC_CHECK_HEADERS([standards.h]) - -AC_CHECK_TYPE(uint_t, unsigned int) -AC_CHECK_TYPE(int8_t, char) -AC_CHECK_TYPE(uint8_t, unsigned char) -AC_CHECK_TYPE(int16_t, short) -AC_CHECK_TYPE(uint16_t, unsigned short) -AC_CHECK_TYPE(int32_t, long) -AC_CHECK_TYPE(uint32_t, unsigned long) -AC_CHECK_TYPE(int64_t, long long) -AC_CHECK_TYPE(uint64_t, unsigned long long) - -AC_CHECK_TYPE(size_t, unsigned int) -AC_CHECK_TYPE(ssize_t, int) - -AC_CHECK_SIZEOF(int) -AC_CHECK_SIZEOF(char) -AC_CHECK_SIZEOF(short) -AC_CHECK_SIZEOF(long) -AC_CHECK_SIZEOF(long long) - -AC_CHECK_SIZEOF(off_t) -AC_CHECK_SIZEOF(size_t) -AC_CHECK_SIZEOF(ssize_t) - -AC_CHECK_TYPE(intptr_t, unsigned long long) -AC_CHECK_TYPE(ptrdiff_t, unsigned long long) - AC_TYPE_SIGNAL AC_TYPE_UID_T AC_TYPE_MODE_T @@ -343,3 +283,24 @@ m4_include(repdir.m4) AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, [AC_MSG_ERROR([Required function not found])]) + +echo "LIBREPLACE_BROKEN_CHECKS: END" +]) dnl end AC_LIBREPLACE_BROKEN_CHECKS + +AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_START, +[ +#LIBREPLACE_ALL_CHECKS: START" +]) +AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_END, +[ +#LIBREPLACE_ALL_CHECKS: END" +]) +m4_define(AC_LIBREPLACE_ALL_CHECKS, +[ +AC__LIBREPLACE_ALL_CHECKS_START +AC_LIBREPLACE_CC_CHECKS +AC_LIBREPLACE_BROKEN_CHECKS +AC__LIBREPLACE_ALL_CHECKS_END +]) + +AC_LIBREPLACE_ALL_CHECKS diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 new file mode 100644 index 0000000000..4dfe32e7a7 --- /dev/null +++ b/source4/lib/replace/libreplace_cc.m4 @@ -0,0 +1,99 @@ + +AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_START, +[ +echo "LIBREPLACE_CC_CHECKS: START" +]) + +AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_END, +[ +echo "LIBREPLACE_CC_CHECKS: END" +]) + +dnl +dnl +dnl AC_LIBREPLACE_CC_CHECKS +dnl +dnl Note: we need to use m4_define instead of AC_DEFUN because +dnl of the ordering of tests +dnl +dnl +m4_define(AC_LIBREPLACE_CC_CHECKS, +[ +AC__LIBREPLACE_ONLY_CC_CHECKS_START + +dnl stop the C89 attempt by autoconf - if autoconf detects -Ae it will enable it +dnl which conflicts with C99 on HPUX +ac_cv_prog_cc_Ae=no + +savedCFLAGS=$CFLAGS +AC_PROG_CC +CFLAGS=$savedCFLAGS +dnl AC_PROG_CPP +dnl AC_PROG_EGREP +dnl AC_GNU_SOURCE +dnl AC_AIX +dnl AC_MINIX +dnl AC_GNU_SOURCE +dnl AC_INCLUDES_DEFAULT +dnl AC_USE_SYSTEM_EXTENSIONS +dnl AC_INCLUDES_DEFAULT +dnl AC_HEADER_STDC +AC_ISC_POSIX +AC_USE_SYSTEM_EXTENSIONS +AC_PROG_CC_C99 +AC_C_INLINE +AC_C_BIGENDIAN +AC_PROG_INSTALL + +AH_VERBATIM([_XOPEN_SOURCE_EXTENDED], +[/* Enable XOPEN extensions on systems that have them. */ +#ifndef _XOPEN_SOURCE_EXTENDED +# define _XOPEN_SOURCE_EXTENDED 1 +#endif]) + +AH_VERBATIM([_OSF_SOURCE], +[/* Enable OSF extensions on systems that have them. */ +#ifndef _OSF_SOURCE +# define _OSF_SOURCE 1 +#endif]) + +LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not supported])]) + +AC_SYS_LARGEFILE + +dnl Add #include for broken IRIX header files +case "$host_os" in + *irix6*) AC_ADD_INCLUDE() + ;; +esac + +AC_CHECK_HEADERS([standards.h]) + +AC_CHECK_TYPE(uint_t, unsigned int) +AC_CHECK_TYPE(int8_t, char) +AC_CHECK_TYPE(uint8_t, unsigned char) +AC_CHECK_TYPE(int16_t, short) +AC_CHECK_TYPE(uint16_t, unsigned short) +AC_CHECK_TYPE(int32_t, long) +AC_CHECK_TYPE(uint32_t, unsigned long) +AC_CHECK_TYPE(int64_t, long long) +AC_CHECK_TYPE(uint64_t, unsigned long long) + +AC_CHECK_TYPE(size_t, unsigned int) +AC_CHECK_TYPE(ssize_t, int) + +AC_CHECK_SIZEOF(int) +AC_CHECK_SIZEOF(char) +AC_CHECK_SIZEOF(short) +AC_CHECK_SIZEOF(long) +AC_CHECK_SIZEOF(long long) + +AC_CHECK_SIZEOF(off_t) +AC_CHECK_SIZEOF(size_t) +AC_CHECK_SIZEOF(ssize_t) + +AC_CHECK_TYPE(intptr_t, unsigned long long) +AC_CHECK_TYPE(ptrdiff_t, unsigned long long) + +AC__LIBREPLACE_ONLY_CC_CHECKS_END +]) dnl end AC_LIBREPLACE_CC_CHECKS diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 71ef64337b..67a770c9e2 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -251,4 +251,6 @@ define(AC_ADD_INCLUDE, EOF ]) +m4_include(libreplace_cc.m4) m4_include(autoconf-2.60.m4) + -- cgit From d08fb7b1cc39f4fa92045a4789fcf6182caba907 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 16:51:45 +0000 Subject: r18485: include libreplace.m4 in the aclocal.m4 files and use the macros in configure.ac metze (This used to be commit 95d33e4d71b4c97af8413bcd136f393aa3e380dd) --- source4/lib/replace/aclocal.m4 | 2 +- source4/lib/replace/configure.ac | 2 +- source4/lib/replace/libreplace.m4 | 4 +++- source4/lib/replace/libreplace_macros.m4 | 3 --- source4/lib/replace/samba.m4 | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/aclocal.m4 b/source4/lib/replace/aclocal.m4 index 2a7ad94963..5605e476ba 100644 --- a/source4/lib/replace/aclocal.m4 +++ b/source4/lib/replace/aclocal.m4 @@ -1 +1 @@ -m4_include(libreplace_macros.m4) +m4_include(libreplace.m4) diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index cf1fe8defc..48fb7ce259 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -3,7 +3,7 @@ AC_INIT(replace.c) AC_CONFIG_SRCDIR([replace.c]) AC_CONFIG_HEADER(config.h) -m4_include(libreplace.m4) +AC_LIBREPLACE_ALL_CHECKS if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wall" diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 293b2380a8..53655e6544 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -303,4 +303,6 @@ AC_LIBREPLACE_BROKEN_CHECKS AC__LIBREPLACE_ALL_CHECKS_END ]) -AC_LIBREPLACE_ALL_CHECKS +m4_include(libreplace_cc.m4) +m4_include(libreplace_macros.m4) +m4_include(autoconf-2.60.m4) diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 67a770c9e2..6c1110dc4b 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -251,6 +251,3 @@ define(AC_ADD_INCLUDE, EOF ]) -m4_include(libreplace_cc.m4) -m4_include(autoconf-2.60.m4) - diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4 index c6c5e63b7f..3769c7f50e 100644 --- a/source4/lib/replace/samba.m4 +++ b/source4/lib/replace/samba.m4 @@ -1,4 +1,4 @@ -m4_include(lib/replace/libreplace.m4) +AC_LIBREPLACE_BROKEN_CHECKS SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}]) SMB_ENABLE(LIBREPLACE_EXT) -- cgit From f80d6bc100ed7b9c8bf83525c3e68c1272de84c3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Sep 2006 17:38:49 +0000 Subject: r18486: hopefully this fixes the panics on solaris metze (This used to be commit 22cfc3404ccb621dad194fe04c5f2885fb16f79c) --- source4/lib/replace/libreplace_cc.m4 | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 4dfe32e7a7..dd06a6c0f7 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -69,6 +69,9 @@ esac AC_CHECK_HEADERS([standards.h]) +# Solaris needs HAVE_LONG_LONG defined +AC_CHECK_TYPES(long long) + AC_CHECK_TYPE(uint_t, unsigned int) AC_CHECK_TYPE(int8_t, char) AC_CHECK_TYPE(uint8_t, unsigned char) -- cgit From 6fa6c74d5959471a2b8d07a2e1e508d299bc2b8d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Sep 2006 22:31:25 +0000 Subject: r18488: we have to make sure any extensions flags also make it into confdefs.h, otherwise the real build and the configure tests will not be significant this change fixes the build of libreplace on hpux with gcc (This used to be commit d37fc315325c93414ce0942d28f0f47b42873b95) --- source4/lib/replace/libreplace_cc.m4 | 14 +++----------- source4/lib/replace/libreplace_macros.m4 | 13 +++++++++++++ 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index dd06a6c0f7..2c58933a65 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -45,17 +45,9 @@ AC_C_INLINE AC_C_BIGENDIAN AC_PROG_INSTALL -AH_VERBATIM([_XOPEN_SOURCE_EXTENDED], -[/* Enable XOPEN extensions on systems that have them. */ -#ifndef _XOPEN_SOURCE_EXTENDED -# define _XOPEN_SOURCE_EXTENDED 1 -#endif]) - -AH_VERBATIM([_OSF_SOURCE], -[/* Enable OSF extensions on systems that have them. */ -#ifndef _OSF_SOURCE -# define _OSF_SOURCE 1 -#endif]) + +AC_EXTENSION_FLAG(_XOPEN_SOURCE_EXTENDED) +AC_EXTENSION_FLAG(_OSF_SOURCE) LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not supported])]) diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 6c1110dc4b..6c4cfc465d 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -87,6 +87,19 @@ fi rm -f conftest* ])]) +AC_DEFUN([AC_EXTENSION_FLAG], +[ + cat >>confdefs.h <<\EOF +#ifndef $1 +# define $1 +#endif +EOF +AH_VERBATIM([$1], [#ifndef $1 +# define $1 +#endif]) +]) + + dnl see if a declaration exists for a function or variable dnl defines HAVE_function_DECL if it exists dnl AC_HAVE_DECL(var, includes) -- cgit From fd6030eac7d0c71106e2f83579d6d2f30e1b5f96 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Sep 2006 23:13:32 +0000 Subject: r18490: on irix _XOPEN_SOURCE_EXTENDED needs to be defined to 1, not just defined (This used to be commit 39d984738b1931e16cb0e6abfdb58108fc97da90) --- source4/lib/replace/libreplace_macros.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 6c4cfc465d..913de5eab1 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -91,11 +91,11 @@ AC_DEFUN([AC_EXTENSION_FLAG], [ cat >>confdefs.h <<\EOF #ifndef $1 -# define $1 +# define $1 1 #endif EOF AH_VERBATIM([$1], [#ifndef $1 -# define $1 +# define $1 1 #endif]) ]) -- cgit From 90c3e8b9060722190e2537069bb7eafe1491c611 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Sep 2006 23:13:44 +0000 Subject: r18491: fixed a warning (This used to be commit 1b17f0f08f85238717e88966cba311ff4b933a9a) --- source4/lib/replace/test/os2_delete.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index 641b8c8d93..d0aadb24ba 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -34,7 +34,7 @@ static void cleanup(void) mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); } -static void create_files() +static void create_files(void) { int i; for (i=0;i Date: Thu, 14 Sep 2006 02:25:57 +0000 Subject: r18492: an attempt at replacing readdir() with something based on getdirentries() This is untested on any of the platforms that matter, so we'll just have to see if the build farm machines like it (This used to be commit 343b0871b16c86b68badd4581420f475f94e79c9) --- source4/lib/replace/repdir_getdirentries.c | 158 ++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir_getdirentries.c b/source4/lib/replace/repdir_getdirentries.c index ff93ed4ea3..3079eefed0 100644 --- a/source4/lib/replace/repdir_getdirentries.c +++ b/source4/lib/replace/repdir_getdirentries.c @@ -1 +1,157 @@ -#error "the readdir() replacement using getdirentried() isn't implemented yet" +/* + Unix SMB/CIFS implementation. + + Copyright (C) Andrew Tridgell 2005 + + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/* + a replacement for opendir/readdir/telldir/seekdir/closedir for BSD + systems using getdirentries + + This is needed because the existing directory handling in FreeBSD + and OpenBSD (and possibly NetBSD) doesn't correctly handle unlink() + on files in a directory where telldir() has been used. On a block + boundary it will occasionally miss a file when seekdir() is used to + return to a position previously recorded with telldir(). + + This also fixes a severe performance and memory usage problem with + telldir() on BSD systems. Each call to telldir() in BSD adds an + entry to a linked list, and those entries are cleaned up on + closedir(). This means with a large directory closedir() can take an + arbitrary amount of time, causing network timeouts as millions of + telldir() entries are freed + + Note! This replacement code is not portable. It relies on + getdirentries() always leaving the file descriptor at a seek offset + that is a multiple of DIR_BUF_SIZE. If the code detects that this + doesn't happen then it will abort(). It also does not handle + directories with offsets larger than can be stored in a long, + + This code is available under other free software licenses as + well. Contact the author. +*/ + +#include +#include +#include +#include +#include +#include +#include + +#define DIR_BUF_BITS 9 +#define DIR_BUF_SIZE (1<fd = open(dname, O_RDONLY); + if (d->fd == -1) { + free(d); + return NULL; + } + d->ofs = 0; + d->seekpos = 0; + d->nbytes = 0; + return (DIR *)d; +} + +struct dirent *readdir(DIR *dir) +{ + struct dir_buf *d = (struct dir_buf *)dir; + struct dirent *de; + + if (d->ofs >= d->nbytes) { + d->nbytes = getdirentries(d->fd, d->buf, DIR_BUF_SIZE, &d->seekpos); + d->ofs = 0; + } + if (d->ofs >= d->nbytes) { + return NULL; + } + de = (struct dirent *)&d->buf[d->ofs]; + d->ofs += de->d_reclen; + return de; +} + +long telldir(DIR *dir) +{ + struct dir_buf *d = (struct dir_buf *)dir; + if (d->ofs >= d->nbytes) { + d->seekpos = lseek(d->fd, 0, SEEK_CUR); + d->ofs = 0; + d->nbytes = 0; + } + /* this relies on seekpos always being a multiple of + DIR_BUF_SIZE. Is that always true on BSD systems? */ + if (d->seekpos & (DIR_BUF_SIZE-1)) { + abort(); + } + return d->seekpos + d->ofs; +} + +void seekdir(DIR *dir, long ofs) +{ + struct dir_buf *d = (struct dir_buf *)dir; + d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET); + d->nbytes = getdirentries(d->fd, d->buf, DIR_BUF_SIZE, &d->seekpos); + d->ofs = 0; + while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) { + if (readdir(dir) == NULL) break; + } +} + +void rewinddir(DIR *dir) +{ + seekdir(dir, 0); +} + +int closedir(DIR *dir) +{ + struct dir_buf *d = (struct dir_buf *)dir; + int r = close(d->fd); + if (r != 0) { + return r; + } + free(d); + return 0; +} + +#ifndef dirfd +/* darn, this is a macro on some systems. */ +int dirfd(DIR *dir) +{ + struct dir_buf *d = (struct dir_buf *)dir; + return d->fd; +} +#endif + + -- cgit From bdfecf3c9777bac276eb3d257ef55728e5dcc6ca Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Sep 2006 02:37:00 +0000 Subject: r18493: another "blind coding" attempt at a getdirentries() based readdir() replacement (This used to be commit 94b73d692bf85604c7be811bad0b8c6a08b18103) --- source4/lib/replace/repdir_getdirentries.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir_getdirentries.c b/source4/lib/replace/repdir_getdirentries.c index 3079eefed0..33c63c3bcc 100644 --- a/source4/lib/replace/repdir_getdirentries.c +++ b/source4/lib/replace/repdir_getdirentries.c @@ -91,7 +91,9 @@ struct dirent *readdir(DIR *dir) struct dirent *de; if (d->ofs >= d->nbytes) { - d->nbytes = getdirentries(d->fd, d->buf, DIR_BUF_SIZE, &d->seekpos); + long pos; + d->nbytes = getdirentries(d->fd, d->buf, DIR_BUF_SIZE, &pos); + d->seekpos = pos; d->ofs = 0; } if (d->ofs >= d->nbytes) { @@ -121,8 +123,9 @@ long telldir(DIR *dir) void seekdir(DIR *dir, long ofs) { struct dir_buf *d = (struct dir_buf *)dir; + long pos; d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET); - d->nbytes = getdirentries(d->fd, d->buf, DIR_BUF_SIZE, &d->seekpos); + d->nbytes = getdirentries(d->fd, d->buf, DIR_BUF_SIZE, &pos); d->ofs = 0; while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) { if (readdir(dir) == NULL) break; -- cgit From ac24d381a5a9bc4611701bcbf956fe017bdddaeb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Sep 2006 05:33:54 +0000 Subject: r18499: this hopefully lets the code compile on OpenBSD the prototype was fixed in this revision http://www.openbsd.org/cgi-bin/cvsweb/src/include/dirent.h.diff?r1=1.15&r2=1.16 so we'll need a configure test to find the prototype of telldir later metze (This used to be commit c4da3b43640368aff98e501b6ca7801821fd2fbd) --- source4/lib/replace/repdir_getdirentries.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir_getdirentries.c b/source4/lib/replace/repdir_getdirentries.c index 33c63c3bcc..a9c1c1ce82 100644 --- a/source4/lib/replace/repdir_getdirentries.c +++ b/source4/lib/replace/repdir_getdirentries.c @@ -104,7 +104,13 @@ struct dirent *readdir(DIR *dir) return de; } +#define TELLDIR_TAKES_CONST_DIR + +#ifdef TELLDIR_TAKES_CONST_DIR +long telldir(const DIR *dir) +#else long telldir(DIR *dir) +#endif { struct dir_buf *d = (struct dir_buf *)dir; if (d->ofs >= d->nbytes) { -- cgit From 8ed1176a8d3ae80d27010243e389d449ab5a0148 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Sep 2006 06:39:48 +0000 Subject: r18501: libreplace needs 'long long', bailout if not present or the size is not 8 bytes or more. samba4 doesn't need type checks anymore metze (This used to be commit d8fdd05482fc6b9bfb48d72db6b467e3e5c05e4d) --- source4/lib/replace/libreplace_cc.m4 | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 2c58933a65..9f6912741e 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -90,5 +90,12 @@ AC_CHECK_SIZEOF(ssize_t) AC_CHECK_TYPE(intptr_t, unsigned long long) AC_CHECK_TYPE(ptrdiff_t, unsigned long long) +if test x"$ac_cv_type_long_long" != x"yes";then + AC_MSG_ERROR([LIBREPLACE needs type 'long long']) +fi +if test $ac_cv_sizeof_long_long -lt 8;then + AC_MSG_ERROR([LIBREPLACE needs sizeof(long long) >= 8]) +fi + AC__LIBREPLACE_ONLY_CC_CHECKS_END ]) dnl end AC_LIBREPLACE_CC_CHECKS -- cgit From d184a9cc329c900f98147423e3350cfeb22e1e88 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Sep 2006 07:22:38 +0000 Subject: r18502: remove unused lines metze (This used to be commit 37f55c08c304feddf2ca5d0d20deeb9a6317e2c3) --- source4/lib/replace/libreplace_cc.m4 | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 9f6912741e..5e44da73a3 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -28,16 +28,6 @@ ac_cv_prog_cc_Ae=no savedCFLAGS=$CFLAGS AC_PROG_CC CFLAGS=$savedCFLAGS -dnl AC_PROG_CPP -dnl AC_PROG_EGREP -dnl AC_GNU_SOURCE -dnl AC_AIX -dnl AC_MINIX -dnl AC_GNU_SOURCE -dnl AC_INCLUDES_DEFAULT -dnl AC_USE_SYSTEM_EXTENSIONS -dnl AC_INCLUDES_DEFAULT -dnl AC_HEADER_STDC AC_ISC_POSIX AC_USE_SYSTEM_EXTENSIONS AC_PROG_CC_C99 -- cgit From a9aa6d0c67985bfebb43be90a81b6d0a4fbcd8ad Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Sep 2006 07:30:46 +0000 Subject: r18503: - _GNU_SOURCE is defined by libreplace - move AS_HELP_STRING replacement to libreplace metze (This used to be commit ace406a36ebbed230bf6c844e4639bac5e6c9882) --- source4/lib/replace/libreplace_macros.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 913de5eab1..41ec03f07a 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -264,3 +264,7 @@ define(AC_ADD_INCLUDE, EOF ]) +dnl AS_HELP_STRING is not available in autoconf 2.57, and AC_HELP_STRING is deprecated +dnl in autoconf 2.59, so define AS_HELP_STRING to be AC_HELP_STRING unless it is already +dnl defined. +m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))]) -- cgit From a0e87e5dc79bc631cb2362ebbf4d91913a342273 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Sep 2006 08:26:41 +0000 Subject: r18505: add configure checks for telldir() and seekdir() telldir() is different on older OpenBSD versions seekdir() is different Tru64 tridge: OpenBSD seems to like this replacement:-) while MAC OS 10 gets 134 runtime error:-( lets wait what Tru64 will give metze (This used to be commit 1f4e602ff239b7feabb2dd1d6938dedf91bde5cd) --- source4/lib/replace/libreplace_macros.m4 | 20 ++++++++++++++++++++ source4/lib/replace/repdir.m4 | 21 +++++++++++++++++++-- source4/lib/replace/repdir_getdirentries.c | 10 ++++++++-- 3 files changed, 47 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 41ec03f07a..91f816c75d 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -268,3 +268,23 @@ dnl AS_HELP_STRING is not available in autoconf 2.57, and AC_HELP_STRING is depr dnl in autoconf 2.59, so define AS_HELP_STRING to be AC_HELP_STRING unless it is already dnl defined. m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))]) + +dnl check if the prototype in the header matches the given one +dnl AC_VERIFY_C_PROTOTYPE(prototype,functionbody,[IF-TRUE].[IF-FALSE],[extraheaders]) +AC_DEFUN(AC_VERIFY_C_PROTOTYPE, +[AC_CACHE_CHECK([for prototype $1], AS_TR_SH([ac_cv_c_prototype_$1]), + AC_COMPILE_IFELSE([ + AC_INCLUDES_DEFAULT + $5 + $1 + { + $2 + } + ],[ + AS_TR_SH([ac_cv_c_prototype_$1])=yes + $3 + ],[ + AS_TR_SH([ac_cv_c_prototype_$1])=no + $4 + ]) +)]) diff --git a/source4/lib/replace/repdir.m4 b/source4/lib/replace/repdir.m4 index 06a01964a8..93bf4ec911 100644 --- a/source4/lib/replace/repdir.m4 +++ b/source4/lib/replace/repdir.m4 @@ -14,7 +14,7 @@ if test x"$libreplace_READDIR_NEEDED" = x"yes"; then AC_CHECK_FUNCS(getdents) AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_READDIR_GETDENTS,[ AC_TRY_RUN([ -#include "confdefs.h" +#define _LIBREPLACE_REPLACE_H #include "$libreplacedir/repdir_getdents.c" #define test_readdir_os2_delete main #include "$libreplacedir/test/os2_delete.c"], @@ -34,9 +34,26 @@ fi # if test x"$libreplace_READDIR_NEEDED" = x"yes"; then AC_CHECK_FUNCS(getdirentries) +AC_VERIFY_C_PROTOTYPE([long telldir(const DIR *dir)], + [ + return 0; + ],[ + AC_DEFINE(TELLDIR_TAKES_CONST_DIR, 1, [Whether telldir takes a const pointer]) + ],[],[ + #include + ]) + +AC_VERIFY_C_PROTOTYPE([int seekdir(DIR *dir, long ofs)], + [ + return 0; + ],[ + AC_DEFINE(SEEKDIR_RETURNS_INT, 1, [Whether seekdir returns an int]) + ],[],[ + #include + ]) AC_CACHE_CHECK([for replacing readdir using getdirentries()],libreplace_READDIR_GETDIRENTRIES,[ AC_TRY_RUN([ -#include "confdefs.h" +#define _LIBREPLACE_REPLACE_H #include "$libreplacedir/repdir_getdirentries.c" #define test_readdir_os2_delete main #include "$libreplacedir/test/os2_delete.c"], diff --git a/source4/lib/replace/repdir_getdirentries.c b/source4/lib/replace/repdir_getdirentries.c index a9c1c1ce82..9e4b63145c 100644 --- a/source4/lib/replace/repdir_getdirentries.c +++ b/source4/lib/replace/repdir_getdirentries.c @@ -48,6 +48,7 @@ well. Contact the author. */ +#include "replace.h" #include #include #include @@ -104,8 +105,6 @@ struct dirent *readdir(DIR *dir) return de; } -#define TELLDIR_TAKES_CONST_DIR - #ifdef TELLDIR_TAKES_CONST_DIR long telldir(const DIR *dir) #else @@ -126,7 +125,11 @@ long telldir(DIR *dir) return d->seekpos + d->ofs; } +#ifdef SEEKDIR_RETURNS_INT +int seekdir(DIR *dir, long ofs) +#else void seekdir(DIR *dir, long ofs) +#endif { struct dir_buf *d = (struct dir_buf *)dir; long pos; @@ -136,6 +139,9 @@ void seekdir(DIR *dir, long ofs) while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) { if (readdir(dir) == NULL) break; } +#ifdef SEEKDIR_RETURNS_INT + return -1; +#endif } void rewinddir(DIR *dir) -- cgit From cbb1975c8caa4277b0d1cad7e8427dc241cf2958 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Sep 2006 10:34:03 +0000 Subject: r18514: fix configure caching of AC_VERIFY_C_PROTOTYPE() macro metze (This used to be commit 8e49dc69e7d588c85c9e9e7b24b595c61c1da95a) --- source4/lib/replace/libreplace_macros.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 91f816c75d..4a645ef81f 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -282,9 +282,9 @@ AC_DEFUN(AC_VERIFY_C_PROTOTYPE, } ],[ AS_TR_SH([ac_cv_c_prototype_$1])=yes - $3 ],[ AS_TR_SH([ac_cv_c_prototype_$1])=no - $4 ]) -)]) +) +AS_IF([test $AS_TR_SH([ac_cv_c_prototype_$1]) = yes],[$3],[$4]) +]) -- cgit From eef5a6f5388b454d9f2646a56847943ccf67eb7b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Sep 2006 11:55:49 +0000 Subject: r18518: we replace snprintf() if its not C99, so we should also add the rep_ prototype in that case (This used to be commit 64b5ff171d04bd93bd41309edfbe532c01a46e4f) --- source4/lib/replace/replace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index ca315131f1..7cdaaae689 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -223,12 +223,12 @@ int rep_dlclose(void *handle); int rep_vasprintf(char **ptr, const char *format, va_list ap); #endif -#ifndef HAVE_SNPRINTF +#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF) #define snprintf rep_snprintf int rep_snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4); #endif -#ifndef HAVE_VSNPRINTF +#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) #define vsnprintf rep_vsnprintf int rep_vsnprintf(char *,size_t ,const char *, va_list ap); #endif -- cgit From fafa8c3e47497a9f399e9ca52a7e6a904f1fb9f6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Sep 2006 18:46:10 +0000 Subject: r18535: move the AC_CANONICAL_HOST and host specific flag tests into libreplace. This should fix the standalone build of tdb on HPUX, where we need to blacklist mmap. Unfortunately this requires that we have a copy of config.guess and config.sub in each of our project subdirectories. I tried to find a way to use something like AC_CONFIG_AUX_DIR($libreplacedir) and just put config.{guess,sub} in the lib/replace/ directory, but I couldn't figure out how to do that in a way that kept autoconf happy for each of our separate builds. Any autoconf guru out there see a way to do this? (This used to be commit 823cd3ab35456769dcefee17bdaca21f01ba0f63) --- source4/lib/replace/config.guess | 1466 +++++++++++++++++++++++++++++++ source4/lib/replace/config.sub | 1579 ++++++++++++++++++++++++++++++++++ source4/lib/replace/libreplace.m4 | 24 + source4/lib/replace/libreplace_cc.m4 | 31 + 4 files changed, 3100 insertions(+) create mode 100755 source4/lib/replace/config.guess create mode 100755 source4/lib/replace/config.sub (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.guess b/source4/lib/replace/config.guess new file mode 100755 index 0000000000..ad5281e66e --- /dev/null +++ b/source4/lib/replace/config.guess @@ -0,0 +1,1466 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + +timestamp='2005-08-03' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerppc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + x86:Interix*:[34]*) + echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + exit ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + *86) UNAME_PROCESSOR=i686 ;; + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/source4/lib/replace/config.sub b/source4/lib/replace/config.sub new file mode 100755 index 0000000000..1c366dfde9 --- /dev/null +++ b/source4/lib/replace/config.sub @@ -0,0 +1,1579 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + +timestamp='2005-07-08' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ + kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | ms1 \ + | msp430 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m32c) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | ms1-* \ + | msp430-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + m32c-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16c) + basic_machine=cr16c-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 53655e6544..1d82c00b2b 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -1,3 +1,26 @@ +AC_DEFUN_ONCE(AC_LIBREPLACE_LOCATION_CHECKS, +[ +echo "LIBREPLACE_LOCATION_CHECKS: START" + +dnl find the libreplace sources. This is meant to work both for +dnl libreplace standalone builds, and builds of packages using libreplace +libreplacedir="" +for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace" "$srcdir/../replace"; do + if test -f "$d/replace.c"; then + libreplacedir="$d" + AC_SUBST(libreplacedir) + break; + fi +done +LIBREPLACEOBJ="replace.o" +AC_SUBST(LIBREPLACEOBJ) + +AC_CANONICAL_HOST + +echo "LIBREPLACE_LOCATION_CHECKS: END" +]) dnl end AC_LIBREPLACE_LOCATION_CHECKS + + AC_DEFUN_ONCE(AC_LIBREPLACE_BROKEN_CHECKS, [ echo "LIBREPLACE_BROKEN_CHECKS: START" @@ -298,6 +321,7 @@ AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_END, m4_define(AC_LIBREPLACE_ALL_CHECKS, [ AC__LIBREPLACE_ALL_CHECKS_START +AC_LIBREPLACE_LOCATION_CHECKS AC_LIBREPLACE_CC_CHECKS AC_LIBREPLACE_BROKEN_CHECKS AC__LIBREPLACE_ALL_CHECKS_END diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 5e44da73a3..4f2ce034bf 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -47,8 +47,39 @@ dnl Add #include for broken IRIX header files case "$host_os" in *irix6*) AC_ADD_INCLUDE() ;; + *hpux*) + # mmap on HPUX is completely broken... + AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken]) + ;; + *aix*) + if test "${GCC}" != "yes"; then + ## for funky AIX compiler using strncpy() + CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000" + fi + ;; + # + # VOS may need to have POSIX support and System V compatibility enabled. + # + *vos*) + case "$CFLAGS" in + *-D_POSIX_C_SOURCE*);; + *) + CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L" + AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support]) + ;; + esac + case "$CFLAGS" in + *-D_SYSV*|*-D_SVID_SOURCE*);; + *) + CFLAGS="$CFLAGS -D_SYSV" + AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility]) + ;; + esac + ;; esac + + AC_CHECK_HEADERS([standards.h]) # Solaris needs HAVE_LONG_LONG defined -- cgit From 182ab7107c13046c650f51c0a4a55955cc38fa24 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Sep 2006 20:08:21 +0000 Subject: r18539: 'make distclean' should delete config.cache (This used to be commit 5a8becb1be1b41b4fecf9f9f47a60eed5f77c264) --- source4/lib/replace/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 23a4239913..10ba5b9415 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -53,7 +53,7 @@ clean: distclean: clean rm -f *~ */*~ - rm -f config.log config.status config.h + rm -f config.log config.status config.h config.cache rm -f Makefile realdistclean: distclean -- cgit From 040b5b812e5a92c8a62334ee6ec85af9f5376ec2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Sep 2006 07:54:13 +0000 Subject: r18544: - use AC_LIBREPLACE_LOCATION_CHECKS in samba4 - to get the ordering right we need to specify AC_CANONICAL_BUILD explicit - add AC_CANONICAL_TARGET metze (This used to be commit 1ea52d75849f004752cdbe11a3dddd10b4afe47d) --- source4/lib/replace/libreplace.m4 | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 1d82c00b2b..26c6caae41 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -15,7 +15,9 @@ done LIBREPLACEOBJ="replace.o" AC_SUBST(LIBREPLACEOBJ) +AC_CANONICAL_BUILD AC_CANONICAL_HOST +AC_CANONICAL_TARGET echo "LIBREPLACE_LOCATION_CHECKS: END" ]) dnl end AC_LIBREPLACE_LOCATION_CHECKS -- cgit From a8fd66f91fcb16dd56890f918e47443f2aba3a98 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Sep 2006 10:54:18 +0000 Subject: r18549: move gcc version check to libreplace and reorder the tests a bit for nicer output metze (This used to be commit 888a769af557d050d99df703ce5f651688c837c5) --- source4/lib/replace/libreplace_cc.m4 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 4f2ce034bf..aa0465983a 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -28,19 +28,23 @@ ac_cv_prog_cc_Ae=no savedCFLAGS=$CFLAGS AC_PROG_CC CFLAGS=$savedCFLAGS -AC_ISC_POSIX -AC_USE_SYSTEM_EXTENSIONS AC_PROG_CC_C99 -AC_C_INLINE +if test x"$GCC" = x"yes" ; then + AC_MSG_CHECKING([for version of gcc]) + GCC_VERSION=`$CC -dumpversion` + AC_MSG_RESULT(${GCC_VERSION}) +fi +AC_USE_SYSTEM_EXTENSIONS AC_C_BIGENDIAN -AC_PROG_INSTALL +AC_C_INLINE +LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not supported])]) +AC_PROG_INSTALL +AC_ISC_POSIX AC_EXTENSION_FLAG(_XOPEN_SOURCE_EXTENDED) AC_EXTENSION_FLAG(_OSF_SOURCE) -LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not supported])]) - AC_SYS_LARGEFILE dnl Add #include for broken IRIX header files -- cgit From 6e3b94d3bcaacba0fed4f977248b0fbe6fcd6812 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 15 Sep 2006 19:14:36 +0000 Subject: r18563: - move more of the header checks into lib/replace/ - change the test for net/if.h to do a full compile, not just an existance test. net/if.h is completely broken on hpux, and can never compile (it uses stuff before it defines it), so by using a AC_TRY_COMPILE() test we avoid using net/if.h on hpux, which should fix the build (This used to be commit bde18f3d5ce837f600bae8d63f31d92a579fe1f2) --- source4/lib/replace/libreplace.m4 | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 26c6caae41..d98845f3b4 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -88,6 +88,33 @@ if test x"$samba_cv_HAVE_MMAP" = x"yes"; then fi +AC_CHECK_HEADERS(sys/syslog.h syslog.h) +AC_CHECK_HEADERS(sys/time.h time.h) +AC_CHECK_HEADERS(stdarg.h vararg.h) +AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) +AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) +AC_CHECK_HEADERS(sys/sockio.h sys/un.h) + + +dnl we need to check that net/if.h really can be used, to cope with hpux +dnl where including it always fails +AC_TRY_COMPILE([ + #include + #if STDC_HEADERS + # include + # include + #else + # if HAVE_STDLIB_H + # include + # endif + #endif + #if HAVE_SYS_SOCKET_H + # include + #endif], + [#include ], + AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h)) + + AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ #include @@ -117,10 +144,6 @@ AC_TRY_COMPILE([ [socklen_t foo;],, [AC_DEFINE(socklen_t, int,[Socket length type])]) -AC_CHECK_HEADERS(sys/syslog.h syslog.h) -AC_CHECK_HEADERS(sys/time.h time.h) -AC_CHECK_HEADERS(sys/socket.h netinet/in.h) -AC_CHECK_HEADERS(stdarg.h vararg.h) AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) -- cgit From 5d6a38004ad45ae58a0a064132d383d3d3ee4c99 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 17 Sep 2006 05:10:00 +0000 Subject: r18592: we don't need this twice metze (This used to be commit e9fe725cf4021943e939f493b967e0ef5a438622) --- source4/lib/replace/libreplace.m4 | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index d98845f3b4..677c5c535a 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -219,9 +219,6 @@ if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then fi -LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes, - c99_struct_initialization=no) - dnl VA_COPY AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[ AC_TRY_LINK([#include -- cgit From 4a854fe809ba617336db3e1d277e00c7ef95c55f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 17 Sep 2006 05:11:57 +0000 Subject: r18593: try to get the same socket_wrapper file building in samba3 and samba4 this is preparation of adding libreplace to samba3 later. metze (This used to be commit 26228e4b2e8debd84caebe84bb34bfbbf2ad405c) --- source4/lib/replace/system/network.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 9b73466924..615fcab5c8 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -67,7 +67,9 @@ #endif #ifdef SOCKET_WRAPPER +#ifndef SOCKET_WRAPPER_NOT_REPLACE #define SOCKET_WRAPPER_REPLACE +#endif #include "lib/socket_wrapper/socket_wrapper.h" #endif -- cgit From 550834c9df68377d1308084814870d45d65472df Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 17 Sep 2006 19:17:41 +0000 Subject: r18594: fail the configure step if the required library is not found for tdb, talloc or libreplace (This used to be commit 9f45f970f71ee5585bf3c924b9c77188405fa246) --- source4/lib/replace/libreplace.m4 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 677c5c535a..de8e4ba4a3 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -5,13 +5,17 @@ echo "LIBREPLACE_LOCATION_CHECKS: START" dnl find the libreplace sources. This is meant to work both for dnl libreplace standalone builds, and builds of packages using libreplace libreplacedir="" -for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace" "$srcdir/../replace"; do +libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace" +for d in $libreplacepaths; do if test -f "$d/replace.c"; then libreplacedir="$d" AC_SUBST(libreplacedir) break; fi done +if [ x"$libreplacedir" = "x" ]; then + AC_MSG_ERROR([cannot find libreplace in $libreplacepaths]) +fi LIBREPLACEOBJ="replace.o" AC_SUBST(LIBREPLACEOBJ) -- cgit From e84ee4a6fd3bb1cc0b92de89f4568e0865ccac0a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 18 Sep 2006 01:31:57 +0000 Subject: r18600: - fix shell syntax in tests for libraries - add library test for libpopt (This used to be commit 13878b7e7ec65b21df954f83afc0e9ceb73e44a0) --- source4/lib/replace/libreplace.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index de8e4ba4a3..6c26f7b904 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -13,7 +13,7 @@ for d in $libreplacepaths; do break; fi done -if [ x"$libreplacedir" = "x" ]; then +if test x"$libreplacedir" = "x"; then AC_MSG_ERROR([cannot find libreplace in $libreplacepaths]) fi LIBREPLACEOBJ="replace.o" -- cgit From 550495b6f9af22c47b7fd336e08f1a8eac4534ec Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Sep 2006 03:48:31 +0000 Subject: r18674: merge from samba3, PRINTF_ATTRIBUTE seems to not work with gcc 3.0 metze (This used to be commit dfb9bfba943bb4954101e7e02fa5a68046817162) --- source4/lib/replace/replace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 7cdaaae689..688f08a51d 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -207,7 +207,7 @@ int rep_dlclose(void *handle); #ifndef PRINTF_ATTRIBUTE -#if __GNUC__ >= 3 +#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) /** Use gcc attribute to check printf fns. a1 is the 1-based index of * the parameter containing the format, and a2 the index of the first * argument. Note that some gcc 2.x versions don't handle this -- cgit From 0780eb7f82ed3cfb7c3091e450ee50a2e8055374 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Sep 2006 03:51:45 +0000 Subject: r18675: merge from samba3: we need to define the macros the indicate we have bool even if we have not defining bool ourself metze (This used to be commit 0c18e5d9383883f696113837a9e2d1bc078f18b1) --- source4/lib/replace/replace.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 688f08a51d..61adb999d9 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -324,11 +324,27 @@ char *rep_mkdtemp(char *template); #ifdef HAVE__Bool #define bool _Bool #else -#define __bool_true_false_are_defined typedef int bool; #endif #endif +/* + * to prevent from doing a redefine of 'bool' + * + * IRIX, HPUX, MacOS 10 and Solaris need BOOL_DEFINED + * Tru64 needs _BOOL_EXISTS + */ +#ifndef BOOL_DEFINED +#define BOOL_DEFINED +#endif +#ifndef _BOOL_EXISTS +#define _BOOL_EXISTS +#endif + +#ifndef __bool_true_false_are_defined +#define __bool_true_false_are_defined +#endif + #ifndef true #define true (1) #endif -- cgit From 22f5fed6a689818fbe25daed5998f3192d4f30ea Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Sep 2006 17:29:34 +0000 Subject: r18723: Update list of provided macros/defines in README. (This used to be commit 5e951bdeec2d7d872410fafb9f051eb4340b6e50) --- source4/lib/replace/README | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index fd630ddc45..182a276116 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -65,6 +65,12 @@ Constants: PATH_NAME_MAX UINT{16,32,64}_MAX INT32_MAX +RTLD_LAZY +HOST_NAME_MAX +UINT16_MAX +UINT32_MAX +UINT64_MAX +CHAR_BIT Macros: va_copy @@ -72,6 +78,7 @@ __FUNCTION__ __STRING MIN MAX +QSORT_CAST Prerequisites: memset (for bzero) -- cgit From 85ba30961baaec34a58b79e72ac1e483daa75aa1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Sep 2006 04:48:41 +0000 Subject: r18769: Re-enable __VA_ARGS__ test (but don't make it fatal) (This used to be commit cc8c403de8c6558031c14f929a485361b7eb0222) --- source4/lib/replace/libreplace.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 6c26f7b904..804f998b9e 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -267,10 +267,10 @@ AC_CHECK_FUNCS(strnlen setenv) AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) # this test disabled as we don't actually need __VA_ARGS__ yet -# AC_TRY_CPP([ -# #define eprintf(...) fprintf(stderr, __VA_ARGS__) -# eprintf("bla", "bar"); -# ], [], [AC_MSG_ERROR([__VA_ARGS__ is required])]) +AC_TRY_CPP([ +#define eprintf(...) fprintf(stderr, __VA_ARGS__) +eprintf("bla", "bar"); +], AC_DEFINE(HAVE__VA_ARGS__MACRO, 1, [Whether the __VA_ARGS__ macro is available])) # Check prerequisites AC_CHECK_FUNCS([memset printf syslog], [], -- cgit From a90eba6316b89c3e387e0c52af22b5344a5de2f2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 24 Sep 2006 01:52:20 +0000 Subject: r18859: finally worked out what is going wrong with immediate structures. The problem is that the AC_PROG_CC_C99 macro ends up selecting either -std=std99 or -std=gnu99 for gcc. Ironically enough, that breaks constant structure initialisers! So, simplest solution is to not try that configure test if we know we are using gcc (This used to be commit 331435daf3275acaf282c1032c6e9f7dc3e685bb) --- source4/lib/replace/libreplace_cc.m4 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index aa0465983a..352d115547 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -28,7 +28,13 @@ ac_cv_prog_cc_Ae=no savedCFLAGS=$CFLAGS AC_PROG_CC CFLAGS=$savedCFLAGS + +dnl don't try for C99 if we are using gcc, as otherwise we +dnl lose immediate structure constants +if test x"$GCC" = x"no" ; then AC_PROG_CC_C99 +fi + if test x"$GCC" = x"yes" ; then AC_MSG_CHECKING([for version of gcc]) GCC_VERSION=`$CC -dumpversion` @@ -122,5 +128,26 @@ if test $ac_cv_sizeof_long_long -lt 8;then AC_MSG_ERROR([LIBREPLACE needs sizeof(long long) >= 8]) fi +############################################ +# check if the compiler can do immediate structures +AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [ + AC_TRY_COMPILE([ +#include ], +[ + typedef struct {unsigned x;} FOOBAR; + #define X_FOOBAR(x) ((FOOBAR) { x }) + #define FOO_ONE X_FOOBAR(1) + FOOBAR f = FOO_ONE; + static const struct { + FOOBAR y; + } f2[] = { + {FOO_ONE} + }; +], + samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)]) +if test x"$samba_cv_immediate_structures" = x"yes"; then + AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures]) +fi + AC__LIBREPLACE_ONLY_CC_CHECKS_END ]) dnl end AC_LIBREPLACE_CC_CHECKS -- cgit From 311e26246c62af508c25895b6c0d93b1f572c2c7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 24 Sep 2006 02:06:05 +0000 Subject: r18861: merge from samba3 (This used to be commit c5e2fcdc10a0869264bb1c6a13ada5f12e1b655f) --- source4/lib/replace/replace.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 61adb999d9..edcdebe6bd 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -333,6 +333,7 @@ typedef int bool; * * IRIX, HPUX, MacOS 10 and Solaris need BOOL_DEFINED * Tru64 needs _BOOL_EXISTS + * AIX needs _BOOL,_TRUE,_FALSE */ #ifndef BOOL_DEFINED #define BOOL_DEFINED @@ -340,6 +341,9 @@ typedef int bool; #ifndef _BOOL_EXISTS #define _BOOL_EXISTS #endif +#ifndef _BOOL +#define _BOOL +#endif #ifndef __bool_true_false_are_defined #define __bool_true_false_are_defined @@ -352,6 +356,13 @@ typedef int bool; #define false (0) #endif +#ifndef _TRUE +#define _TRUE +#endif +#ifndef _FALSE +#define _FALSE +#endif + #ifndef HAVE_FUNCTION_MACRO #ifdef HAVE_func_MACRO #define __FUNCTION__ __func__ -- cgit From 2b2c7ee2f0b5319afde788e244af9dc161500a4c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 24 Sep 2006 02:13:52 +0000 Subject: r18862: as andrew pointed our on irc, if we are going to define _TRUE, then better make it be true :) (This used to be commit 4bda5ed3f9fda437c3f9b7e8ce83853999601c74) --- source4/lib/replace/replace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index edcdebe6bd..01f626390c 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -357,10 +357,10 @@ typedef int bool; #endif #ifndef _TRUE -#define _TRUE +#define _TRUE true #endif #ifndef _FALSE -#define _FALSE +#define _FALSE false #endif #ifndef HAVE_FUNCTION_MACRO -- cgit From ed7639a3042c902bbab8633ef45fd30de85d214c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 26 Sep 2006 03:11:31 +0000 Subject: r18913: an attempt to get tdb/ldb working on the HPUX box 'gwen'. This idea come from Don McCall. Don may well be able to provide us with a configure test in the future which does this in a nicer way, I just want to see if it works now. (This used to be commit f7f548a1c79a78a1b15e96732994135cba94aa3d) --- source4/lib/replace/libreplace_cc.m4 | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 352d115547..37c1551351 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -60,6 +60,7 @@ case "$host_os" in *hpux*) # mmap on HPUX is completely broken... AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken]) + CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" ;; *aix*) if test "${GCC}" != "yes"; then -- cgit From 410256e75aa720b4d88822ae415b44556bb79464 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 26 Sep 2006 05:40:57 +0000 Subject: r18914: this bug fix needs to be for just hpux 11.11 (This used to be commit 2cccede13d34011767159c3345bb6da24ed09bd3) --- source4/lib/replace/libreplace_cc.m4 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 37c1551351..b3b2b0d2bb 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -60,7 +60,10 @@ case "$host_os" in *hpux*) # mmap on HPUX is completely broken... AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken]) - CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" + if test "`uname -r`" = "B.11.11"; then + AC_MSG_WARN([Enabling HPUX 11.11 header bug workaround]) + CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" + fi ;; *aix*) if test "${GCC}" != "yes"; then -- cgit From 174742a74ce448d1944ada9dd602aadf20bce6f8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 27 Sep 2006 10:13:45 +0000 Subject: r18947: overload listen() and ioctl() in socket_wrapper metze (This used to be commit dfaccdca1b6954cd61828749d7b000f804f3b066) --- source4/lib/replace/system/network.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 615fcab5c8..a21f8e2eaf 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -66,6 +66,10 @@ #include #endif +#ifdef HAVE_SYS_IOCTL_H +#include +#endif + #ifdef SOCKET_WRAPPER #ifndef SOCKET_WRAPPER_NOT_REPLACE #define SOCKET_WRAPPER_REPLACE -- cgit From c0c135c774fccc9a1ac6b6a40817ff4207df9478 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 27 Sep 2006 14:16:32 +0000 Subject: r18957: we need to include unistd.h in system/network.h because it contains the ioctl() prototype on some systems and we need to make sure it gets included before socket_wrapper defines ioctl swrap_ioctl metze (This used to be commit f37b13cbe65404f27d31b8020afb2f542313f4d3) --- source4/lib/replace/system/network.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index a21f8e2eaf..5e648dcd15 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -66,6 +66,10 @@ #include #endif +#ifdef HAVE_UNISTD_H +#include +#endif + #ifdef HAVE_SYS_IOCTL_H #include #endif -- cgit From 3f96df61dadb107867c174880029838c5c850cd3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 27 Sep 2006 14:47:00 +0000 Subject: r18960: fix caching of some configure tests AC_CACHE_CHECK() *needs* '_cv_' in the shell var to do caching... metze (This used to be commit cb334632fae28bff107200a7b5643289f383eaad) --- source4/lib/replace/dlfcn.m4 | 6 +++--- source4/lib/replace/repdir.m4 | 34 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.m4 b/source4/lib/replace/dlfcn.m4 index 0f099f4bac..c9d31592e0 100644 --- a/source4/lib/replace/dlfcn.m4 +++ b/source4/lib/replace/dlfcn.m4 @@ -6,10 +6,10 @@ AC_SEARCH_LIBS(dlopen, dl) AC_CHECK_HEADERS(dlfcn.h) -libreplace_dlfcn=no -AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_dlfcn=yes]) +libreplace_cv_dlfcn=no +AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_cv_dlfcn=yes]) -if test x"${libreplace_dlfcn}" = x"yes";then +if test x"${libreplace_cv_dlfcn}" = x"yes";then LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o" fi diff --git a/source4/lib/replace/repdir.m4 b/source4/lib/replace/repdir.m4 index 93bf4ec911..81025d618a 100644 --- a/source4/lib/replace/repdir.m4 +++ b/source4/lib/replace/repdir.m4 @@ -1,38 +1,38 @@ -AC_CACHE_CHECK([for broken readdir],libreplace_READDIR_NEEDED,[ +AC_CACHE_CHECK([for broken readdir],libreplace_cv_READDIR_NEEDED,[ AC_TRY_RUN([ #define test_readdir_os2_delete main #include "$libreplacedir/test/os2_delete.c"], - [libreplace_READDIR_NEEDED=no], - [libreplace_READDIR_NEEDED=yes], - [libreplace_READDIR_NEEDED="assuming not"]) + [libreplace_cv_READDIR_NEEDED=no], + [libreplace_cv_READDIR_NEEDED=yes], + [libreplace_cv_READDIR_NEEDED="assuming not"]) ]) # # try to replace with getdents() if needed # -if test x"$libreplace_READDIR_NEEDED" = x"yes"; then +if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then AC_CHECK_FUNCS(getdents) -AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_READDIR_GETDENTS,[ +AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_cv_READDIR_GETDENTS,[ AC_TRY_RUN([ #define _LIBREPLACE_REPLACE_H #include "$libreplacedir/repdir_getdents.c" #define test_readdir_os2_delete main #include "$libreplacedir/test/os2_delete.c"], - [libreplace_READDIR_GETDENTS=yes], - [libreplace_READDIR_GETDENTS=no]) + [libreplace_cv_READDIR_GETDENTS=yes], + [libreplace_cv_READDIR_GETDENTS=no]) ]) fi -if test x"$libreplace_READDIR_GETDENTS" = x"yes"; then +if test x"$libreplace_cv_READDIR_GETDENTS" = x"yes"; then AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()]) LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdents.o" - libreplace_READDIR_NEEDED=no + libreplace_cv_READDIR_NEEDED=no fi # # try to replace with getdirentries() if needed # -if test x"$libreplace_READDIR_NEEDED" = x"yes"; then +if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then AC_CHECK_FUNCS(getdirentries) AC_VERIFY_C_PROTOTYPE([long telldir(const DIR *dir)], [ @@ -51,25 +51,25 @@ AC_VERIFY_C_PROTOTYPE([int seekdir(DIR *dir, long ofs)], ],[],[ #include ]) -AC_CACHE_CHECK([for replacing readdir using getdirentries()],libreplace_READDIR_GETDIRENTRIES,[ +AC_CACHE_CHECK([for replacing readdir using getdirentries()],libreplace_cv_READDIR_GETDIRENTRIES,[ AC_TRY_RUN([ #define _LIBREPLACE_REPLACE_H #include "$libreplacedir/repdir_getdirentries.c" #define test_readdir_os2_delete main #include "$libreplacedir/test/os2_delete.c"], - [libreplace_READDIR_GETDIRENTRIES=yes], - [libreplace_READDIR_GETDIRENTRIES=no]) + [libreplace_cv_READDIR_GETDIRENTRIES=yes], + [libreplace_cv_READDIR_GETDIRENTRIES=no]) ]) fi -if test x"$libreplace_READDIR_GETDIRENTRIES" = x"yes"; then +if test x"$libreplace_cv_READDIR_GETDIRENTRIES" = x"yes"; then AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) AC_DEFINE(REPLACE_READDIR_GETDIRENTRIES,1,[replace readdir using getdirentries()]) LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdirentries.o" - libreplace_READDIR_NEEDED=no + libreplace_cv_READDIR_NEEDED=no fi AC_MSG_CHECKING([a usable readdir()]) -if test x"$libreplace_READDIR_NEEDED" = x"yes"; then +if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then AC_MSG_RESULT(no) AC_MSG_WARN([the provided readdir() is broken]) else -- cgit From 2550f5ae126bf33148dabf30ae97b6d6d82e30a0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Sep 2006 06:43:27 +0000 Subject: r18970: avoid strndup and strnlen on AIX. They are quite broken. See http://lists.samba.org/archive/samba-technical/2004-August/036915.html (This used to be commit c178c84f01166609e6bd3393d39fb0034130167b) --- source4/lib/replace/libreplace_cc.m4 | 2 ++ source4/lib/replace/replace.h | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index b3b2b0d2bb..73ce01700e 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -66,6 +66,8 @@ case "$host_os" in fi ;; *aix*) + AC_DEFINE(BROKEN_STRNDUP, 1, [Whether strndup is broken]) + AC_DEFINE(BROKEN_STRNLEN, 1, [Whether strnlen is broken]) if test "${GCC}" != "yes"; then ## for funky AIX compiler using strncpy() CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000" diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 01f626390c..a6c7f3b9dd 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -121,12 +121,14 @@ size_t rep_strlcpy(char *d, const char *s, size_t bufsize); size_t rep_strlcat(char *d, const char *s, size_t bufsize); #endif -#ifndef HAVE_STRNDUP +#if (defined(BROKEN_STRNDUP) || !defined(HAVE_STRNDUP)) +#undef HAVE_STRNDUP #define strndup rep_strndup char *rep_strndup(const char *s, size_t n); #endif -#ifndef HAVE_STRNLEN +#if (defined(BROKEN_STRNLEN) || !defined(HAVE_STRNLEN)) +#undef HAVE_STRNLEN #define strnlen rep_strnlen size_t rep_strnlen(const char *s, size_t n); #endif -- cgit From 9f98bcf6a8e53a04c9c5d5fe2114eb5ac2b90c38 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 29 Sep 2006 09:12:55 +0000 Subject: r18991: Fix bug 4133 -- Thanks to Olaf Flebbe (This used to be commit d8bea42bb78619ae35a9680b24fe9eee5f25997d) --- source4/lib/replace/replace.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index a6c7f3b9dd..b24724ec8e 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -153,6 +153,13 @@ int rep_setegid(gid_t); void rep_setlinebuf(FILE *); #endif +#ifndef HAVE_VSYSLOG +#ifdef HAVE_SYSLOG +#define vsyslog rep_vsyslog +void rep_vsyslog (int facility_priority, char *format, va_list arglist); +#endif +#endif + #ifndef HAVE_STRCASESTR #define strcasestr rep_strcasestr char *rep_strcasestr(const char *haystack, const char *needle); -- cgit From e8a005acfe15462b2f7e2aaa66a585d6da098a09 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 29 Sep 2006 12:38:51 +0000 Subject: r18999: merge from samba3: - make more usage of PRINTF_ATTRIBUTE() - vsyslog takes a 'const char *format' metze (This used to be commit cdcd4232d2f383f4d2f9ca1d049b7b3cc7b58359) --- source4/lib/replace/replace.c | 2 +- source4/lib/replace/replace.h | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index aa3e8717c2..e7f47d7d52 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -346,7 +346,7 @@ void rep_setlinebuf(FILE *stream) #ifndef HAVE_VSYSLOG #ifdef HAVE_SYSLOG -void rep_vsyslog (int facility_priority, char *format, va_list arglist) +void rep_vsyslog (int facility_priority, const char *format, va_list arglist) { char *msg = NULL; vasprintf(&msg, format, arglist); diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index b24724ec8e..8943c7d637 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -153,13 +153,6 @@ int rep_setegid(gid_t); void rep_setlinebuf(FILE *); #endif -#ifndef HAVE_VSYSLOG -#ifdef HAVE_SYSLOG -#define vsyslog rep_vsyslog -void rep_vsyslog (int facility_priority, char *format, va_list arglist); -#endif -#endif - #ifndef HAVE_STRCASESTR #define strcasestr rep_strcasestr char *rep_strcasestr(const char *haystack, const char *needle); @@ -229,7 +222,7 @@ int rep_dlclose(void *handle); #ifndef HAVE_VASPRINTF #define vasprintf rep_vasprintf -int rep_vasprintf(char **ptr, const char *format, va_list ap); +int rep_vasprintf(char **ptr, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0); #endif #if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF) @@ -239,7 +232,7 @@ int rep_snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4); #if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) #define vsnprintf rep_vsnprintf -int rep_vsnprintf(char *,size_t ,const char *, va_list ap); +int rep_vsnprintf(char *,size_t ,const char *, va_list ap) PRINTF_ATTRIBUTE(3,0); #endif #ifndef HAVE_ASPRINTF @@ -247,6 +240,12 @@ int rep_vsnprintf(char *,size_t ,const char *, va_list ap); int rep_asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3); #endif +#ifndef HAVE_VSYSLOG +#ifdef HAVE_SYSLOG +#define vsyslog rep_vsyslog +void rep_vsyslog (int facility_priority, const char *format, va_list arglist) PRINTF_ATTRIBUTE(2,0); +#endif +#endif /* we used to use these fns, but now we have good replacements for snprintf and vsnprintf */ -- cgit From 127c96f49905291b4566c2a1bc25d882ae111466 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 1 Oct 2006 20:45:46 +0000 Subject: r19017: Merge from Samba3: Attempt to fix the BSD RAW-CHKPATH failures: In Samba3 we rely on opendir returning ENOTDIR when the file opened is not a directory. Can we merge this back into Samba4? This includes the tabs->spaces fix requested by Stefan. Volker (This used to be commit 7b9ee1171ddc89537ba3b286f20c722fb70c980b) --- source4/lib/replace/repdir_getdents.c | 12 ++++++++++++ source4/lib/replace/repdir_getdirentries.c | 12 ++++++++++++ 2 files changed, 24 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir_getdents.c b/source4/lib/replace/repdir_getdents.c index 07b9568dc1..6b115c4c4f 100644 --- a/source4/lib/replace/repdir_getdents.c +++ b/source4/lib/replace/repdir_getdents.c @@ -68,6 +68,7 @@ struct dir_buf { DIR *opendir(const char *dname) { struct dir_buf *d; + struct stat sb; d = malloc(sizeof(*d)); if (d == NULL) { errno = ENOMEM; @@ -78,6 +79,17 @@ DIR *opendir(const char *dname) free(d); return NULL; } + if (fstat(d->fd, &sb) < 0) { + close(d->fd); + free(d); + return NULL; + } + if (!S_ISDIR(sb.st_mode)) { + close(d->fd); + free(d); + errno = ENOTDIR; + return NULL; + } d->ofs = 0; d->seekpos = 0; d->nbytes = 0; diff --git a/source4/lib/replace/repdir_getdirentries.c b/source4/lib/replace/repdir_getdirentries.c index 9e4b63145c..a6026dfb5d 100644 --- a/source4/lib/replace/repdir_getdirentries.c +++ b/source4/lib/replace/repdir_getdirentries.c @@ -70,6 +70,7 @@ struct dir_buf { DIR *opendir(const char *dname) { struct dir_buf *d; + struct stat sb; d = malloc(sizeof(*d)); if (d == NULL) { errno = ENOMEM; @@ -80,6 +81,17 @@ DIR *opendir(const char *dname) free(d); return NULL; } + if (fstat(d->fd, &sb) < 0) { + close(d->fd); + free(d); + return NULL; + } + if (!S_ISDIR(sb.st_mode)) { + close(d->fd); + free(d); + errno = ENOTDIR; + return NULL; + } d->ofs = 0; d->seekpos = 0; d->nbytes = 0; -- cgit From c4f106c4148965a6cb302d2d1dff730058fe5fc4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Oct 2006 05:52:42 +0000 Subject: r19023: lets see what the build-farm says about trying the getdirentries() based readdir() replacement first. metze (This used to be commit 268c8bc7ef63ca7fd7900bd0aec345b895512c68) --- source4/lib/replace/repdir.m4 | 44 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir.m4 b/source4/lib/replace/repdir.m4 index 81025d618a..7bff47d615 100644 --- a/source4/lib/replace/repdir.m4 +++ b/source4/lib/replace/repdir.m4 @@ -7,28 +7,6 @@ AC_CACHE_CHECK([for broken readdir],libreplace_cv_READDIR_NEEDED,[ [libreplace_cv_READDIR_NEEDED="assuming not"]) ]) -# -# try to replace with getdents() if needed -# -if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then -AC_CHECK_FUNCS(getdents) -AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_cv_READDIR_GETDENTS,[ - AC_TRY_RUN([ -#define _LIBREPLACE_REPLACE_H -#include "$libreplacedir/repdir_getdents.c" -#define test_readdir_os2_delete main -#include "$libreplacedir/test/os2_delete.c"], - [libreplace_cv_READDIR_GETDENTS=yes], - [libreplace_cv_READDIR_GETDENTS=no]) -]) -fi -if test x"$libreplace_cv_READDIR_GETDENTS" = x"yes"; then - AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) - AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()]) - LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdents.o" - libreplace_cv_READDIR_NEEDED=no -fi - # # try to replace with getdirentries() if needed # @@ -68,6 +46,28 @@ if test x"$libreplace_cv_READDIR_GETDIRENTRIES" = x"yes"; then libreplace_cv_READDIR_NEEDED=no fi +# +# try to replace with getdents() if needed +# +if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then +AC_CHECK_FUNCS(getdents) +AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_cv_READDIR_GETDENTS,[ + AC_TRY_RUN([ +#define _LIBREPLACE_REPLACE_H +#include "$libreplacedir/repdir_getdents.c" +#define test_readdir_os2_delete main +#include "$libreplacedir/test/os2_delete.c"], + [libreplace_cv_READDIR_GETDENTS=yes], + [libreplace_cv_READDIR_GETDENTS=no]) +]) +fi +if test x"$libreplace_cv_READDIR_GETDENTS" = x"yes"; then + AC_DEFINE(REPLACE_READDIR,1,[replace readdir]) + AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()]) + LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdents.o" + libreplace_cv_READDIR_NEEDED=no +fi + AC_MSG_CHECKING([a usable readdir()]) if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then AC_MSG_RESULT(no) -- cgit From 37806f79cd612ab390e277ae4b1afac86413e979 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Oct 2006 08:56:35 +0000 Subject: r19029: test if opendir() on a file sets errno = ENOTDIR metze (This used to be commit 6b5f06b059583f9d685d71d48299ab334581c179) --- source4/lib/replace/test/os2_delete.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index d0aadb24ba..8501e0bb40 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -21,7 +21,7 @@ static int test_readdir_os2_delete_ret; -#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) +#define FAILED(d) (fprintf(stderr, "Failed for %s - %d = %s\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -87,7 +87,11 @@ int test_readdir_os2_delete(void) cleanup(); create_files(); - + + d = opendir(TESTDIR "/test0.txt"); + if (d != NULL) FAILED("opendir() on file succeed"); + if (errno != ENOTDIR) FAILED("opendir() on file didn't give ENOTDIR"); + d = opendir(TESTDIR); /* skip past . and .. */ -- cgit From 03cb0224d4dc93e530342e73001a30722cdf75d1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Oct 2006 09:26:05 +0000 Subject: r19032: let the getdents replacement fail and see what the build-farm says. metze (This used to be commit 4ed53dfafcbafbad8f2cde65e84dc0fe32fa62f8) --- source4/lib/replace/repdir.m4 | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/repdir.m4 b/source4/lib/replace/repdir.m4 index 7bff47d615..f53a4c2974 100644 --- a/source4/lib/replace/repdir.m4 +++ b/source4/lib/replace/repdir.m4 @@ -54,6 +54,7 @@ AC_CHECK_FUNCS(getdents) AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_cv_READDIR_GETDENTS,[ AC_TRY_RUN([ #define _LIBREPLACE_REPLACE_H +#error _donot_use_getdents_replacement_anymore #include "$libreplacedir/repdir_getdents.c" #define test_readdir_os2_delete main #include "$libreplacedir/test/os2_delete.c"], -- cgit From 6ddc797e3a6a5852c0d587ed1206f84e95b54210 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Oct 2006 10:35:40 +0000 Subject: r19033: prepare to use the libreplace testsuite as LOCAL-REPLACE in smbtorture metze (This used to be commit 71fc73e11cee89f1b52cda5a32468a74a38cecc3) --- source4/lib/replace/test/testsuite.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 6644fce6bd..fa5265f66f 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -89,7 +89,7 @@ static int test_strlcpy(void) char buf[4]; const struct { const char *src; - int result; + size_t result; } tests[] = { { "abc", 3 }, { "abcdef", 6 }, @@ -373,9 +373,11 @@ static int test_MAX(void) return true; } -int torture_local_replace(void *ctx) +struct torture_context; + +bool torture_local_replace(struct torture_context *torture) { - int ret = true; + bool ret = true; ret &= test_ftruncate(); ret &= test_strlcpy(); ret &= test_strlcat(); @@ -423,7 +425,7 @@ int torture_local_replace(void *ctx) return ret; } -#if !defined(_SAMBA_BUILD_) || ((SAMBA_VERSION_MAJOR==3)&&(SAMBA_VERSION_MINOR<9)) +#if _SAMBA_BUILD_<4 int main(void) { if (!torture_local_replace(NULL)) { -- cgit From 0f60472cb24b03b59114e5dc03918b75c652cb08 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 6 Oct 2006 07:44:36 +0000 Subject: r19116: fixed a checker warning (This used to be commit 48243721df27fa68b3232d71b411fba1e0ab7010) --- source4/lib/replace/test/testsuite.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index fa5265f66f..d45304103f 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -231,14 +231,12 @@ static int test_opendir(void) extern int test_readdir_os2_delete(void); -static bool test_readdir(void) +static int test_readdir(void) { printf("testing readdir\n"); if (test_readdir_os2_delete() != 0) { return false; } - - /* FIXME */ return true; } @@ -400,7 +398,7 @@ bool torture_local_replace(struct torture_context *torture) ret &= test_vasprintf(); ret &= test_vsnprintf(); ret &= test_opendir(); - ret &= test_readdir() ; + ret &= test_readdir(); ret &= test_telldir(); ret &= test_seekdir(); ret &= test_dlopen(); -- cgit From 8f3c1e9fdb494e2ceeff4151a403a74c3676a9fd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 6 Oct 2006 07:45:31 +0000 Subject: r19117: I've changed the checker wrapper on snab to allow for a .checker_innocent file, similar to our .valgrind_suppressions file. (This used to be commit 8228efdb93be20cc3255fbd55336fac89d1bc2d9) --- source4/lib/replace/.checker_innocent | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 source4/lib/replace/.checker_innocent (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/.checker_innocent b/source4/lib/replace/.checker_innocent new file mode 100644 index 0000000000..b39d331ff1 --- /dev/null +++ b/source4/lib/replace/.checker_innocent @@ -0,0 +1,3 @@ +>>>MISTAKE21_create_files_6a9e68ada99a97cb +>>>MISTAKE21_os2_delete_9b2bfa7f38711d09 +>>>MISTAKE21_os2_delete_2fcc29aaa99a97cb -- cgit From 5efcccb2593038641af3416169f1bce497cad047 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 6 Oct 2006 10:17:52 +0000 Subject: r19120: silence a warning about a test function (This used to be commit 59915150f0e303222a16f9d08d3ab31db4e4c617) --- source4/lib/replace/.checker_innocent | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/.checker_innocent b/source4/lib/replace/.checker_innocent index b39d331ff1..e619176540 100644 --- a/source4/lib/replace/.checker_innocent +++ b/source4/lib/replace/.checker_innocent @@ -1,3 +1,4 @@ >>>MISTAKE21_create_files_6a9e68ada99a97cb >>>MISTAKE21_os2_delete_9b2bfa7f38711d09 >>>MISTAKE21_os2_delete_2fcc29aaa99a97cb +>>>SECURITY2_os2_delete_9b2bfa7f1c9396ca -- cgit From 2210d51e4e6f554d5c97e1a918db7353b2c74606 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Oct 2006 11:01:05 +0000 Subject: r19122: merge from samba3: sync system/iconv.h metze (This used to be commit 9c74964b619fd0754d3b72c21fe2cef4d24e7ad5) --- source4/lib/replace/system/iconv.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/iconv.h b/source4/lib/replace/system/iconv.h index 75ee1d83ba..abc2d6f4e1 100644 --- a/source4/lib/replace/system/iconv.h +++ b/source4/lib/replace/system/iconv.h @@ -22,14 +22,27 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#if !defined(HAVE_ICONV) && defined(HAVE_ICONV_H) +#define HAVE_ICONV +#endif + +#if !defined(HAVE_GICONV) && defined(HAVE_GICONV_H) +#define HAVE_GICONV +#endif + +#if !defined(HAVE_BICONV) && defined(HAVE_BICONV_H) +#define HAVE_BICONV +#endif + #ifdef HAVE_NATIVE_ICONV -#ifdef HAVE_ICONV_H +#if defined(HAVE_ICONV) #include -#endif -#ifdef HAVE_GICONV_H +#elif defined(HAVE_GICONV) #include +#elif defined(HAVE_BICONV) +#include #endif -#endif +#endif /* HAVE_NATIVE_ICONV */ /* needed for some systems without iconv. Doesn't really matter what error code we use */ -- cgit From ff4e8321303c4ffbd47b762730c3b5f591554654 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Oct 2006 14:04:05 +0000 Subject: r19131: merge from samba3: fix the logic for the AC_PROG_CC_C99 test metze (This used to be commit 5ccc020639b72a75edfc7f29775b298acf27216e) --- source4/lib/replace/libreplace_cc.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 73ce01700e..77bb5a0598 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -31,7 +31,7 @@ CFLAGS=$savedCFLAGS dnl don't try for C99 if we are using gcc, as otherwise we dnl lose immediate structure constants -if test x"$GCC" = x"no" ; then +if test x"$GCC" != x"yes" ; then AC_PROG_CC_C99 fi -- cgit From 2e059dec541e580df3cb9c62f47c275051bae899 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 8 Oct 2006 21:09:21 +0000 Subject: r19173: see if HPUX 11.23 needs the same workaround as 11.11 metze (This used to be commit 896326d5081da6a20babacf4c28c556fa44216c5) --- source4/lib/replace/libreplace_cc.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 77bb5a0598..6bbea2977b 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -64,6 +64,10 @@ case "$host_os" in AC_MSG_WARN([Enabling HPUX 11.11 header bug workaround]) CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" fi + if test "`uname -r`" = "B.11.23"; then + AC_MSG_WARN([Enabling HPUX 11.23 header bug workaround]) + CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" + fi ;; *aix*) AC_DEFINE(BROKEN_STRNDUP, 1, [Whether strndup is broken]) -- cgit From fd2e67dadff656314b0de72116a97dd1d8080c68 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 9 Oct 2006 07:33:41 +0000 Subject: r19186: that doesn't help... metze (This used to be commit 59c6d51ab31d9d686de35024509f08f5de41c788) --- source4/lib/replace/libreplace_cc.m4 | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 6bbea2977b..77bb5a0598 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -64,10 +64,6 @@ case "$host_os" in AC_MSG_WARN([Enabling HPUX 11.11 header bug workaround]) CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" fi - if test "`uname -r`" = "B.11.23"; then - AC_MSG_WARN([Enabling HPUX 11.23 header bug workaround]) - CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" - fi ;; *aix*) AC_DEFINE(BROKEN_STRNDUP, 1, [Whether strndup is broken]) -- cgit From d66e80c650ac16c9553223aac0cce7989831569b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 9 Oct 2006 09:12:57 +0000 Subject: r19195: this should fix should workaround the broken HPUX 11.23 on host hpisgr8 in the build-farm. metze (This used to be commit 88adbd744355284df223f5618bd76e3d327055d8) --- source4/lib/replace/libreplace_cc.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 77bb5a0598..c86f3d3014 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -64,6 +64,10 @@ case "$host_os" in AC_MSG_WARN([Enabling HPUX 11.11 header bug workaround]) CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" fi + if test "`uname -r`" = "B.11.11"; then + AC_MSG_WARN([Enabling HPUX 11.23 machine/sys/getppdp.h bug workaround]) + CFLAGS="$CFLAGS -D_MACHINE_SYS_GETPPDP_INCLUDED" + fi ;; *aix*) AC_DEFINE(BROKEN_STRNDUP, 1, [Whether strndup is broken]) -- cgit From 0019163d85fce2e83cd3e6193479b59e88d37d98 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 9 Oct 2006 10:44:14 +0000 Subject: r19198: fix typo... metze (This used to be commit 70bab6edfc1c8e52dfa3ff0f02059a2af6086589) --- source4/lib/replace/libreplace_cc.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index c86f3d3014..b8b74036e5 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -64,7 +64,7 @@ case "$host_os" in AC_MSG_WARN([Enabling HPUX 11.11 header bug workaround]) CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" fi - if test "`uname -r`" = "B.11.11"; then + if test "`uname -r`" = "B.11.23"; then AC_MSG_WARN([Enabling HPUX 11.23 machine/sys/getppdp.h bug workaround]) CFLAGS="$CFLAGS -D_MACHINE_SYS_GETPPDP_INCLUDED" fi -- cgit From d067ee2105ac1d64c2b106869fbf93b991f52e11 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 10 Oct 2006 09:32:02 +0000 Subject: r19227: - add a AC_CACHE_CHECK() around the net/if.h test to see (we now get some output that this test happens at all...). - make use of AC_INCLUDES_DEFAULT metze (This used to be commit 7e399e607c8e9bf7365de7d492d29377177cdc1f) --- source4/lib/replace/libreplace.m4 | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 804f998b9e..662993cb79 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -102,22 +102,21 @@ AC_CHECK_HEADERS(sys/sockio.h sys/un.h) dnl we need to check that net/if.h really can be used, to cope with hpux dnl where including it always fails -AC_TRY_COMPILE([ - #include - #if STDC_HEADERS - # include - # include - #else - # if HAVE_STDLIB_H - # include - # endif - #endif - #if HAVE_SYS_SOCKET_H - # include - #endif], - [#include ], - AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h)) - +AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[ + AC_COMPILE_IFELSE([ + AC_INCLUDES_DEFAULT + #if HAVE_SYS_SOCKET_H + # include + #endif + #include + int main(void) {return 0;}], + [libreplace_cv_USABLE_NET_IF_H=yes], + [libreplace_cv_USABLE_NET_IF_H=no] + ) +]) +if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then + AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) +fi AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ -- cgit From 5916c6c469da4d571bb7adb8d25c51a1882cf68e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 11 Oct 2006 07:19:00 +0000 Subject: r19234: fix configure test for net/if.h for some platforms AC_LANG_SOURCE() causes to have the content of confdefs.h in front of the file that will be compiled metze (This used to be commit cd03738e7c5610c4a0cb1161b9bcee5d7c88322d) --- source4/lib/replace/libreplace.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 662993cb79..d74ee6ed1e 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -103,13 +103,13 @@ AC_CHECK_HEADERS(sys/sockio.h sys/un.h) dnl we need to check that net/if.h really can be used, to cope with hpux dnl where including it always fails AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[ - AC_COMPILE_IFELSE([ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ AC_INCLUDES_DEFAULT #if HAVE_SYS_SOCKET_H # include #endif #include - int main(void) {return 0;}], + int main(void) {return 0;}])], [libreplace_cv_USABLE_NET_IF_H=yes], [libreplace_cv_USABLE_NET_IF_H=no] ) -- cgit From b6582987fe25ef3d54034f2f27a052664a298f3e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 11 Oct 2006 11:52:49 +0000 Subject: r19242: merge from samba3: handle NO_CONFIG_H in libreplace metze (This used to be commit 909d736a4bf5a7adfcd64eecf6bb2a92211c6f96) --- source4/lib/replace/replace.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 8943c7d637..7a79f335e2 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -28,7 +28,9 @@ #ifndef _LIBREPLACE_REPLACE_H #define _LIBREPLACE_REPLACE_H +#ifndef NO_CONFIG_H #include "config.h" +#endif #ifdef HAVE_STANDARDS_H #include -- cgit From 2bdaccaa9c794f901ddd10b57b67b8aa21ef5285 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 11 Oct 2006 13:36:37 +0000 Subject: r19245: mrege from samba3: add AC_REMOVE_INCLUDE(), AC_REMOVE_DEFINE() macros metze (This used to be commit dc65a6625295a7316c2e9982ee09eb9607dbed70) --- source4/lib/replace/libreplace_macros.m4 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 4a645ef81f..0669c10c2a 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -264,6 +264,24 @@ define(AC_ADD_INCLUDE, EOF ]) +dnl remove an #include +dnl AC_REMOVE_INCLUDE(VARIABLE) +define(AC_REMOVE_INCLUDE, +[ +grep -v '[#include] $1' confdefs.h >confdefs.h.tmp +cat confdefs.h.tmp > confdefs.h +rm confdefs.h.tmp +]) + +dnl remove an #define +dnl AC_REMOVE_DEFINE(VARIABLE) +define(AC_REMOVE_DEFINE, +[ +grep -v '[#define] $1 ' confdefs.h |grep -v '[#define] $1[$]'>confdefs.h.tmp +cat confdefs.h.tmp > confdefs.h +rm confdefs.h.tmp +]) + dnl AS_HELP_STRING is not available in autoconf 2.57, and AC_HELP_STRING is deprecated dnl in autoconf 2.59, so define AS_HELP_STRING to be AC_HELP_STRING unless it is already dnl defined. -- cgit From c2d6fad69bc42c0d7c261282797ca8baf9e9aad2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 16 Oct 2006 21:39:07 +0000 Subject: r19347: Add socketpair() (This used to be commit 8a8e974d2150d00855ccafef02b7ef2607921ea0) --- source4/lib/replace/README | 1 + source4/lib/replace/libreplace.m4 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 182a276116..a313984c8e 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -52,6 +52,7 @@ readline (the library) inet_ntoa strtoll strtoull +socketpair Types: bool diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index d74ee6ed1e..b63c0fd471 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -150,7 +150,7 @@ AC_TRY_COMPILE([ AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) +AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp socketpair) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) -- cgit From 8acb0575c716c8ca680835764cd3bc5483f3707c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 17 Oct 2006 14:54:47 +0000 Subject: r19373: Merge changes from subunit branch: Convert libreplace testsuite to a standalone program that speaks subunit. (This used to be commit 48d316e7594dfc29b8e6a710e32bb5a6a036b7cf) --- source4/lib/replace/config.mk | 4 ++++ source4/lib/replace/test/os2_delete.c | 4 ++-- source4/lib/replace/test/testsuite.c | 40 ++++++++++++++++------------------- 3 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 source4/lib/replace/config.mk (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk new file mode 100644 index 0000000000..ff80955ffe --- /dev/null +++ b/source4/lib/replace/config.mk @@ -0,0 +1,4 @@ +[BINARY::REPLACE] +OBJ_FILES = test/testsuite.o test/os2_delete.o +PRIVATE_DEPENDENCIES = LIBREPLACE +INSTALLDIR = TORTUREDIR/LOCAL diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index 8501e0bb40..c8abfccff9 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -21,7 +21,7 @@ static int test_readdir_os2_delete_ret; -#define FAILED(d) (fprintf(stderr, "Failed for %s - %d = %s\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) +#define FAILED(d) (printf("failure: readdir [\nFailed for %s - %d = %s\n]\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -107,7 +107,7 @@ int test_readdir_os2_delete(void) } closedir(d); - printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); + fprintf(stderr, "Deleted %d files of %d\n", total_deleted, NUM_FILES); rmdir(TESTDIR) == 0 || FAILED("rmdir"); diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index d45304103f..3e20e22e45 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -57,26 +57,28 @@ static int test_ftruncate(void) struct stat st; int fd; const int size = 1234; - printf("testing ftruncate\n"); + printf("test: ftruncate\n"); unlink(TESTFILE); fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); if (fd == -1) { - printf("creating '%s' failed - %s\n", TESTFILE, strerror(errno)); + printf("failure: ftruncate [\n" + "creating '%s' failed - %s\n]\n", TESTFILE, strerror(errno)); return false; } if (ftruncate(fd, size) != 0) { - printf("ftruncate failed - %s\n", strerror(errno)); + printf("failure: ftruncate [\n%s\n]\n", strerror(errno)); return false; } if (fstat(fd, &st) != 0) { - printf("fstat failed - %s\n", strerror(errno)); + printf("failure: ftruncate [\nfstat failed - %s\n]\n", strerror(errno)); return false; } if (st.st_size != size) { - printf("ftruncate gave wrong size %d - expected %d\n", + printf("failure: ftruncate [\ngave wrong size %d - expected %d\n]\n", (int)st.st_size, size); return false; } + printf("success: ftruncate\n"); return true; } @@ -98,13 +100,14 @@ static int test_strlcpy(void) { NULL, 0 } }; int i; - printf("testing strlcpy\n"); + printf("test: strlcpy\n"); for (i=0;tests[i].src;i++) { if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) { - printf("strlcpy test %d failed\n", i); + printf("failure: strlcpy [\ntest %d failed\n]\n", i); return false; } } + printf("success: strlcpy\n"); return true; } @@ -146,8 +149,9 @@ static int test_strdup(void) static int test_setlinebuf(void) { - printf("testing setlinebuf\n"); + printf("test: setlinebuf\n"); setlinebuf(stdout); + printf("success: setlinebuf\n"); return true; } @@ -233,10 +237,11 @@ extern int test_readdir_os2_delete(void); static int test_readdir(void) { - printf("testing readdir\n"); + printf("test: readdir\n"); if (test_readdir_os2_delete() != 0) { return false; } + printf("success: readdir\n"); return true; } @@ -373,7 +378,7 @@ static int test_MAX(void) struct torture_context; -bool torture_local_replace(struct torture_context *torture) +int main() { bool ret = true; ret &= test_ftruncate(); @@ -420,16 +425,7 @@ bool torture_local_replace(struct torture_context *torture) ret &= test_MIN(); ret &= test_MAX(); - return ret; + if (ret) + return 0; + return -1; } - -#if _SAMBA_BUILD_<4 -int main(void) -{ - if (!torture_local_replace(NULL)) { - printf("ERROR: TESTSUITE FAILED\n"); - return -1; - } - return 0; -} -#endif -- cgit From f9a0ada725b012261ec9460185105f57206c70c3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 18 Oct 2006 16:08:22 +0000 Subject: r19393: Add replacement function for socketpair() (This used to be commit 448a3ecc0184bfa063db1eb3ae6dc16b8b792792) --- source4/lib/replace/replace.c | 21 ++++++++++++++++++ source4/lib/replace/replace.h | 4 ++++ source4/lib/replace/test/testsuite.c | 41 ++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index e7f47d7d52..83d7948dfb 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -590,3 +590,24 @@ int rep_setenv(const char *name, const char *value, int overwrite) } #endif +#ifndef HAVE_SOCKETPAIR +int rep_socketpair(int d, int type, int protocol, int sv[2]) +{ + if (d != AF_UNIX) { + errno = EAFNOSUPPORT; + return -1; + } + + if (protocol != 0) { + errno = EPROTONOSUPPORT; + return -1; + } + + if (type != SOCK_STREAM) { + errno = EOPNOTSUPP; + return -1; + } + + return pipe(sock); +} +#endif diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 7a79f335e2..d75394aa1f 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -209,6 +209,10 @@ void *rep_dlsym(void *handle, const char *symbol); int rep_dlclose(void *handle); #endif +#ifndef HAVE_SOCKETPAIR +#define socketpair rep_socketpair +int rep_socketpair(int d, int type, int protocol, int sv[2]); +#endif #ifndef PRINTF_ATTRIBUTE #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 3e20e22e45..e921a7fc97 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -376,6 +376,46 @@ static int test_MAX(void) return true; } +static bool test_socketpair(void) +{ + int sock[2]; + char buf[20]; + + printf("test: socketpair\n"); + + if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) == -1) { + printf("failure: socketpair [\n" + "socketpair() failed\n" + "]\n"); + return false; + } + + if (write(sock[0], "automatisch", 12) == -1) { + printf("failure: socketpair [\n" + "write() failed: %s\n" + "]\n", strerror(errno)); + return false; + } + + if (read(sock[1], buf, 12) == -1) { + printf("failure: socketpair [\n" + "read() failed: %s\n" + "]\n", strerror(errno)); + return false; + } + + if (strcmp(buf, "automatisch") != 0) { + printf("failure: socketpair [\n" + "expected: automatisch, got: %s\n" + "]\n", buf); + return false; + } + + printf("success: socketpair\n"); + + return true; +} + struct torture_context; int main() @@ -424,6 +464,7 @@ int main() ret &= test_FUNCTION(); ret &= test_MIN(); ret &= test_MAX(); + ret &= test_socketpair(); if (ret) return 0; -- cgit From 3a479ae55085e8dd315429dc5979534628891bbc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 18 Oct 2006 16:40:55 +0000 Subject: r19395: Fix replacement function compilation. (This used to be commit b79303f25180c777d9d09b2cdf852bf0a5eda70d) --- source4/lib/replace/replace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 83d7948dfb..9e6c75bd35 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -608,6 +608,6 @@ int rep_socketpair(int d, int type, int protocol, int sv[2]) return -1; } - return pipe(sock); + return pipe(sv); } #endif -- cgit From d04efb30a013c3c9061f62081fc6fc020bbbd7b0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 18 Oct 2006 22:33:20 +0000 Subject: r19403: try to fix the crashes in the buildfarm related to timegm (This used to be commit c4e1d2c5ae11acac7dd2cedca411b9b6be84962f) --- source4/lib/replace/timegm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c index ff90626d44..608882d0ce 100644 --- a/source4/lib/replace/timegm.c +++ b/source4/lib/replace/timegm.c @@ -44,13 +44,22 @@ static int is_leap(unsigned y) return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0); } -time_t timegm(struct tm *tm) +time_t rep_timegm(struct tm *tm) { static const unsigned ndays[2][12] ={ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; time_t res = 0; unsigned i; + + if (tm->tm_mon > 12 || + tm->tm_mday > 31 || + tm->tm_min > 60 || + tm->tm_sec > 60 || + tm->tm_hour > 24) { + /* invalid tm structure */ + return 0; + } for (i = 70; i < tm->tm_year; ++i) res += is_leap(i) ? 366 : 365; -- cgit From 0ec080d505aa5238ca3733454905f5ce9f65d6dc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 19 Oct 2006 03:04:00 +0000 Subject: r19408: I think tm_mon is ending up as -1 on some platforms (This used to be commit d01bdf1f2dcdf77043a5ad162ee336d3c6f2e944) --- source4/lib/replace/timegm.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c index 608882d0ce..395c684e11 100644 --- a/source4/lib/replace/timegm.c +++ b/source4/lib/replace/timegm.c @@ -53,6 +53,7 @@ time_t rep_timegm(struct tm *tm) unsigned i; if (tm->tm_mon > 12 || + tm->tm_mon < 0 || tm->tm_mday > 31 || tm->tm_min > 60 || tm->tm_sec > 60 || -- cgit From 21948f18a71d6d3de4b05f884a8cbe204c9c6fb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 19 Oct 2006 08:58:55 +0000 Subject: r19410: - fixed checker error - close the sockets after the socketpair test (This used to be commit e679163ac26dccee028ca501e4ef6229a3c761ee) --- source4/lib/replace/test/testsuite.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index e921a7fc97..d119424362 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -376,7 +376,7 @@ static int test_MAX(void) return true; } -static bool test_socketpair(void) +static int test_socketpair(void) { int sock[2]; char buf[20]; @@ -411,6 +411,9 @@ static bool test_socketpair(void) return false; } + close(sock[0]); + close(sock[1]); + printf("success: socketpair\n"); return true; -- cgit From c3e4b2d2782832bcb0072cd7cbb7f0f94910d4bc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 19 Oct 2006 09:35:05 +0000 Subject: r19411: sigh - we can't call close here as its mapped to swrap_close() in the build farm (This used to be commit be43b8c5692f6bb6f1cc74d07f24376b43593256) --- source4/lib/replace/test/testsuite.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index d119424362..a57247377b 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -411,9 +411,6 @@ static int test_socketpair(void) return false; } - close(sock[0]); - close(sock[1]); - printf("success: socketpair\n"); return true; -- cgit From 5a4b133d1ce7ec5043a092396072be5374b3cf24 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 21 Oct 2006 09:15:15 +0000 Subject: r19438: try to fix up the build breakages on BSD systems due to incorrectly detecting iconv.h (This used to be commit e6baa13e1f9c35f95021512b713cebba680b2a72) --- source4/lib/replace/system/iconv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/iconv.h b/source4/lib/replace/system/iconv.h index abc2d6f4e1..f01d135dd1 100644 --- a/source4/lib/replace/system/iconv.h +++ b/source4/lib/replace/system/iconv.h @@ -35,11 +35,11 @@ #endif #ifdef HAVE_NATIVE_ICONV -#if defined(HAVE_ICONV) +#if defined(HAVE_ICONV_H) #include -#elif defined(HAVE_GICONV) +#elif defined(HAVE_GICONV_H) #include -#elif defined(HAVE_BICONV) +#elif defined(HAVE_BICONV_H) #include #endif #endif /* HAVE_NATIVE_ICONV */ -- cgit From 9044f4aa905882485bf2b5c72d9836bdaa14c37a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 21 Oct 2006 09:42:46 +0000 Subject: r19440: merged from samba3 (This used to be commit c22fb040234d0cb808fb36e1b4b7ea7bfd45c8cb) --- source4/lib/replace/dlfcn.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c index e25ac9dfe5..22f9f8bf79 100644 --- a/source4/lib/replace/dlfcn.c +++ b/source4/lib/replace/dlfcn.c @@ -26,28 +26,28 @@ #include "replace.h" #ifndef HAVE_DLOPEN -void *dlopen(const char *name, int flags) +void *rep_dlopen(const char *name, int flags) { return NULL; } #endif #ifndef HAVE_DLSYM -void *dlsym(void *handle, const char *symbol) +void *rep_dlsym(void *handle, const char *symbol) { return NULL; } #endif #ifndef HAVE_DLERROR -char *dlerror(void) +char *rep_dlerror(void) { return "dynamic loading of objects not supported on this platform"; } #endif #ifndef HAVE_DLCLOSE -int dlclose(void *handle) +int rep_dlclose(void *handle) { return 0; } -- cgit From 2e468ee5df6371799d627f78245417fd61c5741d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 21 Oct 2006 10:12:39 +0000 Subject: r19442: this real cause of the failures on *BSD came from the missing ICONV dependency and not from a broken configure test and incorrect ifdef's. metze (This used to be commit 3df2cb1ea82dae7395d3d19ba73f97dad26bb86b) --- source4/lib/replace/config.mk | 4 +++- source4/lib/replace/system/iconv.h | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk index ff80955ffe..7103facd51 100644 --- a/source4/lib/replace/config.mk +++ b/source4/lib/replace/config.mk @@ -1,4 +1,6 @@ [BINARY::REPLACE] OBJ_FILES = test/testsuite.o test/os2_delete.o -PRIVATE_DEPENDENCIES = LIBREPLACE +PRIVATE_DEPENDENCIES = \ + LIBREPLACE \ + ICONV INSTALLDIR = TORTUREDIR/LOCAL diff --git a/source4/lib/replace/system/iconv.h b/source4/lib/replace/system/iconv.h index f01d135dd1..abc2d6f4e1 100644 --- a/source4/lib/replace/system/iconv.h +++ b/source4/lib/replace/system/iconv.h @@ -35,11 +35,11 @@ #endif #ifdef HAVE_NATIVE_ICONV -#if defined(HAVE_ICONV_H) +#if defined(HAVE_ICONV) #include -#elif defined(HAVE_GICONV_H) +#elif defined(HAVE_GICONV) #include -#elif defined(HAVE_BICONV_H) +#elif defined(HAVE_BICONV) #include #endif #endif /* HAVE_NATIVE_ICONV */ -- cgit From bc596cf917a25569f71d7d2b72ba11f3cb34dd54 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 25 Oct 2006 14:58:05 +0000 Subject: r19495: Stop linking binaries twice (once before installation, once during build). Make TORTURE-TALLOC and TORTURE-REPLACE builtin again rather than separate binaries. (This used to be commit 8913d60c72a67b041b08d569c9bd048953106c85) --- source4/lib/replace/test/testsuite.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index a57247377b..48197cf721 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -417,8 +417,7 @@ static int test_socketpair(void) } struct torture_context; - -int main() +bool torture_local_replace(struct torture_context *ctx) { bool ret = true; ret &= test_ftruncate(); @@ -466,7 +465,15 @@ int main() ret &= test_MAX(); ret &= test_socketpair(); + return ret; +} + +#ifndef _SAMBA_BUILD_ +int main() +{ + bool ret = torture_local_replace(NULL); if (ret) return 0; return -1; } +#endif -- cgit From a74de9886cf210b32a4f919f333e93e92ba4e95c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 25 Oct 2006 15:14:03 +0000 Subject: r19496: remove unused file metze (This used to be commit fe733f6307bb5801d523a968aeb5395f463ce6d6) --- source4/lib/replace/config.mk | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 source4/lib/replace/config.mk (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk deleted file mode 100644 index 7103facd51..0000000000 --- a/source4/lib/replace/config.mk +++ /dev/null @@ -1,6 +0,0 @@ -[BINARY::REPLACE] -OBJ_FILES = test/testsuite.o test/os2_delete.o -PRIVATE_DEPENDENCIES = \ - LIBREPLACE \ - ICONV -INSTALLDIR = TORTUREDIR/LOCAL -- cgit From 13dbee3ffea6065a826f010e50c9b4eb2c6ad109 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 7 Nov 2006 00:48:36 +0000 Subject: r19598: Ahead of a merge to current lorikeet-heimdal: Break up auth/auth.h not to include the world. Add credentials_krb5.h with the kerberos dependent prototypes. Andrew Bartlett (This used to be commit 2b569c42e0fbb596ea82484d0e1cb22e193037b9) --- source4/lib/replace/system/kerberos.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/kerberos.h b/source4/lib/replace/system/kerberos.h index b24196fc25..1617b96aad 100644 --- a/source4/lib/replace/system/kerberos.h +++ b/source4/lib/replace/system/kerberos.h @@ -126,7 +126,6 @@ #define KRB5_PRINC_REALM_RETURNS_REALM 1 #include "heimdal/lib/krb5/krb5.h" -#include "heimdal/lib/gssapi/gssapi.h" #include "heimdal/lib/com_err/com_err.h" #endif -- cgit From 22a155af0568d136a3162fbe45e36993b23d83a3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 7 Nov 2006 10:44:17 +0000 Subject: r19609: fix uninitialized perl variabel, we need AC_SUBST() for all configure vars we want to use in perl... metze (This used to be commit 2b021e2d8cff1a097068810d379fc0dca6869654) --- source4/lib/replace/libreplace_cc.m4 | 38 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index b8b74036e5..74c53cad99 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -140,23 +140,27 @@ fi ############################################ # check if the compiler can do immediate structures -AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [ - AC_TRY_COMPILE([ -#include ], -[ - typedef struct {unsigned x;} FOOBAR; - #define X_FOOBAR(x) ((FOOBAR) { x }) - #define FOO_ONE X_FOOBAR(1) - FOOBAR f = FOO_ONE; - static const struct { - FOOBAR y; - } f2[] = { - {FOO_ONE} - }; -], - samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)]) -if test x"$samba_cv_immediate_structures" = x"yes"; then - AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures]) +AC_SUBST(libreplace_cv_immediate_structures) +AC_CACHE_CHECK([for immediate structures],libreplace_cv_immediate_structures,[ + AC_TRY_COMPILE([ + #include + ],[ + typedef struct {unsigned x;} FOOBAR; + #define X_FOOBAR(x) ((FOOBAR) { x }) + #define FOO_ONE X_FOOBAR(1) + FOOBAR f = FOO_ONE; + static const struct { + FOOBAR y; + } f2[] = { + {FOO_ONE} + }; + ], + libreplace_cv_immediate_structures=yes, + libreplace_cv_immediate_structures=no, + libreplace_cv_immediate_structures=cross) +]) +if test x"$libreplace_cv_immediate_structures" = x"yes"; then + AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures]) fi AC__LIBREPLACE_ONLY_CC_CHECKS_END -- cgit From 0c1218cbac93b1919a5c1cec28b4b716092fafc3 Mon Sep 17 00:00:00 2001 From: Paul Green Date: Wed, 29 Nov 2006 18:44:54 +0000 Subject: r19952: Fix socketpair() test case to write to fd(1) and read from fd(0) because when pipe files are substituting for unix domain sockets, pipes provide only uni-directional i/o capabilities. (This used to be commit d0a376732ed7b4f807b99a1c46c54ad1f07c85cf) --- source4/lib/replace/test/testsuite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 48197cf721..a5defaf89d 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -390,14 +390,14 @@ static int test_socketpair(void) return false; } - if (write(sock[0], "automatisch", 12) == -1) { + if (write(sock[1], "automatisch", 12) == -1) { printf("failure: socketpair [\n" "write() failed: %s\n" "]\n", strerror(errno)); return false; } - if (read(sock[1], buf, 12) == -1) { + if (read(sock[0], buf, 12) == -1) { printf("failure: socketpair [\n" "read() failed: %s\n" "]\n", strerror(errno)); -- cgit From 022658ae50f7eb6de5c8b17b6a4f17e9856c0d58 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 28 Dec 2006 17:05:23 +0000 Subject: r20383: only try to find dlfcn.h if the dlopen symbol was found, it hopefully fixes systems where dlfcn.h but no library with dlopen metze (This used to be commit 4aa31c8862020fa2615ec3cf0b65b1bb7ed10dd4) --- source4/lib/replace/dlfcn.m4 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.m4 b/source4/lib/replace/dlfcn.m4 index c9d31592e0..2d5b2c5141 100644 --- a/source4/lib/replace/dlfcn.m4 +++ b/source4/lib/replace/dlfcn.m4 @@ -4,13 +4,15 @@ LIBS="" AC_SEARCH_LIBS(dlopen, dl) -AC_CHECK_HEADERS(dlfcn.h) +if test "$ac_cv_search_dlopen" != no; then + AC_CHECK_HEADERS(dlfcn.h) -libreplace_cv_dlfcn=no -AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_cv_dlfcn=yes]) + libreplace_cv_dlfcn=no + AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_cv_dlfcn=yes]) -if test x"${libreplace_cv_dlfcn}" = x"yes";then - LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o" + if test x"${libreplace_cv_dlfcn}" = x"yes";then + LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o" + fi fi LIBDL="$LIBS" -- cgit From 4a1ac217f4499f154e01c1f6e8aceb9ac6adeae7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 10 Jan 2007 18:23:06 +0000 Subject: r20659: add missing system/aio.h tridge: please commit your version and merge it to both samba3 branches metze (This used to be commit ba492e2c3a64dfc5d4743ba568c63cb9a59e2849) --- source4/lib/replace/system/aio.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 source4/lib/replace/system/aio.h (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/aio.h b/source4/lib/replace/system/aio.h new file mode 100644 index 0000000000..102ed5ceb1 --- /dev/null +++ b/source4/lib/replace/system/aio.h @@ -0,0 +1,29 @@ +#ifndef _system_aio_h +#define _system_aoi_h +/* + Unix SMB/CIFS implementation. + + async io include wrappers + + Copyright (C) Stefan Metzmacher 2006 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_LIBAIO_H 1 +#include +#endif + +#endif -- cgit From 4056528f7268daee5b8fdec0e9b9b6fb19fb72e8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 10 Jan 2007 20:07:13 +0000 Subject: r20665: put in my version of aio.h sorry about that .... (This used to be commit a91373291422e2f50b91fd7c2317dce5d2a4ab63) --- source4/lib/replace/system/aio.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/aio.h b/source4/lib/replace/system/aio.h index 102ed5ceb1..e1b9d836e7 100644 --- a/source4/lib/replace/system/aio.h +++ b/source4/lib/replace/system/aio.h @@ -1,11 +1,11 @@ #ifndef _system_aio_h -#define _system_aoi_h +#define _system_aio_h /* Unix SMB/CIFS implementation. - async io include wrappers + AIO system include wrappers - Copyright (C) Stefan Metzmacher 2006 + Copyright (C) Andrew Tridgell 2006 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifdef HAVE_LIBAIO_H 1 +#if HAVE_LIBAIO_H #include #endif -- cgit From 274df78541eec948e546bb98901b5bb00aaadc00 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 15 Jan 2007 07:15:47 +0000 Subject: r20788: - remove epoll configure checks from libreplace - fix epoll configure checks for the epoll and aio events backends - we should only activate the epoll backend if sys/epoll.h and epoll_create() are found - we should only activate the aio backend if sys/epoll.h, epoll_create(), libaio.h and io_getevents() are found hopefully fix the build on 'bnhtest' in the build farm... metze (This used to be commit d46a5efb03ea1df50567cad00e1589870cdb31fe) --- source4/lib/replace/libreplace.m4 | 3 --- source4/lib/replace/system/select.h | 9 --------- 2 files changed, 12 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index b63c0fd471..dff6098297 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -63,9 +63,6 @@ AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat ge AC_CHECK_HEADERS(stdbool.h sys/select.h) -AC_CHECK_HEADERS(sys/epoll.h) -AC_CHECK_FUNCS(epoll_create) - AC_CHECK_TYPE(bool, [AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],, [ diff --git a/source4/lib/replace/system/select.h b/source4/lib/replace/system/select.h index 0d1eabbc35..20346259c2 100644 --- a/source4/lib/replace/system/select.h +++ b/source4/lib/replace/system/select.h @@ -30,13 +30,4 @@ #define SELECT_CAST #endif -/* use epoll if it is available */ -#if defined(HAVE_EPOLL_CREATE) && defined(HAVE_SYS_EPOLL_H) -#define WITH_EPOLL 1 -#endif - -#if WITH_EPOLL -#include -#endif - #endif -- cgit From 8c75df8b2c5c2bc62ed1ef080c2f83f7ce365c09 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 15 Jan 2007 17:55:26 +0000 Subject: r20810: unlink the test file when the test is done metze (This used to be commit d3e10679afe436b994813e60b117bc42e6c2ed8f) --- source4/lib/replace/test/testsuite.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index a5defaf89d..669f825b90 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -78,6 +78,7 @@ static int test_ftruncate(void) (int)st.st_size, size); return false; } + unlink(TESTFILE); printf("success: ftruncate\n"); return true; } -- cgit From 28438101bd07a96ef5a3725660eb43b486a0eae0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 15 Jan 2007 19:05:11 +0000 Subject: r20815: merge from samba3 metze (This used to be commit 5b8387969dcc1575a71eaf2daa8f42b94c87bbd0) --- source4/lib/replace/test/testsuite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 669f825b90..8a9fb9ab87 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -469,7 +469,7 @@ bool torture_local_replace(struct torture_context *ctx) return ret; } -#ifndef _SAMBA_BUILD_ +#if _SAMBA_BUILD_<4 int main() { bool ret = torture_local_replace(NULL); -- cgit From 71f6a4d05bf46ca9456a3bc9f2d3263936b18ae2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 15 Jan 2007 19:08:03 +0000 Subject: r20816: merge from samba3: include setjmp.h via system/wait.h metze (This used to be commit 1b10cbb62950693760d4af6ab8691a4ba70908c9) --- source4/lib/replace/libreplace.m4 | 1 + source4/lib/replace/system/wait.h | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index dff6098297..3328dea95e 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -62,6 +62,7 @@ AC_FUNC_MEMCMP AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat getpgrp) AC_CHECK_HEADERS(stdbool.h sys/select.h) +AC_CHECK_HEADERS(setjmp.h) AC_CHECK_TYPE(bool, [AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],, diff --git a/source4/lib/replace/system/wait.h b/source4/lib/replace/system/wait.h index c2041a5938..3855f7ae72 100644 --- a/source4/lib/replace/system/wait.h +++ b/source4/lib/replace/system/wait.h @@ -36,4 +36,8 @@ #define SIGNAL_CAST (RETSIGTYPE (*)(int)) #endif +#ifdef HAVE_SETJMP_H +#include +#endif + #endif -- cgit From 0ce02a2c0eb322502bd931e83fa23ce476198e06 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 15 Jan 2007 19:27:45 +0000 Subject: r20819: - include system/aio.h - use full prototype for main - use ifdef instead if metze (This used to be commit b3a3c44f42455d6f84ab2f1f282fb177f8b6013c) --- source4/lib/replace/system/aio.h | 2 +- source4/lib/replace/test/testsuite.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/aio.h b/source4/lib/replace/system/aio.h index e1b9d836e7..45154ccb27 100644 --- a/source4/lib/replace/system/aio.h +++ b/source4/lib/replace/system/aio.h @@ -22,7 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if HAVE_LIBAIO_H +#ifdef HAVE_LIBAIO_H #include #endif diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 8a9fb9ab87..effbdb13ef 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -46,6 +46,7 @@ #include "system/terminal.h" #include "system/time.h" #include "system/wait.h" +#include "system/aio.h" #define TESTFILE "testfile.dat" @@ -470,7 +471,7 @@ bool torture_local_replace(struct torture_context *ctx) } #if _SAMBA_BUILD_<4 -int main() +int main(void) { bool ret = torture_local_replace(NULL); if (ret) -- cgit From cf8eef4ad88af40d2cf147686c1877cd380b452c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 21 Jan 2007 10:32:39 +0000 Subject: r20930: use sigaction() instead of signal() add support for sa_flags argument to event_add_signal(). These are passed to sigaction(). Special handling is provided for SA_RESETHAND (which tells the event system to remove the handler after the signal) and SA_SIGINFO which allows the siginfo structure to be received per signal (This used to be commit 1bb10b6cf7d717ad21834e73a4ca4b22b5fb6f0a) --- source4/lib/replace/system/wait.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/wait.h b/source4/lib/replace/system/wait.h index 3855f7ae72..179ef0774e 100644 --- a/source4/lib/replace/system/wait.h +++ b/source4/lib/replace/system/wait.h @@ -40,4 +40,8 @@ #include #endif +#ifndef SA_RESETHAND +#define SA_RESETHAND SA_ONESHOT +#endif + #endif -- cgit From 0602d4d7f2070af8dfbf364db3e4008091a188fe Mon Sep 17 00:00:00 2001 From: James Peach Date: Tue, 23 Jan 2007 19:52:17 +0000 Subject: r20981: Fix cut'n'paste error. (This used to be commit 20dcd6e2416d656e97b8cc060809673a97d5cde6) --- source4/lib/replace/replace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index d75394aa1f..5667644025 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -181,7 +181,7 @@ int rep_ftruncate(int,off_t); #endif #ifndef HAVE_INITGROUPS -#define ftruncate rep_ftruncate +#define initgroups rep_initgroups int rep_initgroups(char *name, gid_t id); #endif -- cgit From 8538af1107a6e894d4941708b77e79fac587e35d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 6 Feb 2007 05:26:25 +0000 Subject: r21174: many thanks to Paul Wayper for pointing out that C99 requires a matching va_end() for each va_copy(). This doesn't matter for most architectures, but there could be some obscure ones where it does matter. some of this should be ported to Samba3 (This used to be commit 21eb316473486cb6b73bb3ff9c5f3a44ecd57e4a) --- source4/lib/replace/snprintf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index b38d8dad34..9f8a7657e5 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -742,6 +742,8 @@ static int dopr(char *buffer, size_t maxlen, const char *format, va_list args_in ret = currlen; done: + va_end(args); + while (chunks) { cnk = chunks->next; free(chunks); @@ -1260,16 +1262,16 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, va_list ap2; VA_COPY(ap2, ap); - ret = vsnprintf(NULL, 0, format, ap2); + va_end(ap2); if (ret <= 0) return ret; (*ptr) = (char *)malloc(ret+1); if (!*ptr) return -1; VA_COPY(ap2, ap); - ret = vsnprintf(*ptr, ret+1, format, ap2); + va_end(ap2); return ret; } -- cgit From 4126b34e1f34a67b1eed06329530c17dfa54fb00 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 12 Feb 2007 17:36:00 +0000 Subject: r21302: Provide simple redirecting headers for standard headers. (This used to be commit 74c47839536c9ccfa1240289d20df65d9d13839d) --- source4/lib/replace/README | 4 ++++ source4/lib/replace/libreplace.m4 | 5 ++++- source4/lib/replace/libreplace_macros.m4 | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index a313984c8e..21cd0051c7 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -81,6 +81,10 @@ MIN MAX QSORT_CAST +Headers: +stdint.h +stdbool.h + Prerequisites: memset (for bzero) syslog (for vsyslog) diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 3328dea95e..805cdc6cb5 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -61,9 +61,12 @@ AC_FUNC_MEMCMP AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat getpgrp) -AC_CHECK_HEADERS(stdbool.h sys/select.h) +AC_CHECK_HEADERS(stdbool.h stdint.h sys/select.h) AC_CHECK_HEADERS(setjmp.h) +LIBREPLACE_PROVIDE_HEADER([stdint.h]) +LIBREPLACE_PROVIDE_HEADER([stdbool.h]) + AC_CHECK_TYPE(bool, [AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],, [ diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 0669c10c2a..f262b9b6eb 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -306,3 +306,12 @@ AC_DEFUN(AC_VERIFY_C_PROTOTYPE, ) AS_IF([test $AS_TR_SH([ac_cv_c_prototype_$1]) = yes],[$3],[$4]) ]) + +AC_DEFUN(LIBREPLACE_PROVIDE_HEADER, +[AC_CHECK_HEADER([$1], + [ AC_CONFIG_COMMANDS(rm-$1, [rm -f $libreplacedir/$1], [libreplacedir=$libreplacedir]) ], + [ AC_CONFIG_COMMANDS(mk-$1, [echo "#include \"replace.h\"" > $libreplacedir/$1], [libreplacedir=$libreplacedir]) ] + ) +]) + + -- cgit From 544a2d30e01b5f4f9849c9aa631e0525062c2707 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Mar 2007 09:59:06 +0000 Subject: r21793: add replacement for unsetenv() metze (This used to be commit d6de7f2cda70cfd55f0f7fbb9f3b93a5a58c6f51) --- source4/lib/replace/README | 1 + source4/lib/replace/libreplace.m4 | 3 ++- source4/lib/replace/replace.c | 34 ++++++++++++++++++++++++++++++++++ source4/lib/replace/replace.h | 5 +++++ 4 files changed, 42 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 21cd0051c7..6610b7c279 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -21,6 +21,7 @@ setlinebuf vsyslog timegm setenv +unsetenv strndup strnlen waitpid diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 805cdc6cb5..b5f931c7e4 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -263,7 +263,8 @@ AC_CHECK_HEADERS([sys/param.h limits.h]) AC_CHECK_TYPE(comparison_fn_t, [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) -AC_CHECK_FUNCS(strnlen setenv) +AC_CHECK_FUNCS(setenv unsetenv) +AC_CHECK_FUNCS(strnlen) AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) # this test disabled as we don't actually need __VA_ARGS__ yet diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 9e6c75bd35..486c1c5e13 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -590,6 +590,40 @@ int rep_setenv(const char *name, const char *value, int overwrite) } #endif +#ifndef HAVE_UNSETENV +int rep_unsetenv(const char *name) +{ + char *p; + size_t l1; + int ret; + + if (!getenv(name)) { + return 0; + } + + l1 = strlen(name); + + p = malloc(l1+1); + if (p == NULL) { + return -1; + } + memcpy(p, name, l1); + p[l1] = 0; + + /* + * use using "name" here unsets the var + * + * "name=" would set it to an empty string.. + */ + ret = putenv(p); + if (ret != 0) { + free(p); + } + + return ret; +} +#endif + #ifndef HAVE_SOCKETPAIR int rep_socketpair(int d, int type, int protocol, int sv[2]) { diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 5667644025..cae9d80178 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -140,6 +140,11 @@ size_t rep_strnlen(const char *s, size_t n); int rep_setenv(const char *name, const char *value, int overwrite); #endif +#ifndef HAVE_UNSETENV +#define unsetenv rep_unsetenv +int rep_unsetenv(const char *name, const char *value, int overwrite); +#endif + #ifndef HAVE_SETEUID #define seteuid rep_seteuid int rep_seteuid(uid_t); -- cgit From d358087227727a9a8e8661c8eae2990115f8fb80 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Mar 2007 09:59:48 +0000 Subject: r21794: add setenv()/unsetenv() testsuite metze (This used to be commit 3df206ddfadea5bf39a22e8c4c262764c79d302c) --- source4/lib/replace/test/testsuite.c | 62 +++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index effbdb13ef..c2f5ff9a6b 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -171,7 +171,67 @@ static int test_timegm(void) static int test_setenv(void) { - /* FIXME */ +#define TEST_SETENV(key, value, overwrite, result) do { \ + int _ret; \ + char *_v; \ + _ret = setenv(key, value, overwrite); \ + if (_ret != 0) { \ + printf("failure: setenv [\n" \ + "setenv(%s, %s, %d) failed\n" \ + "]\n", \ + key, value, overwrite); \ + return false; \ + } \ + _v=getenv(key); \ + if (!_v) { \ + printf("failure: setenv [\n" \ + "getenv(%s) returned NULL\n" \ + "]\n", \ + key); \ + return false; \ + } \ + if (strcmp(result, _v) != 0) { \ + printf("failure: setenv [\n" \ + "getenv(%s): '%s' != '%s'\n" \ + "]\n", \ + key, result, _v); \ + return false; \ + } \ +} while(0) + +#define TEST_UNSETENV(key) do { \ + int _ret; \ + char *_v; \ + _ret = unsetenv(key); \ + if (_ret != 0) { \ + printf("failure: setenv [\n" \ + "unsetenv(%s) failed\n" \ + "]\n", \ + key); \ + return false; \ + } \ + _v=getenv(key); \ + if (_v) { \ + printf("failure: setenv [\n" \ + "getenv(%s): NULL != '%s'\n" \ + "]\n", \ + SETENVTEST_KEY, _v); \ + return false; \ + } \ +} while (0) + +#define SETENVTEST_KEY "SETENVTESTKEY" +#define SETENVTEST_VAL "SETENVTESTVAL" + + printf("test: setenv\n"); + TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"1", 0, SETENVTEST_VAL"1"); + TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"2", 0, SETENVTEST_VAL"1"); + TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"3", 1, SETENVTEST_VAL"3"); + TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"4", 1, SETENVTEST_VAL"4"); + TEST_UNSETENV(SETENVTEST_KEY); + TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"5", 0, SETENVTEST_VAL"5"); + TEST_UNSETENV(SETENVTEST_KEY); + printf("success: setenv\n"); return true; } -- cgit From 14233bb76fbd96b46d2b845fde1cb7c668d405b0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Mar 2007 10:12:27 +0000 Subject: r21795: fix the prototype of unsetenv()... metze (This used to be commit 2952c20b779fc6c797e2ab33ba3bda19cbb7a00d) --- source4/lib/replace/replace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index cae9d80178..b36a350335 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -142,7 +142,7 @@ int rep_setenv(const char *name, const char *value, int overwrite); #ifndef HAVE_UNSETENV #define unsetenv rep_unsetenv -int rep_unsetenv(const char *name, const char *value, int overwrite); +int rep_unsetenv(const char *name); #endif #ifndef HAVE_SETEUID -- cgit From de75e93817da856f1e79f616e4fc09c27ab626c0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Mar 2007 11:31:06 +0000 Subject: r21796: check if unsetenv() works on an non-existing key metze (This used to be commit c6b4f2d1518c989cacdc8869df89f02dc54857d7) --- source4/lib/replace/test/testsuite.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index c2f5ff9a6b..44c218270c 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -229,8 +229,10 @@ static int test_setenv(void) TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"3", 1, SETENVTEST_VAL"3"); TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"4", 1, SETENVTEST_VAL"4"); TEST_UNSETENV(SETENVTEST_KEY); + TEST_UNSETENV(SETENVTEST_KEY); TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"5", 0, SETENVTEST_VAL"5"); TEST_UNSETENV(SETENVTEST_KEY); + TEST_UNSETENV(SETENVTEST_KEY); printf("success: setenv\n"); return true; } -- cgit From d464f0e78b63ee7df52df9171943f6a9723260fc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Mar 2007 11:32:19 +0000 Subject: r21797: remove the key directly from the environ array inspired by: http://cvs.linux-ha.org/viewcvs/viewcvs.cgi/linux-ha/replace/unsetenv.c?rev=1.4&view=auto metze (This used to be commit 8787525e518805f8445a376dc4964921598cb2e0) --- source4/lib/replace/replace.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 486c1c5e13..03888a8eee 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -593,34 +593,26 @@ int rep_setenv(const char *name, const char *value, int overwrite) #ifndef HAVE_UNSETENV int rep_unsetenv(const char *name) { - char *p; - size_t l1; - int ret; - - if (!getenv(name)) { - return 0; - } - - l1 = strlen(name); - - p = malloc(l1+1); - if (p == NULL) { - return -1; - } - memcpy(p, name, l1); - p[l1] = 0; + extern char **environ; + size_t len = strlen(name); + size_t i; + int found = 0; + + for (i=0; (environ && environ[i]); i++) { + if (found) { + environ[i-1] = environ[i]; + continue; + } - /* - * use using "name" here unsets the var - * - * "name=" would set it to an empty string.. - */ - ret = putenv(p); - if (ret != 0) { - free(p); + if (strncmp(environ[i], name, len) == 0 && environ[i][len] == '=') { + free(environ[i]); + environ[i] = NULL; + found = 1; + continue; + } } - return ret; + return 0; } #endif -- cgit From 8988113a4261a484962eb104408ada661809ce3a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 12 Mar 2007 11:37:12 +0000 Subject: r21798: unsetenv() returns void on some platforms (BSD) metze (This used to be commit 9cdb9f1cee9af47e42e11357397b828b86632805) --- source4/lib/replace/test/testsuite.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 44c218270c..5ed6b3e7a5 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -200,16 +200,8 @@ static int test_setenv(void) } while(0) #define TEST_UNSETENV(key) do { \ - int _ret; \ char *_v; \ - _ret = unsetenv(key); \ - if (_ret != 0) { \ - printf("failure: setenv [\n" \ - "unsetenv(%s) failed\n" \ - "]\n", \ - key); \ - return false; \ - } \ + unsetenv(key); \ _v=getenv(key); \ if (_v) { \ printf("failure: setenv [\n" \ -- cgit From 2882b2ba63ea65c806643f86d996513414c827d0 Mon Sep 17 00:00:00 2001 From: James Peach Date: Mon, 2 Apr 2007 17:06:14 +0000 Subject: r22029: Make sure we respect $srcdir correctly for the srcdir != builddir case. (This used to be commit 0db4256a472975c5097135fa87315038a1350a72) --- source4/lib/replace/samba.m4 | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4 index 3769c7f50e..a2e04f53b1 100644 --- a/source4/lib/replace/samba.m4 +++ b/source4/lib/replace/samba.m4 @@ -3,8 +3,16 @@ AC_LIBREPLACE_BROKEN_CHECKS SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}]) SMB_ENABLE(LIBREPLACE_EXT) +# remove leading ./ LIBREPLACE_DIR=`echo ${libreplacedir} |sed -e 's/^\.\///g'` +# remove leading srcdir .. we are looking for the relative +# path within the samba source tree or wherever libreplace is. +# We need to make sure the object is not forced to end up in +# the source directory because we might be using a separate +# build directory. +LIBREPLACE_DIR=`echo ${LIBREPLACE_DIR} | sed -e "s|^$srcdir/||g"` + LIBREPLACE_OBJS="" for obj in ${LIBREPLACEOBJ}; do LIBREPLACE_OBJS="${LIBREPLACE_OBJS} ${LIBREPLACE_DIR}/${obj}" -- cgit From 4cc500433d07decf8fc2551b117e15537f6c8558 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 10 Apr 2007 16:00:13 +0000 Subject: r22152: merge from samba3: remove netgr functions from libreplace they're not used in samba4 currently and samba3 has explicit configure checks for them. should fix bug #4496 metze (This used to be commit dd83a8dad8ad89a1485598fa6e11c9128d04e6d7) --- source4/lib/replace/README | 2 -- source4/lib/replace/libreplace.m4 | 5 ++--- source4/lib/replace/replace.c | 27 --------------------------- source4/lib/replace/test/testsuite.c | 7 ------- 4 files changed, 2 insertions(+), 39 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 6610b7c279..8fe9f24e79 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -12,7 +12,6 @@ strlcpy strlcat mktime rename -innetgr initgroups memmove strdup @@ -89,5 +88,4 @@ stdbool.h Prerequisites: memset (for bzero) syslog (for vsyslog) -setnetgrent, getnetgrent, endnetgrent (for innetgr) mktemp (for mkstemp and mkdtemp) diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index b5f931c7e4..12be9f6016 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -150,7 +150,7 @@ AC_TRY_COMPILE([ AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) -AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup) +AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp socketpair) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) @@ -331,8 +331,7 @@ m4_include(win32.m4) m4_include(timegm.m4) m4_include(repdir.m4) -AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],, - [AC_MSG_ERROR([Required function not found])]) +AC_CHECK_FUNCS([syslog memset memcpy],,[AC_MSG_ERROR([Required function not found])]) echo "LIBREPLACE_BROKEN_CHECKS: END" ]) dnl end AC_LIBREPLACE_BROKEN_CHECKS diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 03888a8eee..db299130e5 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -154,33 +154,6 @@ time_t rep_mktime(struct tm *t) #endif /* !HAVE_MKTIME */ -#ifndef HAVE_INNETGR -#if defined(HAVE_SETNETGRENT) && defined(HAVE_GETNETGRENT) && defined(HAVE_ENDNETGRENT) -/* - * Search for a match in a netgroup. This replaces it on broken systems. - */ -int rep_innetgr(const char *group, const char *host, const char *user, - const char *dom) -{ - char *hst, *usr, *dm; - - setnetgrent(group); - while (getnetgrent(&hst, &usr, &dm)) { - if (((host == 0) || (hst == 0) || !strcmp(host, hst)) && - ((user == 0) || (usr == 0) || !strcmp(user, usr)) && - ((dom == 0) || (dm == 0) || !strcmp(dom, dm))) { - endnetgrent(); - return (1); - } - } - endnetgrent(); - return (0); -} -#endif /* HAVE_SETNETGRENT HAVE_GETNETGRENT HAVE_ENDNETGRENT */ -#endif /* HAVE_INNETGR */ - - - #ifndef HAVE_INITGROUPS /**************************************************************************** some systems don't have an initgroups call diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 5ed6b3e7a5..40ee0650b0 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -125,12 +125,6 @@ static int test_mktime(void) return true; } -static int test_innetgr(void) -{ - /* FIXME */ - return true; -} - static int test_initgroups(void) { /* FIXME */ @@ -480,7 +474,6 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_strlcpy(); ret &= test_strlcat(); ret &= test_mktime(); - ret &= test_innetgr(); ret &= test_initgroups(); ret &= test_memmove(); ret &= test_strdup(); -- cgit From f2e611f355b5f937ed03d622e46ddeefe859d564 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 12 Apr 2007 19:54:15 +0000 Subject: r22203: Improve the replace testsuite a bit. (This used to be commit 7003a6fa1ae1d163160ad509a7811f836be3aa6f) --- source4/lib/replace/test/testsuite.c | 162 ++++++++++++++++++++++++++++++++--- 1 file changed, 151 insertions(+), 11 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 40ee0650b0..1e881aa10e 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -115,7 +115,27 @@ static int test_strlcpy(void) static int test_strlcat(void) { - /* FIXME */ + char tmp[10]; + printf("test: strlcat\n"); + strcpy(tmp, ""); + if (strlcat(tmp, "bla", 3) != 3) { + printf("failure: strlcat [\ninvalid return code\n]\n"); + return false; + } + if (strcmp(tmp, "bl") != 0) { + printf("failure: strlcat [\nexpected \"bl\", got \"%s\"\n]\n", + tmp); + return false; + } + + strcpy(tmp, "da"); + if (strlcat(tmp, "me", 4) != 4) { + printf("failure: strlcat [\nexpected \"dam\", got \"%s\"\n]\n", + tmp); + return false; + } + + printf("success: strlcat\n"); return true; } @@ -139,7 +159,16 @@ static int test_memmove(void) static int test_strdup(void) { - /* FIXME */ + char *x; + printf("test: strdup\n"); + x = strdup("bla"); + if (strcmp("bla", x) != 0) { + printf("failure: strdup [\nfailed: expected \"bla\", got \"%s\"\n]\n", + x); + return false; + } + free(x); + printf("success: strdup\n"); return true; } @@ -225,13 +254,49 @@ static int test_setenv(void) static int test_strndup(void) { - /* FIXME */ + char *x; + printf("test: strndup\n"); + x = strndup("bla", 0); + if (strcmp(x, "") != 0) { + printf("failure: strndup [\ninvalid\n]\n"); + return false; + } + free(x); + x = strndup("bla", 2); + if (strcmp(x, "bl") != 0) { + printf("failure: strndup [\ninvalid\n]\n"); + return false; + } + free(x); + x = strndup("bla", 10); + if (strcmp(x, "bla") != 0) { + printf("failure: strndup [\ninvalid\n]\n"); + return false; + } + free(x); + printf("success: strndup\n"); return true; } static int test_strnlen(void) { - /* FIXME */ + printf("test: strnlen\n"); + if (strnlen("bla", 2) != 2) { + printf("failure: strnlen [\nunexpected length\n]\n"); + return false; + } + + if (strnlen("some text\n", 0) != 0) { + printf("failure: strnlen [\nunexpected length\n]\n"); + return false; + } + + if (strnlen("some text", 20) != 9) { + printf("failure: strnlen [\nunexpected length\n]\n"); + return false; + } + + printf("success: strnlen\n"); return true; } @@ -255,13 +320,43 @@ static int test_setegid(void) static int test_asprintf(void) { - /* FIXME */ + char *x; + printf("test: asprintf\n"); + if (asprintf(&x, "%d", 9) != 1) { + printf("failure: asprintf [\ngenerate asprintf\n]\n"); + return false; + } + if (strcmp(x, "9") != 0) { + printf("failure: asprintf [\ngenerate asprintf\n]\n"); + return false; + } + if (asprintf(&x, "dat%s", "a") != 4) { + printf("failure: asprintf [\ngenerate asprintf\n]\n"); + return false; + } + if (strcmp(x, "data") != 0) { + printf("failure: asprintf [\ngenerate asprintf\n]\n"); + return false; + } + printf("success: asprintf\n"); return true; } static int test_snprintf(void) { - /* FIXME */ + char tmp[10]; + printf("test: snprintf\n"); + if (snprintf(tmp, 3, "foo%d", 9) != 4) { + printf("failure: snprintf [\nsnprintf return code failed\n]\n"); + return false; + } + + if (strcmp(tmp, "fo") != 0) { + printf("failure: snprintf [\nsnprintf failed\n]\n"); + return false; + } + + printf("success: snprintf\n"); return true; } @@ -328,13 +423,22 @@ static int test_bzero(void) static int test_strerror(void) { + printf("test: strerror\n"); /* FIXME */ + printf("failure: sterror\n"); return true; } static int test_errno(void) { - /* FIXME */ + printf("test: errno\n"); + errno = 3; + if (errno != 3) { + printf("failure: errno [\nerrno failed\n]\n"); + return false; + } + + printf("success: errno\n"); return true; } @@ -376,7 +480,20 @@ static int test_inet_ntoa(void) static int test_strtoll(void) { - /* FIXME */ + printf("test: strtoll\n"); + if (strtoll("15", NULL, 10) != 15) { + printf("failure: strtoll [\nstrtoll failed\n]\n"); + return false; + } + if (strtoll("10", NULL, 16) != 16) { + printf("failure: strtoll [\nstrtoll hex failed\n]\n"); + return false; + } + if (strtoll("11", NULL, 2) != 3) { + printf("failure: strtoll [\nstrtoll binary failed\n]\n"); + return false; + } + printf("success: strtoll\n"); return true; } @@ -410,19 +527,42 @@ static int test_va_copy(void) static int test_FUNCTION(void) { - /* FIXME: test __FUNCTION__ macro */ + printf("test: FUNCTION\n"); + if (strcmp(__FUNCTION__, "test_FUNCTION") != 0) { + printf("failure: FAILURE [\nFAILURE invalid\n]\n"); + return false; + } + printf("success: FUNCTION\n"); return true; } static int test_MIN(void) { - /* FIXME */ + printf("test: MIN\n"); + if (MIN(20, 1) != 1) { + printf("failure: MIN [\nMIN invalid\n]\n"); + return false; + } + if (MIN(1, 20) != 1) { + printf("failure: MIN [\nMIN invalid\n]\n"); + return false; + } + printf("success: MIN\n"); return true; } static int test_MAX(void) { - /* FIXME */ + printf("test: MAX\n"); + if (MAX(20, 1) != 20) { + printf("failure: MAX [\nMAX invalid\n]\n"); + return false; + } + if (MAX(1, 20) != 20) { + printf("failure: MAX [\nMAX invalid\n]\n"); + return false; + } + printf("success: MAX\n"); return true; } -- cgit From eb49760603a043163b7cc80c781a16eac376aee2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 14 Apr 2007 09:14:40 +0000 Subject: r22215: add strptime replacement to libreplace based on the patch from jojowil@hvcc.edu to bug 4063 also add a testsuite for strptime() metze (This used to be commit aba64521707143e6505b3322c390882a918a148a) --- source4/lib/replace/README | 1 + source4/lib/replace/libreplace.m4 | 1 + source4/lib/replace/replace.h | 6 + source4/lib/replace/strptime.c | 991 +++++++++++++++++++++++++++++++++++ source4/lib/replace/strptime.m4 | 21 + source4/lib/replace/test/testsuite.c | 110 ++++ 6 files changed, 1130 insertions(+) create mode 100644 source4/lib/replace/strptime.c create mode 100644 source4/lib/replace/strptime.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 8fe9f24e79..8e0e659c7d 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -53,6 +53,7 @@ inet_ntoa strtoll strtoull socketpair +strptime Types: bool diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 12be9f6016..33cd0894c1 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -327,6 +327,7 @@ m4_include(system/config.m4) m4_include(dlfcn.m4) m4_include(getpass.m4) +m4_include(strptime.m4) m4_include(win32.m4) m4_include(timegm.m4) m4_include(repdir.m4) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index b36a350335..7d6dcec7f1 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -280,6 +280,12 @@ void rep_vsyslog (int facility_priority, const char *format, va_list arglist) PR typedef int (*comparison_fn_t)(const void *, const void *); #endif +#ifdef REPLACE_STRPTIME +#define strptime rep_strptime +struct tm; +char *rep_strptime(const char *buf, const char *format, struct tm *tm); +#endif + /* Load header file for dynamic linking stuff */ #ifdef HAVE_DLFCN_H #include diff --git a/source4/lib/replace/strptime.c b/source4/lib/replace/strptime.c new file mode 100644 index 0000000000..8fb919472e --- /dev/null +++ b/source4/lib/replace/strptime.c @@ -0,0 +1,991 @@ +/* Convert a string representation of time to a time value. + Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1996. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* XXX This version of the implementation is not really complete. + Some of the fields cannot add information alone. But if seeing + some of them in the same format (such as year, week and weekday) + this is enough information for determining the date. */ + +#include "replace.h" +#include "system/locale.h" +#include "system/time.h" + +#ifndef __P +# if defined (__GNUC__) || (defined (__STDC__) && __STDC__) +# define __P(args) args +# else +# define __P(args) () +# endif /* GCC. */ +#endif /* Not __P. */ + +#if ! HAVE_LOCALTIME_R && ! defined localtime_r +# ifdef _LIBC +# define localtime_r __localtime_r +# else +/* Approximate localtime_r as best we can in its absence. */ +# define localtime_r my_localtime_r +static struct tm *localtime_r __P ((const time_t *, struct tm *)); +static struct tm * +localtime_r (t, tp) + const time_t *t; + struct tm *tp; +{ + struct tm *l = localtime (t); + if (! l) + return 0; + *tp = *l; + return tp; +} +# endif /* ! _LIBC */ +#endif /* ! HAVE_LOCALTIME_R && ! defined (localtime_r) */ + + +#define match_char(ch1, ch2) if (ch1 != ch2) return NULL +#if defined __GNUC__ && __GNUC__ >= 2 +# define match_string(cs1, s2) \ + ({ size_t len = strlen (cs1); \ + int result = strncasecmp ((cs1), (s2), len) == 0; \ + if (result) (s2) += len; \ + result; }) +#else +/* Oh come on. Get a reasonable compiler. */ +# define match_string(cs1, s2) \ + (strncasecmp ((cs1), (s2), strlen (cs1)) ? 0 : ((s2) += strlen (cs1), 1)) +#endif +/* We intentionally do not use isdigit() for testing because this will + lead to problems with the wide character version. */ +#define get_number(from, to, n) \ + do { \ + int __n = n; \ + val = 0; \ + while (*rp == ' ') \ + ++rp; \ + if (*rp < '0' || *rp > '9') \ + return NULL; \ + do { \ + val *= 10; \ + val += *rp++ - '0'; \ + } while (--__n > 0 && val * 10 <= to && *rp >= '0' && *rp <= '9'); \ + if (val < from || val > to) \ + return NULL; \ + } while (0) +#ifdef _NL_CURRENT +# define get_alt_number(from, to, n) \ + ({ \ + __label__ do_normal; \ + if (*decided != raw) \ + { \ + const char *alts = _NL_CURRENT (LC_TIME, ALT_DIGITS); \ + int __n = n; \ + int any = 0; \ + while (*rp == ' ') \ + ++rp; \ + val = 0; \ + do { \ + val *= 10; \ + while (*alts != '\0') \ + { \ + size_t len = strlen (alts); \ + if (strncasecmp (alts, rp, len) == 0) \ + break; \ + alts += len + 1; \ + ++val; \ + } \ + if (*alts == '\0') \ + { \ + if (*decided == not && ! any) \ + goto do_normal; \ + /* If we haven't read anything it's an error. */ \ + if (! any) \ + return NULL; \ + /* Correct the premature multiplication. */ \ + val /= 10; \ + break; \ + } \ + else \ + *decided = loc; \ + } while (--__n > 0 && val * 10 <= to); \ + if (val < from || val > to) \ + return NULL; \ + } \ + else \ + { \ + do_normal: \ + get_number (from, to, n); \ + } \ + 0; \ + }) +#else +# define get_alt_number(from, to, n) \ + /* We don't have the alternate representation. */ \ + get_number(from, to, n) +#endif +#define recursive(new_fmt) \ + (*(new_fmt) != '\0' \ + && (rp = strptime_internal (rp, (new_fmt), tm, decided, era_cnt)) != NULL) + + +#ifdef _LIBC +/* This is defined in locale/C-time.c in the GNU libc. */ +extern const struct locale_data _nl_C_LC_TIME; +extern const unsigned short int __mon_yday[2][13]; + +# define weekday_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (DAY_1)].string) +# define ab_weekday_name \ + (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABDAY_1)].string) +# define month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (MON_1)].string) +# define ab_month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABMON_1)].string) +# define HERE_D_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_T_FMT)].string) +# define HERE_D_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (D_FMT)].string) +# define HERE_AM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (AM_STR)].string) +# define HERE_PM_STR (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (PM_STR)].string) +# define HERE_T_FMT_AMPM \ + (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT_AMPM)].string) +# define HERE_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT)].string) + +# define strncasecmp(s1, s2, n) __strncasecmp (s1, s2, n) +#else +static char const weekday_name[][10] = + { + "Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday" + }; +static char const ab_weekday_name[][4] = + { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; +static char const month_name[][10] = + { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }; +static char const ab_month_name[][4] = + { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; +# define HERE_D_T_FMT "%a %b %e %H:%M:%S %Y" +# define HERE_D_FMT "%m/%d/%y" +# define HERE_AM_STR "AM" +# define HERE_PM_STR "PM" +# define HERE_T_FMT_AMPM "%I:%M:%S %p" +# define HERE_T_FMT "%H:%M:%S" + +static const unsigned short int __mon_yday[2][13] = + { + /* Normal years. */ + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, + /* Leap years. */ + { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } + }; +#endif + +/* Status of lookup: do we use the locale data or the raw data? */ +enum locale_status { not, loc, raw }; + + +#ifndef __isleap +/* Nonzero if YEAR is a leap year (every 4 years, + except every 100th isn't, and every 400th is). */ +# define __isleap(year) \ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) +#endif + +/* Compute the day of the week. */ +static void +day_of_the_week (struct tm *tm) +{ + /* We know that January 1st 1970 was a Thursday (= 4). Compute the + the difference between this data in the one on TM and so determine + the weekday. */ + int corr_year = 1900 + tm->tm_year - (tm->tm_mon < 2); + int wday = (-473 + + (365 * (tm->tm_year - 70)) + + (corr_year / 4) + - ((corr_year / 4) / 25) + ((corr_year / 4) % 25 < 0) + + (((corr_year / 4) / 25) / 4) + + __mon_yday[0][tm->tm_mon] + + tm->tm_mday - 1); + tm->tm_wday = ((wday % 7) + 7) % 7; +} + +/* Compute the day of the year. */ +static void +day_of_the_year (struct tm *tm) +{ + tm->tm_yday = (__mon_yday[__isleap (1900 + tm->tm_year)][tm->tm_mon] + + (tm->tm_mday - 1)); +} + +static char * +#ifdef _LIBC +internal_function +#endif +strptime_internal __P ((const char *rp, const char *fmt, struct tm *tm, + enum locale_status *decided, int era_cnt)); + +static char * +#ifdef _LIBC +internal_function +#endif +strptime_internal (rp, fmt, tm, decided, era_cnt) + const char *rp; + const char *fmt; + struct tm *tm; + enum locale_status *decided; + int era_cnt; +{ + const char *rp_backup; + int cnt; + size_t val; + int have_I, is_pm; + int century, want_century; + int want_era; + int have_wday, want_xday; + int have_yday; + int have_mon, have_mday; +#ifdef _NL_CURRENT + size_t num_eras; +#endif + struct era_entry *era; + + have_I = is_pm = 0; + century = -1; + want_century = 0; + want_era = 0; + era = NULL; + + have_wday = want_xday = have_yday = have_mon = have_mday = 0; + + while (*fmt != '\0') + { + /* A white space in the format string matches 0 more or white + space in the input string. */ + if (isspace (*fmt)) + { + while (isspace (*rp)) + ++rp; + ++fmt; + continue; + } + + /* Any character but `%' must be matched by the same character + in the iput string. */ + if (*fmt != '%') + { + match_char (*fmt++, *rp++); + continue; + } + + ++fmt; +#ifndef _NL_CURRENT + /* We need this for handling the `E' modifier. */ + start_over: +#endif + + /* Make back up of current processing pointer. */ + rp_backup = rp; + + switch (*fmt++) + { + case '%': + /* Match the `%' character itself. */ + match_char ('%', *rp++); + break; + case 'a': + case 'A': + /* Match day of week. */ + for (cnt = 0; cnt < 7; ++cnt) + { +#ifdef _NL_CURRENT + if (*decided !=raw) + { + if (match_string (_NL_CURRENT (LC_TIME, DAY_1 + cnt), rp)) + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, DAY_1 + cnt), + weekday_name[cnt])) + *decided = loc; + break; + } + if (match_string (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), rp)) + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), + ab_weekday_name[cnt])) + *decided = loc; + break; + } + } +#endif + if (*decided != loc + && (match_string (weekday_name[cnt], rp) + || match_string (ab_weekday_name[cnt], rp))) + { + *decided = raw; + break; + } + } + if (cnt == 7) + /* Does not match a weekday name. */ + return NULL; + tm->tm_wday = cnt; + have_wday = 1; + break; + case 'b': + case 'B': + case 'h': + /* Match month name. */ + for (cnt = 0; cnt < 12; ++cnt) + { +#ifdef _NL_CURRENT + if (*decided !=raw) + { + if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), rp)) + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, MON_1 + cnt), + month_name[cnt])) + *decided = loc; + break; + } + if (match_string (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), rp)) + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), + ab_month_name[cnt])) + *decided = loc; + break; + } + } +#endif + if (match_string (month_name[cnt], rp) + || match_string (ab_month_name[cnt], rp)) + { + *decided = raw; + break; + } + } + if (cnt == 12) + /* Does not match a month name. */ + return NULL; + tm->tm_mon = cnt; + want_xday = 1; + break; + case 'c': + /* Match locale's date and time format. */ +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (!recursive (_NL_CURRENT (LC_TIME, D_T_FMT))) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (*decided == not && + strcmp (_NL_CURRENT (LC_TIME, D_T_FMT), HERE_D_T_FMT)) + *decided = loc; + want_xday = 1; + break; + } + *decided = raw; + } +#endif + if (!recursive (HERE_D_T_FMT)) + return NULL; + want_xday = 1; + break; + case 'C': + /* Match century number. */ +#ifdef _NL_CURRENT + match_century: +#endif + get_number (0, 99, 2); + century = val; + want_xday = 1; + break; + case 'd': + case 'e': + /* Match day of month. */ + get_number (1, 31, 2); + tm->tm_mday = val; + have_mday = 1; + want_xday = 1; + break; + case 'F': + if (!recursive ("%Y-%m-%d")) + return NULL; + want_xday = 1; + break; + case 'x': +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (!recursive (_NL_CURRENT (LC_TIME, D_FMT))) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (*decided == not + && strcmp (_NL_CURRENT (LC_TIME, D_FMT), HERE_D_FMT)) + *decided = loc; + want_xday = 1; + break; + } + *decided = raw; + } +#endif + /* Fall through. */ + case 'D': + /* Match standard day format. */ + if (!recursive (HERE_D_FMT)) + return NULL; + want_xday = 1; + break; + case 'k': + case 'H': + /* Match hour in 24-hour clock. */ + get_number (0, 23, 2); + tm->tm_hour = val; + have_I = 0; + break; + case 'I': + /* Match hour in 12-hour clock. */ + get_number (1, 12, 2); + tm->tm_hour = val % 12; + have_I = 1; + break; + case 'j': + /* Match day number of year. */ + get_number (1, 366, 3); + tm->tm_yday = val - 1; + have_yday = 1; + break; + case 'm': + /* Match number of month. */ + get_number (1, 12, 2); + tm->tm_mon = val - 1; + have_mon = 1; + want_xday = 1; + break; + case 'M': + /* Match minute. */ + get_number (0, 59, 2); + tm->tm_min = val; + break; + case 'n': + case 't': + /* Match any white space. */ + while (isspace (*rp)) + ++rp; + break; + case 'p': + /* Match locale's equivalent of AM/PM. */ +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (match_string (_NL_CURRENT (LC_TIME, AM_STR), rp)) + { + if (strcmp (_NL_CURRENT (LC_TIME, AM_STR), HERE_AM_STR)) + *decided = loc; + break; + } + if (match_string (_NL_CURRENT (LC_TIME, PM_STR), rp)) + { + if (strcmp (_NL_CURRENT (LC_TIME, PM_STR), HERE_PM_STR)) + *decided = loc; + is_pm = 1; + break; + } + *decided = raw; + } +#endif + if (!match_string (HERE_AM_STR, rp)) { + if (match_string (HERE_PM_STR, rp)) { + is_pm = 1; + } else { + return NULL; + } + } + break; + case 'r': +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (!recursive (_NL_CURRENT (LC_TIME, T_FMT_AMPM))) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (*decided == not && + strcmp (_NL_CURRENT (LC_TIME, T_FMT_AMPM), + HERE_T_FMT_AMPM)) + *decided = loc; + break; + } + *decided = raw; + } +#endif + if (!recursive (HERE_T_FMT_AMPM)) + return NULL; + break; + case 'R': + if (!recursive ("%H:%M")) + return NULL; + break; + case 's': + { + /* The number of seconds may be very high so we cannot use + the `get_number' macro. Instead read the number + character for character and construct the result while + doing this. */ + time_t secs = 0; + if (*rp < '0' || *rp > '9') + /* We need at least one digit. */ + return NULL; + + do + { + secs *= 10; + secs += *rp++ - '0'; + } + while (*rp >= '0' && *rp <= '9'); + + if (localtime_r (&secs, tm) == NULL) + /* Error in function. */ + return NULL; + } + break; + case 'S': + get_number (0, 61, 2); + tm->tm_sec = val; + break; + case 'X': +#ifdef _NL_CURRENT + if (*decided != raw) + { + if (!recursive (_NL_CURRENT (LC_TIME, T_FMT))) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (strcmp (_NL_CURRENT (LC_TIME, T_FMT), HERE_T_FMT)) + *decided = loc; + break; + } + *decided = raw; + } +#endif + /* Fall through. */ + case 'T': + if (!recursive (HERE_T_FMT)) + return NULL; + break; + case 'u': + get_number (1, 7, 1); + tm->tm_wday = val % 7; + have_wday = 1; + break; + case 'g': + get_number (0, 99, 2); + /* XXX This cannot determine any field in TM. */ + break; + case 'G': + if (*rp < '0' || *rp > '9') + return NULL; + /* XXX Ignore the number since we would need some more + information to compute a real date. */ + do + ++rp; + while (*rp >= '0' && *rp <= '9'); + break; + case 'U': + case 'V': + case 'W': + get_number (0, 53, 2); + /* XXX This cannot determine any field in TM without some + information. */ + break; + case 'w': + /* Match number of weekday. */ + get_number (0, 6, 1); + tm->tm_wday = val; + have_wday = 1; + break; + case 'y': +#ifdef _NL_CURRENT + match_year_in_century: +#endif + /* Match year within century. */ + get_number (0, 99, 2); + /* The "Year 2000: The Millennium Rollover" paper suggests that + values in the range 69-99 refer to the twentieth century. */ + tm->tm_year = val >= 69 ? val : val + 100; + /* Indicate that we want to use the century, if specified. */ + want_century = 1; + want_xday = 1; + break; + case 'Y': + /* Match year including century number. */ + get_number (0, 9999, 4); + tm->tm_year = val - 1900; + want_century = 0; + want_xday = 1; + break; + case 'Z': + /* XXX How to handle this? */ + break; + case 'E': +#ifdef _NL_CURRENT + switch (*fmt++) + { + case 'c': + /* Match locale's alternate date and time format. */ + if (*decided != raw) + { + const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT); + + if (*fmt == '\0') + fmt = _NL_CURRENT (LC_TIME, D_T_FMT); + + if (!recursive (fmt)) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (strcmp (fmt, HERE_D_T_FMT)) + *decided = loc; + want_xday = 1; + break; + } + *decided = raw; + } + /* The C locale has no era information, so use the + normal representation. */ + if (!recursive (HERE_D_T_FMT)) + return NULL; + want_xday = 1; + break; + case 'C': + if (*decided != raw) + { + if (era_cnt >= 0) + { + era = _nl_select_era_entry (era_cnt); + if (match_string (era->era_name, rp)) + { + *decided = loc; + break; + } + else + return NULL; + } + else + { + num_eras = _NL_CURRENT_WORD (LC_TIME, + _NL_TIME_ERA_NUM_ENTRIES); + for (era_cnt = 0; era_cnt < (int) num_eras; + ++era_cnt, rp = rp_backup) + { + era = _nl_select_era_entry (era_cnt); + if (match_string (era->era_name, rp)) + { + *decided = loc; + break; + } + } + if (era_cnt == (int) num_eras) + { + era_cnt = -1; + if (*decided == loc) + return NULL; + } + else + break; + } + + *decided = raw; + } + /* The C locale has no era information, so use the + normal representation. */ + goto match_century; + case 'y': + if (*decided == raw) + goto match_year_in_century; + + get_number(0, 9999, 4); + tm->tm_year = val; + want_era = 1; + want_xday = 1; + break; + case 'Y': + if (*decided != raw) + { + num_eras = _NL_CURRENT_WORD (LC_TIME, + _NL_TIME_ERA_NUM_ENTRIES); + for (era_cnt = 0; era_cnt < (int) num_eras; + ++era_cnt, rp = rp_backup) + { + era = _nl_select_era_entry (era_cnt); + if (recursive (era->era_format)) + break; + } + if (era_cnt == (int) num_eras) + { + era_cnt = -1; + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + *decided = loc; + era_cnt = -1; + break; + } + + *decided = raw; + } + get_number (0, 9999, 4); + tm->tm_year = val - 1900; + want_century = 0; + want_xday = 1; + break; + case 'x': + if (*decided != raw) + { + const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_FMT); + + if (*fmt == '\0') + fmt = _NL_CURRENT (LC_TIME, D_FMT); + + if (!recursive (fmt)) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (strcmp (fmt, HERE_D_FMT)) + *decided = loc; + break; + } + *decided = raw; + } + if (!recursive (HERE_D_FMT)) + return NULL; + break; + case 'X': + if (*decided != raw) + { + const char *fmt = _NL_CURRENT (LC_TIME, ERA_T_FMT); + + if (*fmt == '\0') + fmt = _NL_CURRENT (LC_TIME, T_FMT); + + if (!recursive (fmt)) + { + if (*decided == loc) + return NULL; + else + rp = rp_backup; + } + else + { + if (strcmp (fmt, HERE_T_FMT)) + *decided = loc; + break; + } + *decided = raw; + } + if (!recursive (HERE_T_FMT)) + return NULL; + break; + default: + return NULL; + } + break; +#else + /* We have no information about the era format. Just use + the normal format. */ + if (*fmt != 'c' && *fmt != 'C' && *fmt != 'y' && *fmt != 'Y' + && *fmt != 'x' && *fmt != 'X') + /* This is an illegal format. */ + return NULL; + + goto start_over; +#endif + case 'O': + switch (*fmt++) + { + case 'd': + case 'e': + /* Match day of month using alternate numeric symbols. */ + get_alt_number (1, 31, 2); + tm->tm_mday = val; + have_mday = 1; + want_xday = 1; + break; + case 'H': + /* Match hour in 24-hour clock using alternate numeric + symbols. */ + get_alt_number (0, 23, 2); + tm->tm_hour = val; + have_I = 0; + break; + case 'I': + /* Match hour in 12-hour clock using alternate numeric + symbols. */ + get_alt_number (1, 12, 2); + tm->tm_hour = val - 1; + have_I = 1; + break; + case 'm': + /* Match month using alternate numeric symbols. */ + get_alt_number (1, 12, 2); + tm->tm_mon = val - 1; + have_mon = 1; + want_xday = 1; + break; + case 'M': + /* Match minutes using alternate numeric symbols. */ + get_alt_number (0, 59, 2); + tm->tm_min = val; + break; + case 'S': + /* Match seconds using alternate numeric symbols. */ + get_alt_number (0, 61, 2); + tm->tm_sec = val; + break; + case 'U': + case 'V': + case 'W': + get_alt_number (0, 53, 2); + /* XXX This cannot determine any field in TM without + further information. */ + break; + case 'w': + /* Match number of weekday using alternate numeric symbols. */ + get_alt_number (0, 6, 1); + tm->tm_wday = val; + have_wday = 1; + break; + case 'y': + /* Match year within century using alternate numeric symbols. */ + get_alt_number (0, 99, 2); + tm->tm_year = val >= 69 ? val : val + 100; + want_xday = 1; + break; + default: + return NULL; + } + break; + default: + return NULL; + } + } + + if (have_I && is_pm) + tm->tm_hour += 12; + + if (century != -1) + { + if (want_century) + tm->tm_year = tm->tm_year % 100 + (century - 19) * 100; + else + /* Only the century, but not the year. Strange, but so be it. */ + tm->tm_year = (century - 19) * 100; + } + +#ifdef _NL_CURRENT + if (era_cnt != -1) + { + era = _nl_select_era_entry(era_cnt); + if (want_era) + tm->tm_year = (era->start_date[0] + + ((tm->tm_year - era->offset) + * era->absolute_direction)); + else + /* Era start year assumed. */ + tm->tm_year = era->start_date[0]; + } + else +#endif + if (want_era) + return NULL; + + if (want_xday && !have_wday) + { + if ( !(have_mon && have_mday) && have_yday) + { + /* We don't have tm_mon and/or tm_mday, compute them. */ + int t_mon = 0; + while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday) + t_mon++; + if (!have_mon) + tm->tm_mon = t_mon - 1; + if (!have_mday) + tm->tm_mday = + (tm->tm_yday + - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1); + } + day_of_the_week (tm); + } + if (want_xday && !have_yday) + day_of_the_year (tm); + + return (char *) rp; +} + + +char *rep_strptime(const char *buf, const char *format, struct tm *tm) +{ + enum locale_status decided; + +#ifdef _NL_CURRENT + decided = not; +#else + decided = raw; +#endif + return strptime_internal (buf, format, tm, &decided, -1); +} diff --git a/source4/lib/replace/strptime.m4 b/source4/lib/replace/strptime.m4 new file mode 100644 index 0000000000..0f2065fd62 --- /dev/null +++ b/source4/lib/replace/strptime.m4 @@ -0,0 +1,21 @@ +AC_CACHE_CHECK([whether strptime is available and works],libreplace_cv_STRPTIME_OK,[ + AC_TRY_RUN([ + #include + #include + #include + int main (void) { + const char *s = "20061004023546Z"; + char *ret; + struct tm t; + ret = strptime(s, "%Y%m%d%H%M%S", &t); + if ( ret == NULL ) return 1; + return 0; + }], + [libreplace_cv_STRPTIME_OK=yes], + [libreplace_cv_STRPTIME_OK=no], + [libreplace_cv_STRPTIME_OK="assuming not"]) +]) +if test x"$libreplace_cv_STRPTIME_OK" != x"yes"; then + AC_DEFINE(REPLACE_STRPTIME,1,[Whether strptime should be replaced]) + LIBREPLACEOBJ="${LIBREPLACEOBJ} strptime.o" +fi diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 1e881aa10e..a992fd8c0f 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -606,6 +606,115 @@ static int test_socketpair(void) return true; } +static int test_strptime(void) +{ + const char *s = "20070414101546Z"; + char *ret; + struct tm t, t2; + + printf("test: strptime\n"); + + ret = strptime(s, "%Y%m%d%H%M%S", &t); + if ( ret == NULL ) { + printf("failure: strptime [\n" + "returned NULL\n" + "]\n"); + return false; + } + + ret = strptime(s, "%Y%m%d%H%M%SZ", &t2); + if ( ret == NULL ) { + printf("failure: strptime [\n" + "returned NULL with Z\n" + "]\n"); + return false; + } + + if (memcmp(&t, &t2, sizeof(t)) == 0) { + printf("failure: strptime [\n" + "result differs if the format string has a 'Z' at the end\n" + "]\n"); + return false; + } + + if (t.tm_sec != 46) { + printf("failure: strptime [\n" + "tm_sec: expected: 46, got: %d\n" + "]\n", + t.tm_sec); + return false; + } + + if (t.tm_min != 15) { + printf("failure: strptime [\n" + "tm_min: expected: 15, got: %d\n" + "]\n", + t.tm_min); + return false; + } + + if (t.tm_hour != 10) { + printf("failure: strptime [\n" + "tm_hour: expected: 10, got: %d\n" + "]\n", + t.tm_hour); + return false; + } + + if (t.tm_mday != 14) { + printf("failure: strptime [\n" + "tm_mday: expected: 14, got: %d\n" + "]\n", + t.tm_mday); + return false; + } + + if (t.tm_mon != 3) { + printf("failure: strptime [\n" + "tm_mon: expected: 3, got: %d\n" + "]\n", + t.tm_mon); + return false; + } + + if (t.tm_year != 107) { + printf("failure: strptime [\n" + "tm_year: expected: 107, got: %d\n" + "]\n", + t.tm_year); + return false; + } + + if (t.tm_wday != 6) { /* saturday */ + printf("failure: strptime [\n" + "tm_wday: expected: 6, got: %d\n" + "]\n", + t.tm_wday); + return false; + } + + if (t.tm_yday != 103) { + printf("failure: strptime [\n" + "tm_yday: expected: 103, got: %d\n" + "]\n", + t.tm_yday); + return false; + } + + /* we don't test this as it depends on the host configuration + if (t.tm_isdst != 0) { + printf("failure: strptime [\n" + "tm_isdst: expected: 0, got: %d\n" + "]\n", + t.tm_isdst); + return false; + }*/ + + printf("success: strptime\n"); + + return true; +} + struct torture_context; bool torture_local_replace(struct torture_context *ctx) { @@ -653,6 +762,7 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_MIN(); ret &= test_MAX(); ret &= test_socketpair(); + ret &= test_strptime(); return ret; } -- cgit From aea41afb52e24077e7b1e28f5090326665d7c3f6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 15 Apr 2007 16:13:06 +0000 Subject: r22216: move strptime testsuite into it's own file so we can include it for the configure test as it seems that strptime() is really broken on some hosts in the build farm, re should use the replacement code when we detect this in the configure test metze (This used to be commit 08a5e9760643b9fbf00fdcf7163de7cf50e841e6) --- source4/lib/replace/strptime.m4 | 14 +--- source4/lib/replace/test/strptime.c | 152 +++++++++++++++++++++++++++++++++++ source4/lib/replace/test/testsuite.c | 108 +------------------------ 3 files changed, 158 insertions(+), 116 deletions(-) create mode 100644 source4/lib/replace/test/strptime.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/strptime.m4 b/source4/lib/replace/strptime.m4 index 0f2065fd62..da22fc5a97 100644 --- a/source4/lib/replace/strptime.m4 +++ b/source4/lib/replace/strptime.m4 @@ -1,16 +1,8 @@ AC_CACHE_CHECK([whether strptime is available and works],libreplace_cv_STRPTIME_OK,[ AC_TRY_RUN([ - #include - #include - #include - int main (void) { - const char *s = "20061004023546Z"; - char *ret; - struct tm t; - ret = strptime(s, "%Y%m%d%H%M%S", &t); - if ( ret == NULL ) return 1; - return 0; - }], + #define LIBREPLACE_CONFIGURE_TEST_STRPTIME + #include "$libreplacedir/test/strptime.c" + ], [libreplace_cv_STRPTIME_OK=yes], [libreplace_cv_STRPTIME_OK=no], [libreplace_cv_STRPTIME_OK="assuming not"]) diff --git a/source4/lib/replace/test/strptime.c b/source4/lib/replace/test/strptime.c new file mode 100644 index 0000000000..434b5d0933 --- /dev/null +++ b/source4/lib/replace/test/strptime.c @@ -0,0 +1,152 @@ + +#ifdef LIBREPLACE_CONFIGURE_TEST_STRPTIME + +#include +#include +#include + +#define true 1 +#define false 0 + +/* make printf a no-op */ +#define printf if(0) printf + +#else /* LIBREPLACE_CONFIGURE_TEST_STRPTIME */ + +#include "replace.h" +#include "system/time.h" + +#endif /* LIBREPLACE_CONFIGURE_TEST_STRPTIME */ + +int libreplace_test_strptime(void) +{ + const char *s = "20070414101546Z"; + char *ret; + struct tm t, t2; + + printf("test: strptime\n"); + + ret = strptime(s, "%Y%m%d%H%M%S", &t); + if ( ret == NULL ) { + printf("failure: strptime [\n" + "returned NULL\n" + "]\n"); + return false; + } + + if ( *ret != 'Z' ) { + printf("failure: strptime [\n" + "ret doesn't point to 'Z'\n" + "]\n"); + return false; + } + + ret = strptime(s, "%Y%m%d%H%M%SZ", &t2); + if ( ret == NULL ) { + printf("failure: strptime [\n" + "returned NULL with Z\n" + "]\n"); + return false; + } + + if ( *ret != '\0' ) { + printf("failure: strptime [\n" + "ret doesn't point to '\\0'\n" + "]\n"); + return false; + } + + if (memcmp(&t, &t2, sizeof(t)) == 0) { + printf("failure: strptime [\n" + "result differs if the format string has a 'Z' at the end\n" + "]\n"); + return false; + } + + if (t.tm_sec != 46) { + printf("failure: strptime [\n" + "tm_sec: expected: 46, got: %d\n" + "]\n", + t.tm_sec); + return false; + } + + if (t.tm_min != 15) { + printf("failure: strptime [\n" + "tm_min: expected: 15, got: %d\n" + "]\n", + t.tm_min); + return false; + } + + if (t.tm_hour != 10) { + printf("failure: strptime [\n" + "tm_hour: expected: 10, got: %d\n" + "]\n", + t.tm_hour); + return false; + } + + if (t.tm_mday != 14) { + printf("failure: strptime [\n" + "tm_mday: expected: 14, got: %d\n" + "]\n", + t.tm_mday); + return false; + } + + if (t.tm_mon != 3) { + printf("failure: strptime [\n" + "tm_mon: expected: 3, got: %d\n" + "]\n", + t.tm_mon); + return false; + } + + if (t.tm_year != 107) { + printf("failure: strptime [\n" + "tm_year: expected: 107, got: %d\n" + "]\n", + t.tm_year); + return false; + } + + if (t.tm_wday != 6) { /* saturday */ + printf("failure: strptime [\n" + "tm_wday: expected: 6, got: %d\n" + "]\n", + t.tm_wday); + return false; + } + + if (t.tm_yday != 103) { + printf("failure: strptime [\n" + "tm_yday: expected: 103, got: %d\n" + "]\n", + t.tm_yday); + return false; + } + + /* we don't test this as it depends on the host configuration + if (t.tm_isdst != 0) { + printf("failure: strptime [\n" + "tm_isdst: expected: 0, got: %d\n" + "]\n", + t.tm_isdst); + return false; + }*/ + + printf("success: strptime\n"); + + return true; +} + +#ifdef LIBREPLACE_CONFIGURE_TEST_STRPTIME +int main (void) +{ + int ret; + ret = libreplace_test_strptime(); + if (ret == false) return 1; + return 0; +} +#endif diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index a992fd8c0f..7d45feec6b 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -606,113 +606,11 @@ static int test_socketpair(void) return true; } +extern int libreplace_test_strptime(void); + static int test_strptime(void) { - const char *s = "20070414101546Z"; - char *ret; - struct tm t, t2; - - printf("test: strptime\n"); - - ret = strptime(s, "%Y%m%d%H%M%S", &t); - if ( ret == NULL ) { - printf("failure: strptime [\n" - "returned NULL\n" - "]\n"); - return false; - } - - ret = strptime(s, "%Y%m%d%H%M%SZ", &t2); - if ( ret == NULL ) { - printf("failure: strptime [\n" - "returned NULL with Z\n" - "]\n"); - return false; - } - - if (memcmp(&t, &t2, sizeof(t)) == 0) { - printf("failure: strptime [\n" - "result differs if the format string has a 'Z' at the end\n" - "]\n"); - return false; - } - - if (t.tm_sec != 46) { - printf("failure: strptime [\n" - "tm_sec: expected: 46, got: %d\n" - "]\n", - t.tm_sec); - return false; - } - - if (t.tm_min != 15) { - printf("failure: strptime [\n" - "tm_min: expected: 15, got: %d\n" - "]\n", - t.tm_min); - return false; - } - - if (t.tm_hour != 10) { - printf("failure: strptime [\n" - "tm_hour: expected: 10, got: %d\n" - "]\n", - t.tm_hour); - return false; - } - - if (t.tm_mday != 14) { - printf("failure: strptime [\n" - "tm_mday: expected: 14, got: %d\n" - "]\n", - t.tm_mday); - return false; - } - - if (t.tm_mon != 3) { - printf("failure: strptime [\n" - "tm_mon: expected: 3, got: %d\n" - "]\n", - t.tm_mon); - return false; - } - - if (t.tm_year != 107) { - printf("failure: strptime [\n" - "tm_year: expected: 107, got: %d\n" - "]\n", - t.tm_year); - return false; - } - - if (t.tm_wday != 6) { /* saturday */ - printf("failure: strptime [\n" - "tm_wday: expected: 6, got: %d\n" - "]\n", - t.tm_wday); - return false; - } - - if (t.tm_yday != 103) { - printf("failure: strptime [\n" - "tm_yday: expected: 103, got: %d\n" - "]\n", - t.tm_yday); - return false; - } - - /* we don't test this as it depends on the host configuration - if (t.tm_isdst != 0) { - printf("failure: strptime [\n" - "tm_isdst: expected: 0, got: %d\n" - "]\n", - t.tm_isdst); - return false; - }*/ - - printf("success: strptime\n"); - - return true; + return libreplace_test_strptime(); } struct torture_context; -- cgit From 6262602b4ff1aff61103069b03b707fb66334555 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 15 Apr 2007 16:30:01 +0000 Subject: r22217: merge from samba3 21944: move acl header checks to the correct place only metze (This used to be commit be84eb68e1f0d3826b9f819fa44d8b399e38cbcd) --- source4/lib/replace/system/config.m4 | 3 ++- source4/lib/replace/system/filesys.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 index 4d66317a5e..74278787e7 100644 --- a/source4/lib/replace/system/config.m4 +++ b/source4/lib/replace/system/config.m4 @@ -1,6 +1,7 @@ # filesys AC_HEADER_DIRENT -AC_CHECK_HEADERS(fcntl.h sys/fcntl.h sys/acl.h sys/resource.h sys/ioctl.h sys/mode.h sys/filio.h sys/fs/s5param.h sys/filsys.h ) +AC_CHECK_HEADERS(fcntl.h sys/fcntl.h sys/resource.h sys/ioctl.h sys/mode.h sys/filio.h sys/fs/s5param.h sys/filsys.h) +AC_CHECK_HEADERS(sys/acl.h acl/libacl.h) # select AC_CHECK_HEADERS(sys/select.h) diff --git a/source4/lib/replace/system/filesys.h b/source4/lib/replace/system/filesys.h index 1e48f7ab40..3b68abe48a 100644 --- a/source4/lib/replace/system/filesys.h +++ b/source4/lib/replace/system/filesys.h @@ -41,6 +41,10 @@ #include #endif +#ifdef HAVE_ACL_LIBACL_H +#include +#endif + #ifdef HAVE_SYS_FS_S5PARAM_H #include #endif -- cgit From e369a15fa4380889f7d725b86335f5b298542e1d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 15 Apr 2007 19:09:34 +0000 Subject: r22218: fix libreplace standalone build metze (This used to be commit 398e008ea78777164dcf4eef059626d574c35f47) --- source4/lib/replace/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 10ba5b9415..f4c79749a6 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -37,7 +37,7 @@ test: all installcheck: install test -TEST_OBJS = test/testsuite.o test/os2_delete.o +TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o testsuite: libreplace.a $(TEST_OBJS) $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace -- cgit From 7b2b43920ba3f15c8c5db65b4be1d70bdbab2d1f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 15 Apr 2007 20:55:52 +0000 Subject: r22223: make comparing of struct tm more verbose and more portable metze (This used to be commit 2552a3300ba94b48e447e82f6b1d2ffa76d5c660) --- source4/lib/replace/test/strptime.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/strptime.c b/source4/lib/replace/test/strptime.c index 434b5d0933..fade3ecc57 100644 --- a/source4/lib/replace/test/strptime.c +++ b/source4/lib/replace/test/strptime.c @@ -8,6 +8,10 @@ #define true 1 #define false 0 +#ifndef __STRING +#define __STRING(x) #x +#endif + /* make printf a no-op */ #define printf if(0) printf @@ -24,6 +28,9 @@ int libreplace_test_strptime(void) char *ret; struct tm t, t2; + memset(&t, 0, sizeof(t)); + memset(&t2, 0, sizeof(t2)); + printf("test: strptime\n"); ret = strptime(s, "%Y%m%d%H%M%S", &t); @@ -56,13 +63,26 @@ int libreplace_test_strptime(void) return false; } - if (memcmp(&t, &t2, sizeof(t)) == 0) { - printf("failure: strptime [\n" - "result differs if the format string has a 'Z' at the end\n" - "]\n"); - return false; +#define CMP_TM_ELEMENT(t1,t2,elem) \ + if (t1.elem != t2.elem) { \ + printf("failure: strptime [\n" \ + "result differs if the format string has a 'Z' at the end\n" \ + "element: %s %d != %d\n" \ + "]\n", \ + __STRING(elen), t1.elem, t2.elem); \ + return false; \ } + CMP_TM_ELEMENT(t,t2,tm_sec); + CMP_TM_ELEMENT(t,t2,tm_min); + CMP_TM_ELEMENT(t,t2,tm_hour); + CMP_TM_ELEMENT(t,t2,tm_mday); + CMP_TM_ELEMENT(t,t2,tm_mon); + CMP_TM_ELEMENT(t,t2,tm_year); + CMP_TM_ELEMENT(t,t2,tm_wday); + CMP_TM_ELEMENT(t,t2,tm_yday); + CMP_TM_ELEMENT(t,t2,tm_isdst); + if (t.tm_sec != 46) { printf("failure: strptime [\n" "tm_sec: expected: 46, got: %d\n" -- cgit From bb36705c8d360a2ba865a3d8118c52afa1e46f4e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 15 Apr 2007 21:13:13 +0000 Subject: r22226: move discard_const macros to librelace metze (This used to be commit c2cfee6d25718fac35bd4ed982c7424f1c3ed0b7) --- source4/lib/replace/replace.h | 23 +++++++++++++++++++++++ source4/lib/replace/strptime.c | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 7d6dcec7f1..959d44b33e 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -79,6 +79,29 @@ #include #endif +/** + this is a warning hack. The idea is to use this everywhere that we + get the "discarding const" warning from gcc. That doesn't actually + fix the problem of course, but it means that when we do get to + cleaning them up we can do it by searching the code for + discard_const. + + It also means that other error types aren't as swamped by the noise + of hundreds of const warnings, so we are more likely to notice when + we get new errors. + + Please only add more uses of this macro when you find it + _really_ hard to fix const warnings. Our aim is to eventually use + this function in only a very few places. + + Also, please call this via the discard_const_p() macro interface, as that + makes the return type safe. +*/ +#define discard_const(ptr) ((void *)((intptr_t)(ptr))) + +/** Type-safe version of discard_const */ +#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) + #ifndef HAVE_STRERROR extern char *sys_errlist[]; #define strerror(i) sys_errlist[i] diff --git a/source4/lib/replace/strptime.c b/source4/lib/replace/strptime.c index 8fb919472e..d415b7826e 100644 --- a/source4/lib/replace/strptime.c +++ b/source4/lib/replace/strptime.c @@ -974,7 +974,7 @@ strptime_internal (rp, fmt, tm, decided, era_cnt) if (want_xday && !have_yday) day_of_the_year (tm); - return (char *) rp; + return discard_const_p(char, rp); } -- cgit From 69370d05c94e2fceb55e19e1d886d4f7135b40a4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 06:08:06 +0000 Subject: r22239: use strlcpy instead of strcpy to make the IBM checker happy metze (This used to be commit d51af1b3ac8c332481f978b909ee461941f8a50d) --- source4/lib/replace/test/testsuite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 7d45feec6b..165d222261 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -117,7 +117,7 @@ static int test_strlcat(void) { char tmp[10]; printf("test: strlcat\n"); - strcpy(tmp, ""); + strlcpy(tmp, "", sizeof(tmp)); if (strlcat(tmp, "bla", 3) != 3) { printf("failure: strlcat [\ninvalid return code\n]\n"); return false; @@ -128,7 +128,7 @@ static int test_strlcat(void) return false; } - strcpy(tmp, "da"); + strlcpy(tmp, "da", sizeof(tmp)); if (strlcat(tmp, "me", 4) != 4) { printf("failure: strlcat [\nexpected \"dam\", got \"%s\"\n]\n", tmp); -- cgit From abe4d9a93f75f31d04d6a71c86a5b89cfa683a22 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 06:29:45 +0000 Subject: r22243: remove useless printf's metze (This used to be commit 8267e2964eddf0afc13edec8e91f9e7ca1d72644) --- source4/lib/replace/test/testsuite.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 165d222261..4c21de7aa3 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -423,9 +423,7 @@ static int test_bzero(void) static int test_strerror(void) { - printf("test: strerror\n"); /* FIXME */ - printf("failure: sterror\n"); return true; } -- cgit From 4b2b3bb7068a6d09b3cd4628bb25e74bd2a47ef6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 07:40:32 +0000 Subject: r22246: only test strtoll once metze (This used to be commit 236def3494f20c59ad44464a5359f3387acbb708) --- source4/lib/replace/test/testsuite.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 4c21de7aa3..a394810f61 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -651,7 +651,6 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_getpass(); ret &= test_inet_ntoa(); ret &= test_strtoll(); - ret &= test_strtoll(); ret &= test_strtoull(); ret &= test_va_copy(); ret &= test_FUNCTION(); -- cgit From f0c9bc037ed78f6bf0999ef669612b4003ec51ad Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 09:19:35 +0000 Subject: r22250: try to fix the build on aix1 in the farm metze (This used to be commit 0a04ed570b125be1716628136f87f0244ad12f72) --- source4/lib/replace/libreplace.m4 | 2 ++ source4/lib/replace/replace.h | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 33cd0894c1..ab7c83f9dd 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -263,7 +263,9 @@ AC_CHECK_HEADERS([sys/param.h limits.h]) AC_CHECK_TYPE(comparison_fn_t, [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) +AC_CHECK_DECLS([setenv, unsetenv]) AC_CHECK_FUNCS(setenv unsetenv) + AC_CHECK_FUNCS(strnlen) AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 959d44b33e..3b09216257 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -160,7 +160,11 @@ size_t rep_strnlen(const char *s, size_t n); #ifndef HAVE_SETENV #define setenv rep_setenv -int rep_setenv(const char *name, const char *value, int overwrite); +int rep_setenv(const char *name, const char *value, int overwrite); +#else +#ifndef HAVE_DECL_SETENV +int setenv(const char *name, const char *value, int overwrite); +#endif #endif #ifndef HAVE_UNSETENV -- cgit From 43b16443de76bb8bc11be811ac515374337970bd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 09:43:48 +0000 Subject: r22253: - make the strtoll tests more verbose - add initial strtoull tests metze (This used to be commit 5d1e0f167add3c75955a27aa1ff3b16523ccf5c2) --- source4/lib/replace/test/testsuite.c | 63 ++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 7 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index a394810f61..025e5256f9 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -478,26 +478,75 @@ static int test_inet_ntoa(void) static int test_strtoll(void) { + int64_t v; + printf("test: strtoll\n"); - if (strtoll("15", NULL, 10) != 15) { - printf("failure: strtoll [\nstrtoll failed\n]\n"); + + v = strtoll("15", NULL, 10); + if (v != 15) { + printf("failure: strtoll [\n" + "strtoll failed: %lld != 15\n" + "]\n", + v); return false; } - if (strtoll("10", NULL, 16) != 16) { - printf("failure: strtoll [\nstrtoll hex failed\n]\n"); + + v = strtoll("10", NULL, 16); + if (v != 16) { + printf("failure: strtoll [\n" + "strtoll hex failed: %lld != 16\n" + "]\n", + v); return false; } - if (strtoll("11", NULL, 2) != 3) { - printf("failure: strtoll [\nstrtoll binary failed\n]\n"); + + v = strtoll("11", NULL, 2); + if (v != 3) { + printf("failure: strtoll [\n" + "strtoll binary failed: %lld != 3\n" + "]\n", + v); return false; } + printf("success: strtoll\n"); return true; } static int test_strtoull(void) { - /* FIXME */ + uint64_t v; + + printf("test: strtoull\n"); + + v = strtoull("15", NULL, 10); + if (v != 15) { + printf("failure: strtoull [\n" + "strtoull failed: %llu != 15\n" + "]\n", + v); + return false; + } + + v = strtoull("10", NULL, 16); + if (v != 16) { + printf("failure: strtoull [\n" + "strtoull hex failed: %llu != 16\n" + "]\n", + v); + return false; + } + + v = strtoull("11", NULL, 2); + if (v != 3) { + printf("failure: strtoull [\n" + "strtoull binary failed: %llu != 3\n" + "]\n", + v); + return false; + } + + printf("success: strtuoll\n"); return true; } -- cgit From 9a7d2f8e54e61c40738eff89b1b6b9c71ced9640 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 12:43:18 +0000 Subject: r22263: use AC_HAVE_DECL() because AC_CHECK_DECLS() defines to 1 or 0 and #ifndef doesn't work. metze (This used to be commit 99125fe76a115b237e18c6a8b73e4adffc5ffb8d) --- source4/lib/replace/libreplace.m4 | 2 +- source4/lib/replace/replace.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index ab7c83f9dd..e9b19b7cf5 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -263,7 +263,7 @@ AC_CHECK_HEADERS([sys/param.h limits.h]) AC_CHECK_TYPE(comparison_fn_t, [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])]) -AC_CHECK_DECLS([setenv, unsetenv]) +AC_HAVE_DECL(setenv, [#include ]) AC_CHECK_FUNCS(setenv unsetenv) AC_CHECK_FUNCS(strnlen) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 3b09216257..a5455be2b6 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -162,7 +162,7 @@ size_t rep_strnlen(const char *s, size_t n); #define setenv rep_setenv int rep_setenv(const char *name, const char *value, int overwrite); #else -#ifndef HAVE_DECL_SETENV +#ifndef HAVE_SETENV_DECL int setenv(const char *name, const char *value, int overwrite); #endif #endif -- cgit From 3dd41c856eb423432814dd1e4af36f7ccffe03d6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 19:22:24 +0000 Subject: r22270: provide __location__ in replace.h and see how the build-farm likes this simpler version metze (This used to be commit 2abc79680f8342c9a7a6c1f3746489dd598b7bf8) --- source4/lib/replace/README | 3 +++ source4/lib/replace/replace.h | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 8e0e659c7d..d63847556c 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -77,6 +77,9 @@ CHAR_BIT Macros: va_copy __FUNCTION__ +__FILE__ +__LINE__ +__location__ __STRING MIN MAX diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index a5455be2b6..0d462b613d 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -439,6 +439,10 @@ typedef int bool; #define __STRING(x) #x #endif +#ifndef __location__ +#define __location__ __FILE__ ":" __STRING(__LINE__) +#endif + #if MMAP_BLACKLIST #undef HAVE_MMAP #endif -- cgit From 7e13a1c96ad2ab5ee6506b631390a5d99d3347e8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 19:45:35 +0000 Subject: r22273: - provide __LINESTR__ macro - add __STRINGSTRING() macro to really create a string of __LINE__ - fix __location__ macro metze (This used to be commit 24324fbcff1a896c55e789063f9916dbd092956d) --- source4/lib/replace/README | 2 ++ source4/lib/replace/replace.h | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index d63847556c..c2de560314 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -79,8 +79,10 @@ va_copy __FUNCTION__ __FILE__ __LINE__ +__LINESTR__ __location__ __STRING +__STRINGSTRING MIN MAX QSORT_CAST diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 0d462b613d..840b448d24 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -439,8 +439,16 @@ typedef int bool; #define __STRING(x) #x #endif +#ifndef _STRINGSTRING +#define __STRINGSTRING(x) __STRING(x) +#endif + +#ifndef __LINESTR__ +#define __LINESTR__ __STRINGSTRING(__LINE__) +#endif + #ifndef __location__ -#define __location__ __FILE__ ":" __STRING(__LINE__) +#define __location__ __FILE__ ":" __LINESTR__ #endif #if MMAP_BLACKLIST -- cgit From 5b7afb8a9f331eb63842969564a4dcb72f747726 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Apr 2007 19:55:51 +0000 Subject: r22279: add a lot more detailed strtoll() and strtoull() tests metze (This used to be commit 8b6d9076040b27fb13b99209116973f5abcec667) --- source4/lib/replace/test/testsuite.c | 310 ++++++++++++++++++++++++++++------- 1 file changed, 254 insertions(+), 56 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 025e5256f9..2d068c559f 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -476,38 +476,140 @@ static int test_inet_ntoa(void) return true; } +#define TEST_STRTO_X(type,fmt,func,str,base,res,diff,rrnoo) do {\ + type _v; \ + char _s[64]; \ + char *_p = NULL;\ + char *_ep = NULL; \ + strlcpy(_s, str, sizeof(_s));\ + if (diff >= 0) { \ + _ep = &_s[diff]; \ + } \ + errno = 0; \ + _v = func(_s, &_p, base); \ + if (errno != rrnoo) { \ + printf("failure: %s [\n" \ + "\t%s\n" \ + "\t%s(\"%s\",%d,%d): " fmt " (=/!)= " fmt "\n" \ + "\terrno: %d != %d\n" \ + "]\n", \ + __STRING(func), __location__, __STRING(func), \ + str, diff, base, res, _v, rrnoo, errno); \ + return false; \ + } else if (_v != res) { \ + printf("failure: %s [\n" \ + "\t%s\n" \ + "\t%s(\"%s\",%d,%d): " fmt " != " fmt "\n" \ + "]\n", \ + __STRING(func), __location__, __STRING(func), \ + str, diff, base, res, _v); \ + return false; \ + } else if (_p != _ep) { \ + printf("failure: %s [\n" \ + "\t%s\n" \ + "\t%s(\"%s\",%d,%d): " fmt " (=/!)= " fmt "\n" \ + "\tptr: %p - %p = %d != %d\n" \ + "]\n", \ + __STRING(func), __location__, __STRING(func), \ + str, diff, base, res, _v, _ep, _p, diff - (_ep - _p), diff); \ + return false; \ + } \ +} while (0) + static int test_strtoll(void) { - int64_t v; - printf("test: strtoll\n"); - v = strtoll("15", NULL, 10); - if (v != 15) { - printf("failure: strtoll [\n" - "strtoll failed: %lld != 15\n" - "]\n", - v); - return false; - } - - v = strtoll("10", NULL, 16); - if (v != 16) { - printf("failure: strtoll [\n" - "strtoll hex failed: %lld != 16\n" - "]\n", - v); - return false; - } - - v = strtoll("11", NULL, 2); - if (v != 3) { - printf("failure: strtoll [\n" - "strtoll binary failed: %lld != 3\n" - "]\n", - v); - return false; - } +#define TEST_STRTOLL(str,base,res,diff,errnoo) TEST_STRTO_X(int64_t, "%lld", strtoll,str,base,res,diff,errnoo) + + TEST_STRTOLL("15", 10, 15LL, 2, 0); + TEST_STRTOLL(" 15", 10, 15LL, 4, 0); + TEST_STRTOLL("15", 0, 15LL, 2, 0); + TEST_STRTOLL(" 15 ", 0, 15LL, 3, 0); + TEST_STRTOLL("+15", 10, 15LL, 3, 0); + TEST_STRTOLL(" +15", 10, 15LL, 5, 0); + TEST_STRTOLL("+15", 0, 15LL, 3, 0); + TEST_STRTOLL(" +15 ", 0, 15LL, 4, 0); + TEST_STRTOLL("-15", 10, -15LL, 3, 0); + TEST_STRTOLL(" -15", 10, -15LL, 5, 0); + TEST_STRTOLL("-15", 0, -15LL, 3, 0); + TEST_STRTOLL(" -15 ", 0, -15LL, 4, 0); + TEST_STRTOLL("015", 10, 15LL, 3, 0); + TEST_STRTOLL(" 015", 10, 15LL, 5, 0); + TEST_STRTOLL("015", 0, 13LL, 3, 0); + TEST_STRTOLL(" 015", 0, 13LL, 5, 0); + TEST_STRTOLL("0x15", 10, 0LL, 1, 0); + TEST_STRTOLL(" 0x15", 10, 0LL, 3, 0); + TEST_STRTOLL("0x15", 0, 21LL, 4, 0); + TEST_STRTOLL(" 0x15", 0, 21LL, 6, 0); + + TEST_STRTOLL("10", 16, 16LL, 2, 0); + TEST_STRTOLL(" 10 ", 16, 16LL, 4, 0); + TEST_STRTOLL("0x10", 16, 16LL, 4, 0); + TEST_STRTOLL("0x10", 0, 16LL, 4, 0); + TEST_STRTOLL(" 0x10 ", 0, 16LL, 5, 0); + TEST_STRTOLL("+10", 16, 16LL, 3, 0); + TEST_STRTOLL(" +10 ", 16, 16LL, 5, 0); + TEST_STRTOLL("+0x10", 16, 16LL, 5, 0); + TEST_STRTOLL("+0x10", 0, 16LL, 5, 0); + TEST_STRTOLL(" +0x10 ", 0, 16LL, 6, 0); + TEST_STRTOLL("-10", 16, -16LL, 3, 0); + TEST_STRTOLL(" -10 ", 16, -16LL, 5, 0); + TEST_STRTOLL("-0x10", 16, -16LL, 5, 0); + TEST_STRTOLL("-0x10", 0, -16LL, 5, 0); + TEST_STRTOLL(" -0x10 ", 0, -16LL, 6, 0); + TEST_STRTOLL("010", 16, 16LL, 3, 0); + TEST_STRTOLL(" 010 ", 16, 16LL, 5, 0); + TEST_STRTOLL("-010", 16, -16LL, 4, 0); + + TEST_STRTOLL("11", 8, 9LL, 2, 0); + TEST_STRTOLL("011", 8, 9LL, 3, 0); + TEST_STRTOLL("011", 0, 9LL, 3, 0); + TEST_STRTOLL("-11", 8, -9LL, 3, 0); + TEST_STRTOLL("-011", 8, -9LL, 4, 0); + TEST_STRTOLL("-011", 0, -9LL, 4, 0); + + TEST_STRTOLL("011", 8, 9LL, 3, 0); + TEST_STRTOLL("011", 0, 9LL, 3, 0); + TEST_STRTOLL("-11", 8, -9LL, 3, 0); + TEST_STRTOLL("-011", 8, -9LL, 4, 0); + TEST_STRTOLL("-011", 0, -9LL, 4, 0); + + TEST_STRTOLL("Text", 0, 0LL, 0, 0); + + TEST_STRTOLL("9223372036854775807", 10, 9223372036854775807LL, 19, 0); + TEST_STRTOLL("9223372036854775807", 0, 9223372036854775807LL, 19, 0); + TEST_STRTOLL("9223372036854775808", 0, 9223372036854775807LL, 19, ERANGE); + TEST_STRTOLL("9223372036854775808", 10, 9223372036854775807LL, 19, ERANGE); + TEST_STRTOLL("0x7FFFFFFFFFFFFFFF", 0, 9223372036854775807LL, 18, 0); + TEST_STRTOLL("0x7FFFFFFFFFFFFFFF", 16, 9223372036854775807LL, 18, 0); + TEST_STRTOLL("7FFFFFFFFFFFFFFF", 16, 9223372036854775807LL, 16, 0); + TEST_STRTOLL("0x8000000000000000", 0, 9223372036854775807LL, 18, ERANGE); + TEST_STRTOLL("0x8000000000000000", 16, 9223372036854775807LL, 18, ERANGE); + TEST_STRTOLL("80000000000000000", 16, 9223372036854775807LL, 17, ERANGE); + TEST_STRTOLL("0777777777777777777777", 0, 9223372036854775807LL, 22, 0); + TEST_STRTOLL("0777777777777777777777", 8, 9223372036854775807LL, 22, 0); + TEST_STRTOLL("777777777777777777777", 8, 9223372036854775807LL, 21, 0); + TEST_STRTOLL("01000000000000000000000", 0, 9223372036854775807LL, 23, ERANGE); + TEST_STRTOLL("01000000000000000000000", 8, 9223372036854775807LL, 23, ERANGE); + TEST_STRTOLL("1000000000000000000000", 8, 9223372036854775807LL, 22, ERANGE); + + TEST_STRTOLL("-9223372036854775808", 10, -9223372036854775807LL -1, 20, 0); + TEST_STRTOLL("-9223372036854775808", 0, -9223372036854775807LL -1, 20, 0); + TEST_STRTOLL("-9223372036854775809", 0, -9223372036854775807LL -1, 20, ERANGE); + TEST_STRTOLL("-9223372036854775809", 10, -9223372036854775807LL -1, 20, ERANGE); + TEST_STRTOLL("-0x8000000000000000", 0, -9223372036854775807LL -1, 19, 0); + TEST_STRTOLL("-0x8000000000000000", 16, -9223372036854775807LL -1, 19, 0); + TEST_STRTOLL("-8000000000000000", 16, -9223372036854775807LL -1, 17, 0); + TEST_STRTOLL("-0x8000000000000001", 0, -9223372036854775807LL -1, 19, ERANGE); + TEST_STRTOLL("-0x8000000000000001", 16, -9223372036854775807LL -1, 19, ERANGE); + TEST_STRTOLL("-80000000000000001", 16, -9223372036854775807LL -1, 18, ERANGE); + TEST_STRTOLL("-01000000000000000000000",0, -9223372036854775807LL -1, 24, 0); + TEST_STRTOLL("-01000000000000000000000",8, -9223372036854775807LL -1, 24, 0); + TEST_STRTOLL("-1000000000000000000000", 8, -9223372036854775807LL -1, 23, 0); + TEST_STRTOLL("-01000000000000000000001",0, -9223372036854775807LL -1, 24, ERANGE); + TEST_STRTOLL("-01000000000000000000001",8, -9223372036854775807LL -1, 24, ERANGE); + TEST_STRTOLL("-1000000000000000000001", 8, -9223372036854775807LL -1, 23, ERANGE); printf("success: strtoll\n"); return true; @@ -515,36 +617,132 @@ static int test_strtoll(void) static int test_strtoull(void) { - uint64_t v; - printf("test: strtoull\n"); - v = strtoull("15", NULL, 10); - if (v != 15) { - printf("failure: strtoull [\n" - "strtoull failed: %llu != 15\n" - "]\n", - v); - return false; - } - - v = strtoull("10", NULL, 16); - if (v != 16) { - printf("failure: strtoull [\n" - "strtoull hex failed: %llu != 16\n" - "]\n", - v); - return false; - } - - v = strtoull("11", NULL, 2); - if (v != 3) { - printf("failure: strtoull [\n" - "strtoull binary failed: %llu != 3\n" - "]\n", - v); - return false; - } +#define TEST_STRTOULL(str,base,res,diff,errnoo) TEST_STRTO_X(uint64_t,"%llu",strtoull,str,base,res,diff,errnoo) + + TEST_STRTOULL("15", 10, 15LLU, 2, 0); + TEST_STRTOULL(" 15", 10, 15LLU, 4, 0); + TEST_STRTOULL("15", 0, 15LLU, 2, 0); + TEST_STRTOULL(" 15 ", 0, 15LLU, 3, 0); + TEST_STRTOULL("+15", 10, 15LLU, 3, 0); + TEST_STRTOULL(" +15", 10, 15LLU, 5, 0); + TEST_STRTOULL("+15", 0, 15LLU, 3, 0); + TEST_STRTOULL(" +15 ", 0, 15LLU, 4, 0); + TEST_STRTOULL("-15", 10, 18446744073709551601LLU, 3, 0); + TEST_STRTOULL(" -15", 10, 18446744073709551601LLU, 5, 0); + TEST_STRTOULL("-15", 0, 18446744073709551601LLU, 3, 0); + TEST_STRTOULL(" -15 ", 0, 18446744073709551601LLU, 4, 0); + TEST_STRTOULL("015", 10, 15LLU, 3, 0); + TEST_STRTOULL(" 015", 10, 15LLU, 5, 0); + TEST_STRTOULL("015", 0, 13LLU, 3, 0); + TEST_STRTOULL(" 015", 0, 13LLU, 5, 0); + TEST_STRTOULL("0x15", 10, 0LLU, 1, 0); + TEST_STRTOULL(" 0x15", 10, 0LLU, 3, 0); + TEST_STRTOULL("0x15", 0, 21LLU, 4, 0); + TEST_STRTOULL(" 0x15", 0, 21LLU, 6, 0); + + TEST_STRTOULL("10", 16, 16LLU, 2, 0); + TEST_STRTOULL(" 10 ", 16, 16LLU, 4, 0); + TEST_STRTOULL("0x10", 16, 16LLU, 4, 0); + TEST_STRTOULL("0x10", 0, 16LLU, 4, 0); + TEST_STRTOULL(" 0x10 ", 0, 16LLU, 5, 0); + TEST_STRTOULL("+10", 16, 16LLU, 3, 0); + TEST_STRTOULL(" +10 ", 16, 16LLU, 5, 0); + TEST_STRTOULL("+0x10", 16, 16LLU, 5, 0); + TEST_STRTOULL("+0x10", 0, 16LLU, 5, 0); + TEST_STRTOULL(" +0x10 ", 0, 16LLU, 6, 0); + TEST_STRTOULL("-10", 16, -16LLU, 3, 0); + TEST_STRTOULL(" -10 ", 16, -16LLU, 5, 0); + TEST_STRTOULL("-0x10", 16, -16LLU, 5, 0); + TEST_STRTOULL("-0x10", 0, -16LLU, 5, 0); + TEST_STRTOULL(" -0x10 ", 0, -16LLU, 6, 0); + TEST_STRTOULL("010", 16, 16LLU, 3, 0); + TEST_STRTOULL(" 010 ", 16, 16LLU, 5, 0); + TEST_STRTOULL("-010", 16, -16LLU, 4, 0); + + TEST_STRTOULL("11", 8, 9LLU, 2, 0); + TEST_STRTOULL("011", 8, 9LLU, 3, 0); + TEST_STRTOULL("011", 0, 9LLU, 3, 0); + TEST_STRTOULL("-11", 8, -9LLU, 3, 0); + TEST_STRTOULL("-011", 8, -9LLU, 4, 0); + TEST_STRTOULL("-011", 0, -9LLU, 4, 0); + + TEST_STRTOULL("011", 8, 9LLU, 3, 0); + TEST_STRTOULL("011", 0, 9LLU, 3, 0); + TEST_STRTOULL("-11", 8, -9LLU, 3, 0); + TEST_STRTOULL("-011", 8, -9LLU, 4, 0); + TEST_STRTOULL("-011", 0, -9LLU, 4, 0); + + TEST_STRTOULL("Text", 0, 0LLU, 0, 0); + + TEST_STRTOULL("9223372036854775807", 10, 9223372036854775807LLU, 19, 0); + TEST_STRTOULL("9223372036854775807", 0, 9223372036854775807LLU, 19, 0); + TEST_STRTOULL("9223372036854775808", 0, 9223372036854775808LLU, 19, 0); + TEST_STRTOULL("9223372036854775808", 10, 9223372036854775808LLU, 19, 0); + TEST_STRTOULL("0x7FFFFFFFFFFFFFFF", 0, 9223372036854775807LLU, 18, 0); + TEST_STRTOULL("0x7FFFFFFFFFFFFFFF", 16, 9223372036854775807LLU, 18, 0); + TEST_STRTOULL("7FFFFFFFFFFFFFFF", 16, 9223372036854775807LLU, 16, 0); + TEST_STRTOULL("0x8000000000000000", 0, 9223372036854775808LLU, 18, 0); + TEST_STRTOULL("0x8000000000000000", 16, 9223372036854775808LLU, 18, 0); + TEST_STRTOULL("8000000000000000", 16, 9223372036854775808LLU, 16, 0); + TEST_STRTOULL("0777777777777777777777", 0, 9223372036854775807LLU, 22, 0); + TEST_STRTOULL("0777777777777777777777", 8, 9223372036854775807LLU, 22, 0); + TEST_STRTOULL("777777777777777777777", 8, 9223372036854775807LLU, 21, 0); + TEST_STRTOULL("01000000000000000000000",0, 9223372036854775808LLU, 23, 0); + TEST_STRTOULL("01000000000000000000000",8, 9223372036854775808LLU, 23, 0); + TEST_STRTOULL("1000000000000000000000", 8, 9223372036854775808LLU, 22, 0); + + TEST_STRTOULL("-9223372036854775808", 10, 9223372036854775808LLU, 20, 0); + TEST_STRTOULL("-9223372036854775808", 0, 9223372036854775808LLU, 20, 0); + TEST_STRTOULL("-9223372036854775809", 0, 9223372036854775807LLU, 20, 0); + TEST_STRTOULL("-9223372036854775809", 10, 9223372036854775807LLU, 20, 0); + TEST_STRTOULL("-0x8000000000000000", 0, 9223372036854775808LLU, 19, 0); + TEST_STRTOULL("-0x8000000000000000", 16, 9223372036854775808LLU, 19, 0); + TEST_STRTOULL("-8000000000000000", 16, 9223372036854775808LLU, 17, 0); + TEST_STRTOULL("-0x8000000000000001", 0, 9223372036854775807LLU, 19, 0); + TEST_STRTOULL("-0x8000000000000001", 16, 9223372036854775807LLU, 19, 0); + TEST_STRTOULL("-8000000000000001", 16, 9223372036854775807LLU, 17, 0); + TEST_STRTOULL("-01000000000000000000000",0, 9223372036854775808LLU, 24, 0); + TEST_STRTOULL("-01000000000000000000000",8, 9223372036854775808LLU, 24, 0); + TEST_STRTOULL("-1000000000000000000000",8, 9223372036854775808LLU, 23, 0); + TEST_STRTOULL("-01000000000000000000001",0, 9223372036854775807LLU, 24, 0); + TEST_STRTOULL("-01000000000000000000001",8, 9223372036854775807LLU, 24, 0); + TEST_STRTOULL("-1000000000000000000001",8, 9223372036854775807LLU, 23, 0); + + TEST_STRTOULL("18446744073709551615", 0, 18446744073709551615LLU, 20, 0); + TEST_STRTOULL("18446744073709551615", 10, 18446744073709551615LLU, 20, 0); + TEST_STRTOULL("18446744073709551616", 0, 18446744073709551615LLU, 20, ERANGE); + TEST_STRTOULL("18446744073709551616", 10, 18446744073709551615LLU, 20, ERANGE); + TEST_STRTOULL("0xFFFFFFFFFFFFFFFF", 0, 18446744073709551615LLU, 18, 0); + TEST_STRTOULL("0xFFFFFFFFFFFFFFFF", 16, 18446744073709551615LLU, 18, 0); + TEST_STRTOULL("FFFFFFFFFFFFFFFF", 16, 18446744073709551615LLU, 16, 0); + TEST_STRTOULL("0x10000000000000000", 0, 18446744073709551615LLU, 19, ERANGE); + TEST_STRTOULL("0x10000000000000000", 16, 18446744073709551615LLU, 19, ERANGE); + TEST_STRTOULL("10000000000000000", 16, 18446744073709551615LLU, 17, ERANGE); + TEST_STRTOULL("01777777777777777777777",0, 18446744073709551615LLU, 23, 0); + TEST_STRTOULL("01777777777777777777777",8, 18446744073709551615LLU, 23, 0); + TEST_STRTOULL("1777777777777777777777", 8, 18446744073709551615LLU, 22, 0); + TEST_STRTOULL("02000000000000000000000",0, 18446744073709551615LLU, 23, ERANGE); + TEST_STRTOULL("02000000000000000000000",8, 18446744073709551615LLU, 23, ERANGE); + TEST_STRTOULL("2000000000000000000000", 8, 18446744073709551615LLU, 22, ERANGE); + + TEST_STRTOULL("-18446744073709551615", 0, 1LLU, 21, 0); + TEST_STRTOULL("-18446744073709551615", 10, 1LLU, 21, 0); + TEST_STRTOULL("-18446744073709551616", 0, 18446744073709551615LLU, 21, ERANGE); + TEST_STRTOULL("-18446744073709551616", 10, 18446744073709551615LLU, 21, ERANGE); + TEST_STRTOULL("-0xFFFFFFFFFFFFFFFF", 0, 1LLU, 19, 0); + TEST_STRTOULL("-0xFFFFFFFFFFFFFFFF", 16, 1LLU, 19, 0); + TEST_STRTOULL("-FFFFFFFFFFFFFFFF", 16, 1LLU, 17, 0); + TEST_STRTOULL("-0x10000000000000000", 0, 18446744073709551615LLU, 20, ERANGE); + TEST_STRTOULL("-0x10000000000000000", 16, 18446744073709551615LLU, 20, ERANGE); + TEST_STRTOULL("-10000000000000000", 16, 18446744073709551615LLU, 18, ERANGE); + TEST_STRTOULL("-01777777777777777777777",0, 1LLU, 24, 0); + TEST_STRTOULL("-01777777777777777777777",8, 1LLU, 24, 0); + TEST_STRTOULL("-1777777777777777777777",8, 1LLU, 23, 0); + TEST_STRTOULL("-02000000000000000000000",0, 18446744073709551615LLU, 24, ERANGE); + TEST_STRTOULL("-02000000000000000000000",8, 18446744073709551615LLU, 24, ERANGE); + TEST_STRTOULL("-2000000000000000000000",8, 18446744073709551615LLU, 23, ERANGE); printf("success: strtuoll\n"); return true; -- cgit From 4047b20c368f473081eeb951dff119a6c060c9f7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 17 Apr 2007 08:03:01 +0000 Subject: r22297: move ZERO_*, ARRAY_SIZE and PTR_DIFF macros into libreplace metze (This used to be commit b69c950858d837d7bd734d418129ade69106a00d) --- source4/lib/replace/README | 6 ++++++ source4/lib/replace/replace.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index c2de560314..77558b2ca9 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -86,6 +86,12 @@ __STRINGSTRING MIN MAX QSORT_CAST +ZERO_STRUCT +ZERO_STRUCTP +ZERO_STRUCTPN +ZERO_ARRAY +ARRAY_SIZE +PTR_DIFF Headers: stdint.h diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 840b448d24..b96356ac46 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -451,6 +451,35 @@ typedef int bool; #define __location__ __FILE__ ":" __LINESTR__ #endif +/** + * zero a structure + */ +#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) + +/** + * zero a structure given a pointer to the structure + */ +#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0) + +/** + * zero a structure given a pointer to the structure - no zero check + */ +#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x))) + +/* zero an array - note that sizeof(array) must work - ie. it must not be a + pointer */ +#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x)) + +/** + * work out how many elements there are in a static array + */ +#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) + +/** + * pointer difference macro + */ +#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) + #if MMAP_BLACKLIST #undef HAVE_MMAP #endif -- cgit From 34952e81fadc06ff2ae68d982963b26d41f4872c Mon Sep 17 00:00:00 2001 From: James Peach Date: Fri, 20 Apr 2007 17:55:36 +0000 Subject: r22415: Remove test directory once we are finished. Merge -r 22393:22394 from SAMBA_3_0. (This used to be commit a8fe3c34e2964c7080ec3702b53ec141d58b7e5f) --- source4/lib/replace/test/os2_delete.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index c8abfccff9..c6ef180017 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -111,5 +111,7 @@ int test_readdir_os2_delete(void) rmdir(TESTDIR) == 0 || FAILED("rmdir"); + system("rm -rf " TESTDIR); + return test_readdir_os2_delete_ret; } -- cgit From 2ea189659172ef49684bcd0a716ae2fffcd538ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 30 Apr 2007 09:38:25 +0000 Subject: r22598: Simplify includes for replace. (This used to be commit e72cec408e832e0f6ce05c38febdd56de501dbf7) --- source4/lib/replace/Makefile.in | 4 ++-- source4/lib/replace/libreplace.m4 | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index f4c79749a6..41454f6ec4 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -11,9 +11,9 @@ srcdir = @srcdir@ builddir = @builddir@ INSTALL = @INSTALL@ -.PHONY: test +.PHONY: test all showflags install installcheck clean distclean realdistclean -CFLAGS=-I. -I@libreplacedir@ @CFLAGS@ +CFLAGS=-I. @CFLAGS@ OBJS = @LIBREPLACEOBJ@ diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index e9b19b7cf5..fa00f2c1c4 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -354,6 +354,7 @@ AC_LIBREPLACE_LOCATION_CHECKS AC_LIBREPLACE_CC_CHECKS AC_LIBREPLACE_BROKEN_CHECKS AC__LIBREPLACE_ALL_CHECKS_END +CFLAGS="$CFLAGS -I$libreplacedir" ]) m4_include(libreplace_cc.m4) -- cgit From e4161f9deee8198e9128e88458e3c5603e86cd3e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 4 May 2007 06:59:02 +0000 Subject: r22658: - add AC_GNU_SOURCE macro for systems which don't have it (sles8) - fix compiler warning on some systems metze (This used to be commit 2097ac64fc5b2b7e9a8221861a788c4a5f44948a) --- source4/lib/replace/autoconf-2.60.m4 | 13 +++++++++++++ source4/lib/replace/test/testsuite.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/autoconf-2.60.m4 b/source4/lib/replace/autoconf-2.60.m4 index 5360fff5d2..acdcd38efe 100644 --- a/source4/lib/replace/autoconf-2.60.m4 +++ b/source4/lib/replace/autoconf-2.60.m4 @@ -1,3 +1,16 @@ +# AC_GNU_SOURCE +# -------------- +AC_DEFUN([AC_GNU_SOURCE], +[AH_VERBATIM([_GNU_SOURCE], +[/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif])dnl +AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl +AC_BEFORE([$0], [AC_RUN_IFELSE])dnl +AC_DEFINE([_GNU_SOURCE]) +]) + # _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST, # ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE) # -------------------------------------------------------------- diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 2d068c559f..54ffd6a66d 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -511,7 +511,7 @@ static int test_inet_ntoa(void) "\tptr: %p - %p = %d != %d\n" \ "]\n", \ __STRING(func), __location__, __STRING(func), \ - str, diff, base, res, _v, _ep, _p, diff - (_ep - _p), diff); \ + str, diff, base, res, _v, _ep, _p, (int)(diff - (_ep - _p)), diff); \ return false; \ } \ } while (0) -- cgit From c3b00b471aaa4a0da7f2743ae2170a36bb11a16f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 May 2007 15:53:59 +0000 Subject: r22827: Change license to LGPL (discussed with tridge). (This used to be commit 1193c759622edd9e6843d9b7f53d9532748ce8a0) --- source4/lib/replace/system/aio.h | 26 +++++++++++++++----------- source4/lib/replace/system/capability.h | 26 +++++++++++++++----------- source4/lib/replace/system/dir.h | 26 +++++++++++++++----------- source4/lib/replace/system/filesys.h | 27 ++++++++++++++++----------- source4/lib/replace/system/glob.h | 27 ++++++++++++++++----------- source4/lib/replace/system/iconv.h | 27 ++++++++++++++++----------- source4/lib/replace/system/kerberos.h | 27 ++++++++++++++++----------- source4/lib/replace/system/locale.h | 27 ++++++++++++++++----------- source4/lib/replace/system/network.h | 27 ++++++++++++++++----------- source4/lib/replace/system/passwd.h | 27 ++++++++++++++++----------- source4/lib/replace/system/printing.h | 27 ++++++++++++++++----------- source4/lib/replace/system/readline.h | 29 +++++++++++++++++------------ source4/lib/replace/system/select.h | 27 ++++++++++++++++----------- source4/lib/replace/system/shmem.h | 27 ++++++++++++++++----------- source4/lib/replace/system/syslog.h | 27 ++++++++++++++++----------- source4/lib/replace/system/terminal.h | 27 ++++++++++++++++----------- source4/lib/replace/system/time.h | 29 +++++++++++++++++------------ source4/lib/replace/system/wait.h | 29 +++++++++++++++++------------ 18 files changed, 288 insertions(+), 201 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/aio.h b/source4/lib/replace/system/aio.h index 45154ccb27..624575f619 100644 --- a/source4/lib/replace/system/aio.h +++ b/source4/lib/replace/system/aio.h @@ -7,19 +7,23 @@ Copyright (C) Andrew Tridgell 2006 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_LIBAIO_H diff --git a/source4/lib/replace/system/capability.h b/source4/lib/replace/system/capability.h index 6ed8ae8de0..23e5969145 100644 --- a/source4/lib/replace/system/capability.h +++ b/source4/lib/replace/system/capability.h @@ -7,19 +7,23 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_SYS_CAPABILITY_H diff --git a/source4/lib/replace/system/dir.h b/source4/lib/replace/system/dir.h index 64e413c907..01607b384f 100644 --- a/source4/lib/replace/system/dir.h +++ b/source4/lib/replace/system/dir.h @@ -7,19 +7,23 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #if HAVE_DIRENT_H diff --git a/source4/lib/replace/system/filesys.h b/source4/lib/replace/system/filesys.h index 3b68abe48a..a1a0412f37 100644 --- a/source4/lib/replace/system/filesys.h +++ b/source4/lib/replace/system/filesys.h @@ -7,19 +7,24 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include diff --git a/source4/lib/replace/system/glob.h b/source4/lib/replace/system/glob.h index 0e51f397c6..ea546ff7f7 100644 --- a/source4/lib/replace/system/glob.h +++ b/source4/lib/replace/system/glob.h @@ -7,19 +7,24 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifdef HAVE_GLOB_H diff --git a/source4/lib/replace/system/iconv.h b/source4/lib/replace/system/iconv.h index abc2d6f4e1..2b2832a796 100644 --- a/source4/lib/replace/system/iconv.h +++ b/source4/lib/replace/system/iconv.h @@ -7,19 +7,24 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #if !defined(HAVE_ICONV) && defined(HAVE_ICONV_H) diff --git a/source4/lib/replace/system/kerberos.h b/source4/lib/replace/system/kerberos.h index 1617b96aad..8a849c4fb6 100644 --- a/source4/lib/replace/system/kerberos.h +++ b/source4/lib/replace/system/kerberos.h @@ -8,19 +8,24 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifdef HAVE_KRB5 diff --git a/source4/lib/replace/system/locale.h b/source4/lib/replace/system/locale.h index 82b179dc5b..aa1e1e619e 100644 --- a/source4/lib/replace/system/locale.h +++ b/source4/lib/replace/system/locale.h @@ -8,19 +8,24 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifdef HAVE_CTYPE_H diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 5e648dcd15..64c7cd3399 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -7,19 +7,24 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifdef HAVE_SYS_SOCKET_H diff --git a/source4/lib/replace/system/passwd.h b/source4/lib/replace/system/passwd.h index 21f31f0388..d51914eb50 100644 --- a/source4/lib/replace/system/passwd.h +++ b/source4/lib/replace/system/passwd.h @@ -8,19 +8,24 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifdef HAVE_PWD_H diff --git a/source4/lib/replace/system/printing.h b/source4/lib/replace/system/printing.h index 489ccb1da8..3054811453 100644 --- a/source4/lib/replace/system/printing.h +++ b/source4/lib/replace/system/printing.h @@ -8,19 +8,24 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifdef AIX diff --git a/source4/lib/replace/system/readline.h b/source4/lib/replace/system/readline.h index 4a64ef1376..3a253058e2 100644 --- a/source4/lib/replace/system/readline.h +++ b/source4/lib/replace/system/readline.h @@ -3,21 +3,26 @@ /* Unix SMB/CIFS implementation. - readline wrappers + Readline wrappers - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifdef HAVE_LIBREADLINE diff --git a/source4/lib/replace/system/select.h b/source4/lib/replace/system/select.h index 20346259c2..97140e1d73 100644 --- a/source4/lib/replace/system/select.h +++ b/source4/lib/replace/system/select.h @@ -7,19 +7,24 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifdef HAVE_SYS_SELECT_H diff --git a/source4/lib/replace/system/shmem.h b/source4/lib/replace/system/shmem.h index 26fa7c8d43..234ec1c14a 100644 --- a/source4/lib/replace/system/shmem.h +++ b/source4/lib/replace/system/shmem.h @@ -7,19 +7,24 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #if defined(HAVE_SYS_IPC_H) diff --git a/source4/lib/replace/system/syslog.h b/source4/lib/replace/system/syslog.h index e123830a70..f949c7a8d9 100644 --- a/source4/lib/replace/system/syslog.h +++ b/source4/lib/replace/system/syslog.h @@ -7,19 +7,24 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifdef HAVE_SYSLOG_H diff --git a/source4/lib/replace/system/terminal.h b/source4/lib/replace/system/terminal.h index 94d6b5cc98..292c85ab6f 100644 --- a/source4/lib/replace/system/terminal.h +++ b/source4/lib/replace/system/terminal.h @@ -7,19 +7,24 @@ Copyright (C) Andrew Tridgell 2004 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifdef SUNOS4 diff --git a/source4/lib/replace/system/time.h b/source4/lib/replace/system/time.h index e7c88f133d..a0924f4051 100644 --- a/source4/lib/replace/system/time.h +++ b/source4/lib/replace/system/time.h @@ -6,20 +6,25 @@ time system include wrappers Copyright (C) Andrew Tridgell 2004 + + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifdef TIME_WITH_SYS_TIME diff --git a/source4/lib/replace/system/wait.h b/source4/lib/replace/system/wait.h index 179ef0774e..96b5c2cb80 100644 --- a/source4/lib/replace/system/wait.h +++ b/source4/lib/replace/system/wait.h @@ -6,20 +6,25 @@ waitpid system include wrappers Copyright (C) Andrew Tridgell 2004 + + ** NOTE! The following LGPL license applies to the replace + ** library. This does NOT imply that all of Samba is released + ** under the LGPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifdef HAVE_SYS_WAIT_H -- cgit From bc02bba4499b7f6c78dc5db0610fe4f4d238829a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 14 May 2007 00:31:04 +0000 Subject: r22829: system/select.h needs to bring in epoll.h for epoll usage in lib/events (This used to be commit 2c9d0b57f9cef96ac0878a9761f3c15774fda336) --- source4/lib/replace/system/select.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/select.h b/source4/lib/replace/system/select.h index 97140e1d73..a196f9c478 100644 --- a/source4/lib/replace/system/select.h +++ b/source4/lib/replace/system/select.h @@ -31,6 +31,10 @@ #include #endif +#ifdef HAVE_SYS_EPOLL_H +#include +#endif + #ifndef SELECT_CAST #define SELECT_CAST #endif -- cgit From 3e5335063a15dda4c21baab0961d766f30b21d84 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 16 May 2007 11:15:16 +0000 Subject: r22931: Fix logic in detection of the need to replace dlopen and friends. Originally, dlfcn.o was only added to LIBREPLACEOBJ if dlopen was found in libdl but header dlfcn.h was not appropriate. Michael (This used to be commit 7afa8d2a4707e999a380e747ccaae1de53a00251) --- source4/lib/replace/dlfcn.m4 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.m4 b/source4/lib/replace/dlfcn.m4 index 2d5b2c5141..d42409ac63 100644 --- a/source4/lib/replace/dlfcn.m4 +++ b/source4/lib/replace/dlfcn.m4 @@ -2,17 +2,18 @@ dnl dummies provided by dlfcn.c if not available save_LIBS="$LIBS" LIBS="" +libreplace_cv_dlfcn=no AC_SEARCH_LIBS(dlopen, dl) -if test "$ac_cv_search_dlopen" != no; then +if test x"${ac_cv_search_dlopen}" = x"no"; then + libreplace_cv_dlfcn=yes +else AC_CHECK_HEADERS(dlfcn.h) - - libreplace_cv_dlfcn=no AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_cv_dlfcn=yes]) +fi - if test x"${libreplace_cv_dlfcn}" = x"yes";then - LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o" - fi +if test x"${libreplace_cv_dlfcn}" = x"yes";then + LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o" fi LIBDL="$LIBS" -- cgit From 2ad24b9ba191ed9d2b77dbf3f667504e05bc9707 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 May 2007 06:53:57 +0000 Subject: r22988: fixed 2 bugs in our unsetenv() replacement code 1) you must not free the memory, as it is possible the memory did not come from malloc (try it under valgrind to test) 2) the old code didn't cope with duplicate environment variables I hope this will fix some of the build farm errors on irix, and maybe solaris (This used to be commit ec6900171d066e927f004b621fb39cc7b8dcfd90) --- source4/lib/replace/replace.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index db299130e5..87e73d001c 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -568,20 +568,24 @@ int rep_unsetenv(const char *name) { extern char **environ; size_t len = strlen(name); - size_t i; - int found = 0; + size_t i, count; - for (i=0; (environ && environ[i]); i++) { - if (found) { - environ[i-1] = environ[i]; - continue; - } + if (environ == NULL || getenv(name) == NULL) { + return 0; + } + for (i=0;environ[i];i++) /* noop */ ; + + count=i; + + for (i=0;i Date: Thu, 24 May 2007 15:51:01 +0000 Subject: r23118: Make inet_pton and inet_ntop available through lib/replace. The code for inet_pton.c and inet_ntop.c is taken from the rsync code. I will put this into 3_0 and 3_0_26 too, but let's sort the readahead issue in lib/replace of 3_0 first... Michael (This used to be commit 9781b13fd3e0c2a0aa66412c571f562c9f17dcbe) --- source4/lib/replace/README | 2 + source4/lib/replace/inet.m4 | 2 + source4/lib/replace/inet_ntop.c | 188 +++++++++++++++++++++++++++++++++ source4/lib/replace/inet_pton.c | 215 ++++++++++++++++++++++++++++++++++++++ source4/lib/replace/libreplace.m4 | 1 + source4/lib/replace/replace.h | 10 ++ 6 files changed, 418 insertions(+) create mode 100644 source4/lib/replace/inet.m4 create mode 100644 source4/lib/replace/inet_ntop.c create mode 100644 source4/lib/replace/inet_pton.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 77558b2ca9..3ce1d61e82 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -54,6 +54,8 @@ strtoll strtoull socketpair strptime +inet_pton +inet_ntop Types: bool diff --git a/source4/lib/replace/inet.m4 b/source4/lib/replace/inet.m4 new file mode 100644 index 0000000000..bbb205dc3e --- /dev/null +++ b/source4/lib/replace/inet.m4 @@ -0,0 +1,2 @@ +AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"]) +AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"]) diff --git a/source4/lib/replace/inet_ntop.c b/source4/lib/replace/inet_ntop.c new file mode 100644 index 0000000000..3f3e6f87d4 --- /dev/null +++ b/source4/lib/replace/inet_ntop.c @@ -0,0 +1,188 @@ +/* + * Copyright (C) 1996-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* Adapted for Samba lib/replace by Michael Adam */ + +#include "replace.h" +#include "system/network.h" + +#define NS_INT16SZ 2 +#define NS_IN6ADDRSZ 16 + +/* + * WARNING: Don't even consider trying to compile this on a system where + * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. + */ + +static const char *inet_ntop4(const unsigned char *src, char *dst, + size_t size); + +#ifdef AF_INET6 +static const char *inet_ntop6(const unsigned char *src, char *dst, + size_t size); +#endif + +/* char * + * isc_net_ntop(af, src, dst, size) + * convert a network format address to presentation format. + * return: + * pointer to presentation format address (`dst'), or NULL (see errno). + * author: + * Paul Vixie, 1996. + */ +const char * +rep_inet_ntop(int af, const void *src, char *dst, size_t size) +{ + switch (af) { + case AF_INET: + return (inet_ntop4(src, dst, size)); +#ifdef AF_INET6 + case AF_INET6: + return (inet_ntop6(src, dst, size)); +#endif + default: + errno = EAFNOSUPPORT; + return (NULL); + } + /* NOTREACHED */ +} + +/* const char * + * inet_ntop4(src, dst, size) + * format an IPv4 address + * return: + * `dst' (as a const) + * notes: + * (1) uses no statics + * (2) takes a unsigned char* not an in_addr as input + * author: + * Paul Vixie, 1996. + */ +static const char * +inet_ntop4(const unsigned char *src, char *dst, size_t size) +{ + static const char *fmt = "%u.%u.%u.%u"; + char tmp[sizeof "255.255.255.255"]; + size_t len; + + len = snprintf(tmp, sizeof tmp, fmt, src[0], src[1], src[2], src[3]); + if (len >= size) { + errno = ENOSPC; + return (NULL); + } + memcpy(dst, tmp, len + 1); + + return (dst); +} + +/* const char * + * isc_inet_ntop6(src, dst, size) + * convert IPv6 binary address into presentation (printable) format + * author: + * Paul Vixie, 1996. + */ +#ifdef AF_INET6 +static const char * +inet_ntop6(const unsigned char *src, char *dst, size_t size) +{ + /* + * Note that int32_t and int16_t need only be "at least" large enough + * to contain a value of the specified size. On some systems, like + * Crays, there is no such thing as an integer variable with 16 bits. + * Keep this in mind if you think this function should have been coded + * to use pointer overlays. All the world's not a VAX. + */ + char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; + struct { int base, len; } best, cur; + unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ]; + int i, inc; + + /* + * Preprocess: + * Copy the input (bytewise) array into a wordwise array. + * Find the longest run of 0x00's in src[] for :: shorthanding. + */ + memset(words, '\0', sizeof words); + for (i = 0; i < NS_IN6ADDRSZ; i++) + words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); + best.base = -1; + cur.base = -1; + for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { + if (words[i] == 0) { + if (cur.base == -1) + cur.base = i, cur.len = 1; + else + cur.len++; + } else { + if (cur.base != -1) { + if (best.base == -1 || cur.len > best.len) + best = cur; + cur.base = -1; + } + } + } + if (cur.base != -1) { + if (best.base == -1 || cur.len > best.len) + best = cur; + } + if (best.base != -1 && best.len < 2) + best.base = -1; + + /* + * Format the result. + */ + tp = tmp; + for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { + /* Are we inside the best run of 0x00's? */ + if (best.base != -1 && i >= best.base && + i < (best.base + best.len)) { + if (i == best.base) + *tp++ = ':'; + continue; + } + /* Are we following an initial run of 0x00s or any real hex? */ + if (i != 0) + *tp++ = ':'; + /* Is this address an encapsulated IPv4? */ + if (i == 6 && best.base == 0 && + (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { + if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) + return (NULL); + tp += strlen(tp); + break; + } + inc = snprintf(tp, 5, "%x", words[i]); + assert(inc < 5); + tp += inc; + } + /* Was it a trailing run of 0x00's? */ + if (best.base != -1 && (best.base + best.len) == + (NS_IN6ADDRSZ / NS_INT16SZ)) + *tp++ = ':'; + *tp++ = '\0'; + + /* + * Check for overflow, copy, and we're done. + */ + if ((size_t)(tp - tmp) > size) { + errno = ENOSPC; + return (NULL); + } + memcpy(dst, tmp, tp - tmp); + return (dst); +} +#endif /* AF_INET6 */ diff --git a/source4/lib/replace/inet_pton.c b/source4/lib/replace/inet_pton.c new file mode 100644 index 0000000000..154b2c58ce --- /dev/null +++ b/source4/lib/replace/inet_pton.c @@ -0,0 +1,215 @@ +/* + * Copyright (C) 1996-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* Adapted for Samba lib/replace by Michael Adam */ + +#include "replace.h" +#include "system/network.h" + +#define NS_INT16SZ 2 +#define NS_INADDRSZ 4 +#define NS_IN6ADDRSZ 16 + +/* + * WARNING: Don't even consider trying to compile this on a system where + * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. + */ + +static int inet_pton4(const char *src, unsigned char *dst); +#ifdef INET6 +static int inet_pton6(const char *src, unsigned char *dst); +#endif + +/* int + * inet_pton(af, src, dst) + * convert from presentation format (which usually means ASCII printable) + * to network format (which is usually some kind of binary format). + * return: + * 1 if the address was valid for the specified address family + * 0 if the address wasn't valid (`dst' is untouched in this case) + * -1 if some other error occurred (`dst' is untouched in this case, too) + * author: + * Paul Vixie, 1996. + */ +int +rep_inet_pton(int af, + const char *src, + void *dst) +{ + switch (af) { + case AF_INET: + return (inet_pton4(src, dst)); +#ifdef INET6 + case AF_INET6: + return (inet_pton6(src, dst)); +#endif + default: + errno = EAFNOSUPPORT; + return (-1); + } + /* NOTREACHED */ +} + +/* int + * inet_pton4(src, dst) + * like inet_aton() but without all the hexadecimal and shorthand. + * return: + * 1 if `src' is a valid dotted quad, else 0. + * notice: + * does not touch `dst' unless it's returning 1. + * author: + * Paul Vixie, 1996. + */ +static int +inet_pton4(src, dst) + const char *src; + unsigned char *dst; +{ + static const char digits[] = "0123456789"; + int saw_digit, octets, ch; + unsigned char tmp[NS_INADDRSZ], *tp; + + saw_digit = 0; + octets = 0; + *(tp = tmp) = 0; + while ((ch = *src++) != '\0') { + const char *pch; + + if ((pch = strchr(digits, ch)) != NULL) { + unsigned int new = *tp * 10 + (pch - digits); + + if (new > 255) + return (0); + *tp = new; + if (! saw_digit) { + if (++octets > 4) + return (0); + saw_digit = 1; + } + } else if (ch == '.' && saw_digit) { + if (octets == 4) + return (0); + *++tp = 0; + saw_digit = 0; + } else + return (0); + } + if (octets < 4) + return (0); + memcpy(dst, tmp, NS_INADDRSZ); + return (1); +} + +/* int + * inet_pton6(src, dst) + * convert presentation level address to network order binary form. + * return: + * 1 if `src' is a valid [RFC1884 2.2] address, else 0. + * notice: + * (1) does not touch `dst' unless it's returning 1. + * (2) :: in a full address is silently ignored. + * credit: + * inspired by Mark Andrews. + * author: + * Paul Vixie, 1996. + */ +#ifdef INET6 +static int +inet_pton6(src, dst) + const char *src; + unsigned char *dst; +{ + static const char xdigits_l[] = "0123456789abcdef", + xdigits_u[] = "0123456789ABCDEF"; + unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; + const char *xdigits, *curtok; + int ch, saw_xdigit; + unsigned int val; + + memset((tp = tmp), '\0', NS_IN6ADDRSZ); + endp = tp + NS_IN6ADDRSZ; + colonp = NULL; + /* Leading :: requires some special handling. */ + if (*src == ':') + if (*++src != ':') + return (0); + curtok = src; + saw_xdigit = 0; + val = 0; + while ((ch = *src++) != '\0') { + const char *pch; + + if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) + pch = strchr((xdigits = xdigits_u), ch); + if (pch != NULL) { + val <<= 4; + val |= (pch - xdigits); + if (val > 0xffff) + return (0); + saw_xdigit = 1; + continue; + } + if (ch == ':') { + curtok = src; + if (!saw_xdigit) { + if (colonp) + return (0); + colonp = tp; + continue; + } + if (tp + NS_INT16SZ > endp) + return (0); + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; + saw_xdigit = 0; + val = 0; + continue; + } + if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && + inet_pton4(curtok, tp) > 0) { + tp += NS_INADDRSZ; + saw_xdigit = 0; + break; /* '\0' was seen by inet_pton4(). */ + } + return (0); + } + if (saw_xdigit) { + if (tp + NS_INT16SZ > endp) + return (0); + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; + } + if (colonp != NULL) { + /* + * Since some memmove()'s erroneously fail to handle + * overlapping regions, we'll do the shift by hand. + */ + const int n = tp - colonp; + int i; + + for (i = 1; i <= n; i++) { + endp[- i] = colonp[n - i]; + colonp[n - i] = 0; + } + tp = endp; + } + if (tp != endp) + return (0); + memcpy(dst, tmp, NS_IN6ADDRSZ); + return (1); +} +#endif diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index fa00f2c1c4..2b91002fdb 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -333,6 +333,7 @@ m4_include(strptime.m4) m4_include(win32.m4) m4_include(timegm.m4) m4_include(repdir.m4) +m4_include(inet.m4) AC_CHECK_FUNCS([syslog memset memcpy],,[AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 3cb3c95b69..3a8ce1a6f1 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -338,6 +338,16 @@ int rep_mkstemp(char *temp); char *rep_mkdtemp(char *template); #endif +#ifdef HAVE_INET_PTON +#define inet_pton rep_inet_pton +int rep_inet_pton(int af, const char *src, void *dst); +#endif + +#ifdef HAVE_INET_NTOP +#define inet_ntop rep_inet_ntop +const char *rep_inet_ntop(int af, const void *src, char *dst, size_t size); +#endif + #ifdef HAVE_LIMITS_H #include #endif -- cgit From 4fa973e4a48f6f4de4c8937d6c2472564b760c76 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 24 May 2007 21:29:15 +0000 Subject: r23123: Fix two utterly simply typos that broke the whole build farm... Michael (This used to be commit 54193c4638a27983f18478a61beedde889ecc2e2) --- source4/lib/replace/replace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 3a8ce1a6f1..5918f98bc4 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -338,12 +338,12 @@ int rep_mkstemp(char *temp); char *rep_mkdtemp(char *template); #endif -#ifdef HAVE_INET_PTON +#ifndef HAVE_INET_PTON #define inet_pton rep_inet_pton int rep_inet_pton(int af, const char *src, void *dst); #endif -#ifdef HAVE_INET_NTOP +#ifndef HAVE_INET_NTOP #define inet_ntop rep_inet_ntop const char *rep_inet_ntop(int af, const void *src, char *dst, size_t size); #endif -- cgit From dc919c25343211b25ed8c55577bc5451791cbde4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 28 May 2007 21:04:59 +0000 Subject: r23175: Handle PKG_CONFIG_PATH not set yet - fixes warning in selftest.pl (This used to be commit 222acbe33b427a6ccae3b9e27b545f22e4564d5c) --- source4/lib/replace/replace.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 5918f98bc4..a43f436083 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -258,6 +258,14 @@ int rep_socketpair(int d, int type, int protocol, int sv[2]); #endif #endif +#ifndef _DEPRECATED_ +#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) +#define _DEPRECATED_ __attribute__ ((deprecated)) +#else +#define _DEPRECATED_ +#endif +#endif + #ifndef HAVE_VASPRINTF #define vasprintf rep_vasprintf int rep_vasprintf(char **ptr, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0); -- cgit From fbe7d8cbc5df572024098bfae2ad2666cd4bcc47 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 29 May 2007 11:13:07 +0000 Subject: r23188: revert 23123 and 23118. as a long term solution this was the correct approach, but it's a bit more complex and we need to provide the whole socket api and libnsl.so checking in libreplace... as a short term solution to fix the build on host 'hape' we'll use the same trick as with inet_aton.c from heimdal's lib/roken/ metze (This used to be commit 0e88e2e46199d8ea64dd42c4c8b86d64ce5c2d04) --- source4/lib/replace/README | 2 - source4/lib/replace/inet.m4 | 2 - source4/lib/replace/inet_ntop.c | 188 --------------------------------- source4/lib/replace/inet_pton.c | 215 -------------------------------------- source4/lib/replace/libreplace.m4 | 1 - source4/lib/replace/replace.h | 10 -- 6 files changed, 418 deletions(-) delete mode 100644 source4/lib/replace/inet.m4 delete mode 100644 source4/lib/replace/inet_ntop.c delete mode 100644 source4/lib/replace/inet_pton.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 3ce1d61e82..77558b2ca9 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -54,8 +54,6 @@ strtoll strtoull socketpair strptime -inet_pton -inet_ntop Types: bool diff --git a/source4/lib/replace/inet.m4 b/source4/lib/replace/inet.m4 deleted file mode 100644 index bbb205dc3e..0000000000 --- a/source4/lib/replace/inet.m4 +++ /dev/null @@ -1,2 +0,0 @@ -AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"]) -AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"]) diff --git a/source4/lib/replace/inet_ntop.c b/source4/lib/replace/inet_ntop.c deleted file mode 100644 index 3f3e6f87d4..0000000000 --- a/source4/lib/replace/inet_ntop.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 1996-2001 Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM - * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL - * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING - * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* Adapted for Samba lib/replace by Michael Adam */ - -#include "replace.h" -#include "system/network.h" - -#define NS_INT16SZ 2 -#define NS_IN6ADDRSZ 16 - -/* - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static const char *inet_ntop4(const unsigned char *src, char *dst, - size_t size); - -#ifdef AF_INET6 -static const char *inet_ntop6(const unsigned char *src, char *dst, - size_t size); -#endif - -/* char * - * isc_net_ntop(af, src, dst, size) - * convert a network format address to presentation format. - * return: - * pointer to presentation format address (`dst'), or NULL (see errno). - * author: - * Paul Vixie, 1996. - */ -const char * -rep_inet_ntop(int af, const void *src, char *dst, size_t size) -{ - switch (af) { - case AF_INET: - return (inet_ntop4(src, dst, size)); -#ifdef AF_INET6 - case AF_INET6: - return (inet_ntop6(src, dst, size)); -#endif - default: - errno = EAFNOSUPPORT; - return (NULL); - } - /* NOTREACHED */ -} - -/* const char * - * inet_ntop4(src, dst, size) - * format an IPv4 address - * return: - * `dst' (as a const) - * notes: - * (1) uses no statics - * (2) takes a unsigned char* not an in_addr as input - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop4(const unsigned char *src, char *dst, size_t size) -{ - static const char *fmt = "%u.%u.%u.%u"; - char tmp[sizeof "255.255.255.255"]; - size_t len; - - len = snprintf(tmp, sizeof tmp, fmt, src[0], src[1], src[2], src[3]); - if (len >= size) { - errno = ENOSPC; - return (NULL); - } - memcpy(dst, tmp, len + 1); - - return (dst); -} - -/* const char * - * isc_inet_ntop6(src, dst, size) - * convert IPv6 binary address into presentation (printable) format - * author: - * Paul Vixie, 1996. - */ -#ifdef AF_INET6 -static const char * -inet_ntop6(const unsigned char *src, char *dst, size_t size) -{ - /* - * Note that int32_t and int16_t need only be "at least" large enough - * to contain a value of the specified size. On some systems, like - * Crays, there is no such thing as an integer variable with 16 bits. - * Keep this in mind if you think this function should have been coded - * to use pointer overlays. All the world's not a VAX. - */ - char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; - struct { int base, len; } best, cur; - unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ]; - int i, inc; - - /* - * Preprocess: - * Copy the input (bytewise) array into a wordwise array. - * Find the longest run of 0x00's in src[] for :: shorthanding. - */ - memset(words, '\0', sizeof words); - for (i = 0; i < NS_IN6ADDRSZ; i++) - words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); - best.base = -1; - cur.base = -1; - for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { - if (words[i] == 0) { - if (cur.base == -1) - cur.base = i, cur.len = 1; - else - cur.len++; - } else { - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - cur.base = -1; - } - } - } - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - } - if (best.base != -1 && best.len < 2) - best.base = -1; - - /* - * Format the result. - */ - tp = tmp; - for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { - /* Are we inside the best run of 0x00's? */ - if (best.base != -1 && i >= best.base && - i < (best.base + best.len)) { - if (i == best.base) - *tp++ = ':'; - continue; - } - /* Are we following an initial run of 0x00s or any real hex? */ - if (i != 0) - *tp++ = ':'; - /* Is this address an encapsulated IPv4? */ - if (i == 6 && best.base == 0 && - (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { - if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) - return (NULL); - tp += strlen(tp); - break; - } - inc = snprintf(tp, 5, "%x", words[i]); - assert(inc < 5); - tp += inc; - } - /* Was it a trailing run of 0x00's? */ - if (best.base != -1 && (best.base + best.len) == - (NS_IN6ADDRSZ / NS_INT16SZ)) - *tp++ = ':'; - *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t)(tp - tmp) > size) { - errno = ENOSPC; - return (NULL); - } - memcpy(dst, tmp, tp - tmp); - return (dst); -} -#endif /* AF_INET6 */ diff --git a/source4/lib/replace/inet_pton.c b/source4/lib/replace/inet_pton.c deleted file mode 100644 index 154b2c58ce..0000000000 --- a/source4/lib/replace/inet_pton.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (C) 1996-2001 Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM - * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL - * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING - * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* Adapted for Samba lib/replace by Michael Adam */ - -#include "replace.h" -#include "system/network.h" - -#define NS_INT16SZ 2 -#define NS_INADDRSZ 4 -#define NS_IN6ADDRSZ 16 - -/* - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static int inet_pton4(const char *src, unsigned char *dst); -#ifdef INET6 -static int inet_pton6(const char *src, unsigned char *dst); -#endif - -/* int - * inet_pton(af, src, dst) - * convert from presentation format (which usually means ASCII printable) - * to network format (which is usually some kind of binary format). - * return: - * 1 if the address was valid for the specified address family - * 0 if the address wasn't valid (`dst' is untouched in this case) - * -1 if some other error occurred (`dst' is untouched in this case, too) - * author: - * Paul Vixie, 1996. - */ -int -rep_inet_pton(int af, - const char *src, - void *dst) -{ - switch (af) { - case AF_INET: - return (inet_pton4(src, dst)); -#ifdef INET6 - case AF_INET6: - return (inet_pton6(src, dst)); -#endif - default: - errno = EAFNOSUPPORT; - return (-1); - } - /* NOTREACHED */ -} - -/* int - * inet_pton4(src, dst) - * like inet_aton() but without all the hexadecimal and shorthand. - * return: - * 1 if `src' is a valid dotted quad, else 0. - * notice: - * does not touch `dst' unless it's returning 1. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton4(src, dst) - const char *src; - unsigned char *dst; -{ - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - unsigned char tmp[NS_INADDRSZ], *tp; - - saw_digit = 0; - octets = 0; - *(tp = tmp) = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr(digits, ch)) != NULL) { - unsigned int new = *tp * 10 + (pch - digits); - - if (new > 255) - return (0); - *tp = new; - if (! saw_digit) { - if (++octets > 4) - return (0); - saw_digit = 1; - } - } else if (ch == '.' && saw_digit) { - if (octets == 4) - return (0); - *++tp = 0; - saw_digit = 0; - } else - return (0); - } - if (octets < 4) - return (0); - memcpy(dst, tmp, NS_INADDRSZ); - return (1); -} - -/* int - * inet_pton6(src, dst) - * convert presentation level address to network order binary form. - * return: - * 1 if `src' is a valid [RFC1884 2.2] address, else 0. - * notice: - * (1) does not touch `dst' unless it's returning 1. - * (2) :: in a full address is silently ignored. - * credit: - * inspired by Mark Andrews. - * author: - * Paul Vixie, 1996. - */ -#ifdef INET6 -static int -inet_pton6(src, dst) - const char *src; - unsigned char *dst; -{ - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, saw_xdigit; - unsigned int val; - - memset((tp = tmp), '\0', NS_IN6ADDRSZ); - endp = tp + NS_IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return (0); - curtok = src; - saw_xdigit = 0; - val = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (pch - xdigits); - if (val > 0xffff) - return (0); - saw_xdigit = 1; - continue; - } - if (ch == ':') { - curtok = src; - if (!saw_xdigit) { - if (colonp) - return (0); - colonp = tp; - continue; - } - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - saw_xdigit = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && - inet_pton4(curtok, tp) > 0) { - tp += NS_INADDRSZ; - saw_xdigit = 0; - break; /* '\0' was seen by inet_pton4(). */ - } - return (0); - } - if (saw_xdigit) { - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - } - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const int n = tp - colonp; - int i; - - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - return (0); - memcpy(dst, tmp, NS_IN6ADDRSZ); - return (1); -} -#endif diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 2b91002fdb..fa00f2c1c4 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -333,7 +333,6 @@ m4_include(strptime.m4) m4_include(win32.m4) m4_include(timegm.m4) m4_include(repdir.m4) -m4_include(inet.m4) AC_CHECK_FUNCS([syslog memset memcpy],,[AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index a43f436083..1259400d6f 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -346,16 +346,6 @@ int rep_mkstemp(char *temp); char *rep_mkdtemp(char *template); #endif -#ifndef HAVE_INET_PTON -#define inet_pton rep_inet_pton -int rep_inet_pton(int af, const char *src, void *dst); -#endif - -#ifndef HAVE_INET_NTOP -#define inet_ntop rep_inet_ntop -const char *rep_inet_ntop(int af, const void *src, char *dst, size_t size); -#endif - #ifdef HAVE_LIMITS_H #include #endif -- cgit From 867f7f4b7499c810adf3d5b391966321709e864d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 29 May 2007 15:18:20 +0000 Subject: r23208: on some HP-UX boxes dlfcn.h is available and use unsigned int flags for dlopen but no library contains the function... metze (This used to be commit 0c7e3ed9625d512522a0cc7278e705fbbfc316f4) --- source4/lib/replace/dlfcn.c | 4 ++++ source4/lib/replace/dlfcn.m4 | 17 +++++++++++------ source4/lib/replace/replace.h | 4 ++++ 3 files changed, 19 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c index 22f9f8bf79..55b38bb9eb 100644 --- a/source4/lib/replace/dlfcn.c +++ b/source4/lib/replace/dlfcn.c @@ -26,7 +26,11 @@ #include "replace.h" #ifndef HAVE_DLOPEN +#ifdef DLOPEN_TAKES_UNSIGNED_FLAGS +void *rep_dlopen(const char *name, unsigned int flags) +#else void *rep_dlopen(const char *name, int flags) +#endif { return NULL; } diff --git a/source4/lib/replace/dlfcn.m4 b/source4/lib/replace/dlfcn.m4 index d42409ac63..a1b57d10ec 100644 --- a/source4/lib/replace/dlfcn.m4 +++ b/source4/lib/replace/dlfcn.m4 @@ -5,12 +5,17 @@ LIBS="" libreplace_cv_dlfcn=no AC_SEARCH_LIBS(dlopen, dl) -if test x"${ac_cv_search_dlopen}" = x"no"; then - libreplace_cv_dlfcn=yes -else - AC_CHECK_HEADERS(dlfcn.h) - AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_cv_dlfcn=yes]) -fi +AC_CHECK_HEADERS(dlfcn.h) +AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_cv_dlfcn=yes]) + +AC_VERIFY_C_PROTOTYPE([void *dlopen(const char* filename, unsigned int flags)], + [ + return 0; + ],[ + AC_DEFINE(DLOPEN_TAKES_UNSIGNED_FLAGS, 1, [Whether dlopen takes unsinged int flags]) + ],[],[ + #include + ]) if test x"${libreplace_cv_dlfcn}" = x"yes";then LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o" diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 1259400d6f..f584cd42fa 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -228,8 +228,12 @@ char *rep_dlerror(void); #ifndef HAVE_DLOPEN #define dlopen rep_dlopen +#ifdef DLOPEN_TAKES_UNSIGNED_FLAGS +void *rep_dlopen(const char *name, unsigned int flags); +#else void *rep_dlopen(const char *name, int flags); #endif +#endif #ifndef HAVE_DLSYM #define dlsym rep_dlsym -- cgit From 9c6c4848c941971f186a2cbcefcd07e5a1a55544 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 30 May 2007 08:14:59 +0000 Subject: r23237: update lib/replace from ctdb (This used to be commit 361c5995bcf1dafb89f935ac4183dc295e1d524d) --- source4/lib/replace/libreplace.m4 | 2 +- source4/lib/replace/system/filesys.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index fa00f2c1c4..f06d7f83dc 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -99,7 +99,7 @@ AC_CHECK_HEADERS(stdarg.h vararg.h) AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) AC_CHECK_HEADERS(sys/sockio.h sys/un.h) - +AC_CHECK_HEADERS(sys/mount.h mntent.h) dnl we need to check that net/if.h really can be used, to cope with hpux dnl where including it always fails diff --git a/source4/lib/replace/system/filesys.h b/source4/lib/replace/system/filesys.h index a1a0412f37..b3c339a144 100644 --- a/source4/lib/replace/system/filesys.h +++ b/source4/lib/replace/system/filesys.h @@ -38,6 +38,10 @@ #include #endif +#ifdef HAVE_MNTENT_H +#include +#endif + #ifdef HAVE_SYS_VFS_H #include #endif -- cgit From 1e3a49478ed4dcd58d290f708d995ce4eba8d3ea Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 31 May 2007 12:23:52 +0000 Subject: r23265: HP-UX 11.00 also needs this, try to see if 11.23 is also happy with it... metze (This used to be commit 71eac88f7e666e6cd0dfe113d02861cdfecbee9b) --- source4/lib/replace/libreplace_cc.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 74c53cad99..3acd0eda8e 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -60,10 +60,10 @@ case "$host_os" in *hpux*) # mmap on HPUX is completely broken... AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken]) - if test "`uname -r`" = "B.11.11"; then +# if test "`uname -r`" = "B.11.11"; then AC_MSG_WARN([Enabling HPUX 11.11 header bug workaround]) CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" - fi +# fi if test "`uname -r`" = "B.11.23"; then AC_MSG_WARN([Enabling HPUX 11.23 machine/sys/getppdp.h bug workaround]) CFLAGS="$CFLAGS -D_MACHINE_SYS_GETPPDP_INCLUDED" -- cgit From f0daf9602d71ac0938fe982c77c6bcf9720305ca Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 31 May 2007 13:59:08 +0000 Subject: r23266: HP-UX 11.23 doesn't like this, but HP-UX 11.00 and 11.11 need it metze (This used to be commit 6dff6c93fc9073f29b0ae50e4b4abd695918a115) --- source4/lib/replace/libreplace_cc.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 3acd0eda8e..d4b7cfcdff 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -60,10 +60,10 @@ case "$host_os" in *hpux*) # mmap on HPUX is completely broken... AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken]) -# if test "`uname -r`" = "B.11.11"; then + if test "`uname -r`" = "B.11.00" -o "`uname -r`" = "B.11.11"; then AC_MSG_WARN([Enabling HPUX 11.11 header bug workaround]) CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" -# fi + fi if test "`uname -r`" = "B.11.23"; then AC_MSG_WARN([Enabling HPUX 11.23 machine/sys/getppdp.h bug workaround]) CFLAGS="$CFLAGS -D_MACHINE_SYS_GETPPDP_INCLUDED" -- cgit From d3807e3f5c2d663b60c3739fb9066c66494eb638 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Jun 2007 13:04:56 +0000 Subject: r23293: the fix for HP-UX 11.11 doesn't work on HP-UX 11.00 we end up with sozeof(uint64_t) == 4 :-( the _APP32_64BIT_OFF_T section in missed to redirect pread, pwrite to pread64, pwrite64 in HP-UX 11.00 so try it manually as a workarround metze (This used to be commit bb2da636be57e44d80b2bb52b3bba5c145f4bc68) --- source4/lib/replace/libreplace_cc.m4 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index d4b7cfcdff..24dab3c7f8 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -60,7 +60,11 @@ case "$host_os" in *hpux*) # mmap on HPUX is completely broken... AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken]) - if test "`uname -r`" = "B.11.00" -o "`uname -r`" = "B.11.11"; then + if test "`uname -r`" = "B.11.00"; then + AC_MSG_WARN([Enabling HPUX 11.00 header bug workaround]) + CFLAGS="$CFLAGS -Dpread=pread64 -Dpwrite=pwrite64" + fi + if test "`uname -r`" = "B.11.11"; then AC_MSG_WARN([Enabling HPUX 11.11 header bug workaround]) CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" fi -- cgit From 547f27daa2c6281c112031925e9d94f08723d58c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Jun 2007 18:36:55 +0000 Subject: r23296: HP-UX 11.11 also gets sizeof(uint64_t) == 4 so try the same fix as for 11.00 metze (This used to be commit d89088128af89122ef7e0be22697db8dda60ef58) --- source4/lib/replace/libreplace_cc.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 24dab3c7f8..fe19995db2 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -66,7 +66,8 @@ case "$host_os" in fi if test "`uname -r`" = "B.11.11"; then AC_MSG_WARN([Enabling HPUX 11.11 header bug workaround]) - CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" + #CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" + CFLAGS="$CFLAGS -Dpread=pread64 -Dpwrite=pwrite64" fi if test "`uname -r`" = "B.11.23"; then AC_MSG_WARN([Enabling HPUX 11.23 machine/sys/getppdp.h bug workaround]) -- cgit From d596200dde861f42cb989158d17abb9b693aae99 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 2 Jun 2007 08:00:45 +0000 Subject: r23303: so HP-UX 11.11 also likes the 11.00 workarround for broken pread/pwrite when using large file support. metze (This used to be commit d890a2dabf309f15b0b0c87bb3888d0776bd094b) --- source4/lib/replace/libreplace_cc.m4 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index fe19995db2..a01bf1b290 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -60,13 +60,8 @@ case "$host_os" in *hpux*) # mmap on HPUX is completely broken... AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken]) - if test "`uname -r`" = "B.11.00"; then - AC_MSG_WARN([Enabling HPUX 11.00 header bug workaround]) - CFLAGS="$CFLAGS -Dpread=pread64 -Dpwrite=pwrite64" - fi - if test "`uname -r`" = "B.11.11"; then - AC_MSG_WARN([Enabling HPUX 11.11 header bug workaround]) - #CFLAGS="$CFLAGS -D_LARGEFILE64_SUPPORT -D__LP64__ -DO_LARGEFILE=04000" + if test "`uname -r`" = "B.11.00" -o "`uname -r`" = "B.11.11"; then + AC_MSG_WARN([Enabling HPUX 11.00/11.11 header bug workaround]) CFLAGS="$CFLAGS -Dpread=pread64 -Dpwrite=pwrite64" fi if test "`uname -r`" = "B.11.23"; then -- cgit From e0f3a383b4aa15980e1b91a9355fd9e802be0c97 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 2 Jun 2007 08:16:42 +0000 Subject: r23306: pass down LDFLAGS to the link command in the libreplace standalone build metze (This used to be commit 06caaf0d8d86bb05ceaac6624735283b585d995d) --- source4/lib/replace/Makefile.in | 5 +++-- source4/lib/replace/configure.ac | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 41454f6ec4..30f39ac6cb 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -14,6 +14,7 @@ INSTALL = @INSTALL@ .PHONY: test all showflags install installcheck clean distclean realdistclean CFLAGS=-I. @CFLAGS@ +LDFLAGS=@LDFLAGS@ OBJS = @LIBREPLACEOBJ@ @@ -23,7 +24,7 @@ showflags: @echo 'libreplace will be compiled with flags:' @echo ' CC = $(CC)' @echo ' CFLAGS = $(CFLAGS)' - @echo ' LIBS = $(LIBS)' + @echo ' LDFLAGS= $(LDFLAGS)' install: all mkdir -p $(libdir) @@ -40,7 +41,7 @@ installcheck: install test TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o testsuite: libreplace.a $(TEST_OBJS) - $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace + $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) .c.o: @echo Compiling $*.c diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index 48fb7ce259..beeb77e152 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -19,4 +19,6 @@ if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wno-format-y2k" fi +AC_SUBST(LDFLAGS) + AC_OUTPUT(Makefile) -- cgit From 14846bf4f6f185f550570e6a524c265d585454ef Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 6 Jun 2007 09:27:43 +0000 Subject: r23363: Activate rep_pread and rep_pwrite in lib/replace/replace.h. This fixes the build on a SuSE 6.1. :-) I guess this had been merely forgotten. But beware: The implementations of rep_pread and rep_pwrite are not thread safe. Michael (This used to be commit e4955c729fdf0bd299df4dadc4b33e09fe4d336e) --- source4/lib/replace/replace.c | 8 ++++++++ source4/lib/replace/replace.h | 10 ++++++++++ 2 files changed, 18 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 87e73d001c..b86da53caf 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -438,6 +438,10 @@ char *rep_mkdtemp(char *template) } #endif +/***************************************************************** + Watch out: this is not thread safe. +*****************************************************************/ + #ifndef HAVE_PREAD ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) { @@ -448,6 +452,10 @@ ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset) } #endif +/***************************************************************** + Watch out: this is not thread safe. +*****************************************************************/ + #ifndef HAVE_PWRITE ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) { diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index f584cd42fa..62d480e20e 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -350,6 +350,16 @@ int rep_mkstemp(char *temp); char *rep_mkdtemp(char *template); #endif +#ifndef HAVE_PREAD +#define pread rep_pread +ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset); +#endif + +#ifndef HAVE_PWRITE +#define pwrite rep_pwrite +ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset); +#endif + #ifdef HAVE_LIMITS_H #include #endif -- cgit From b8d69a7ea2505b706ff7c74d7c97bc89d82dfa07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:46:15 +0000 Subject: r23795: more v2->v3 conversion (This used to be commit 84b468b2f8f2dffda89593f816e8bc6a8b6d42ac) --- source4/lib/replace/config.guess | 2 +- source4/lib/replace/config.sub | 2 +- source4/lib/replace/dlfcn.c | 2 +- source4/lib/replace/repdir_getdents.c | 2 +- source4/lib/replace/repdir_getdirentries.c | 2 +- source4/lib/replace/replace.c | 2 +- source4/lib/replace/replace.h | 2 +- source4/lib/replace/system/aio.h | 2 +- source4/lib/replace/system/capability.h | 2 +- source4/lib/replace/system/dir.h | 2 +- source4/lib/replace/system/filesys.h | 2 +- source4/lib/replace/system/glob.h | 2 +- source4/lib/replace/system/iconv.h | 2 +- source4/lib/replace/system/kerberos.h | 2 +- source4/lib/replace/system/locale.h | 2 +- source4/lib/replace/system/network.h | 2 +- source4/lib/replace/system/passwd.h | 2 +- source4/lib/replace/system/printing.h | 2 +- source4/lib/replace/system/readline.h | 2 +- source4/lib/replace/system/select.h | 2 +- source4/lib/replace/system/shmem.h | 2 +- source4/lib/replace/system/syslog.h | 2 +- source4/lib/replace/system/terminal.h | 2 +- source4/lib/replace/system/time.h | 2 +- source4/lib/replace/system/wait.h | 2 +- source4/lib/replace/test/testsuite.c | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.guess b/source4/lib/replace/config.guess index ad5281e66e..30af5be004 100755 --- a/source4/lib/replace/config.guess +++ b/source4/lib/replace/config.guess @@ -7,7 +7,7 @@ timestamp='2005-08-03' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but diff --git a/source4/lib/replace/config.sub b/source4/lib/replace/config.sub index 1c366dfde9..f0fcaf6361 100755 --- a/source4/lib/replace/config.sub +++ b/source4/lib/replace/config.sub @@ -11,7 +11,7 @@ timestamp='2005-07-08' # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c index 55b38bb9eb..3e2232ce80 100644 --- a/source4/lib/replace/dlfcn.c +++ b/source4/lib/replace/dlfcn.c @@ -11,7 +11,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/repdir_getdents.c b/source4/lib/replace/repdir_getdents.c index 6b115c4c4f..4ce981a619 100644 --- a/source4/lib/replace/repdir_getdents.c +++ b/source4/lib/replace/repdir_getdents.c @@ -10,7 +10,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/repdir_getdirentries.c b/source4/lib/replace/repdir_getdirentries.c index a6026dfb5d..34dd0dd314 100644 --- a/source4/lib/replace/repdir_getdirentries.c +++ b/source4/lib/replace/repdir_getdirentries.c @@ -10,7 +10,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b86da53caf..1b4a82cb03 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -10,7 +10,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 62d480e20e..ce41fc4e26 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -13,7 +13,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/aio.h b/source4/lib/replace/system/aio.h index 624575f619..8bc4fdfd42 100644 --- a/source4/lib/replace/system/aio.h +++ b/source4/lib/replace/system/aio.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/capability.h b/source4/lib/replace/system/capability.h index 23e5969145..c2048d3946 100644 --- a/source4/lib/replace/system/capability.h +++ b/source4/lib/replace/system/capability.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/dir.h b/source4/lib/replace/system/dir.h index 01607b384f..d6829c3f19 100644 --- a/source4/lib/replace/system/dir.h +++ b/source4/lib/replace/system/dir.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/filesys.h b/source4/lib/replace/system/filesys.h index b3c339a144..aa86a9f58f 100644 --- a/source4/lib/replace/system/filesys.h +++ b/source4/lib/replace/system/filesys.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/glob.h b/source4/lib/replace/system/glob.h index ea546ff7f7..c05e9f64f7 100644 --- a/source4/lib/replace/system/glob.h +++ b/source4/lib/replace/system/glob.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/iconv.h b/source4/lib/replace/system/iconv.h index 2b2832a796..a7299799d1 100644 --- a/source4/lib/replace/system/iconv.h +++ b/source4/lib/replace/system/iconv.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/kerberos.h b/source4/lib/replace/system/kerberos.h index 8a849c4fb6..685d2e9462 100644 --- a/source4/lib/replace/system/kerberos.h +++ b/source4/lib/replace/system/kerberos.h @@ -15,7 +15,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/locale.h b/source4/lib/replace/system/locale.h index aa1e1e619e..9b47cb1ef4 100644 --- a/source4/lib/replace/system/locale.h +++ b/source4/lib/replace/system/locale.h @@ -15,7 +15,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 64c7cd3399..4594f2237d 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/passwd.h b/source4/lib/replace/system/passwd.h index d51914eb50..6820d05b97 100644 --- a/source4/lib/replace/system/passwd.h +++ b/source4/lib/replace/system/passwd.h @@ -15,7 +15,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/printing.h b/source4/lib/replace/system/printing.h index 3054811453..cccd6b0e62 100644 --- a/source4/lib/replace/system/printing.h +++ b/source4/lib/replace/system/printing.h @@ -15,7 +15,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/readline.h b/source4/lib/replace/system/readline.h index 3a253058e2..0dbdd70618 100644 --- a/source4/lib/replace/system/readline.h +++ b/source4/lib/replace/system/readline.h @@ -12,7 +12,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/select.h b/source4/lib/replace/system/select.h index a196f9c478..635b725d79 100644 --- a/source4/lib/replace/system/select.h +++ b/source4/lib/replace/system/select.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/shmem.h b/source4/lib/replace/system/shmem.h index 234ec1c14a..80b4b65f44 100644 --- a/source4/lib/replace/system/shmem.h +++ b/source4/lib/replace/system/shmem.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/syslog.h b/source4/lib/replace/system/syslog.h index f949c7a8d9..fd7214f73d 100644 --- a/source4/lib/replace/system/syslog.h +++ b/source4/lib/replace/system/syslog.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/terminal.h b/source4/lib/replace/system/terminal.h index 292c85ab6f..56f6aedeff 100644 --- a/source4/lib/replace/system/terminal.h +++ b/source4/lib/replace/system/terminal.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/time.h b/source4/lib/replace/system/time.h index a0924f4051..d3dc6da4ad 100644 --- a/source4/lib/replace/system/time.h +++ b/source4/lib/replace/system/time.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/system/wait.h b/source4/lib/replace/system/wait.h index 96b5c2cb80..8b2daa9ffc 100644 --- a/source4/lib/replace/system/wait.h +++ b/source4/lib/replace/system/wait.h @@ -14,7 +14,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 54ffd6a66d..48d597ce89 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -12,7 +12,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- cgit From 4b71c210d5aa01fc5934ea1777a1c8a7ed1e1f37 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:04:16 +0000 Subject: r23796: main COPYING file for samba4, plus some formatting varients (This used to be commit 76c6bfdeb51b5673bbabe0ca3d8bff3b74a327ee) --- source4/lib/replace/getpass.c | 2 +- source4/lib/replace/strptime.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 2ccbf7b733..2cbb30e2da 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -3,7 +3,7 @@ This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the +published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, diff --git a/source4/lib/replace/strptime.c b/source4/lib/replace/strptime.c index d415b7826e..2658a66854 100644 --- a/source4/lib/replace/strptime.c +++ b/source4/lib/replace/strptime.c @@ -5,7 +5,7 @@ The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the + published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, -- cgit From 54b6c7517e40cc7a613ba7b023a26ed4aa02635b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:17:46 +0000 Subject: r23797: started fixing old FSF addresses. Fixed pcap2nbench COPYING file (This used to be commit 9f77c40a8ee137339877bb622332a901fec46e6d) --- source4/lib/replace/strptime.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/strptime.c b/source4/lib/replace/strptime.c index 2658a66854..002ea66212 100644 --- a/source4/lib/replace/strptime.c +++ b/source4/lib/replace/strptime.c @@ -14,9 +14,8 @@ Library General Public License for more details. You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + License along with the GNU C Library; see the file COPYING.LIB. If not, + see . */ /* XXX This version of the implementation is not really complete. Some of the fields cannot add information alone. But if seeing -- cgit From 6c973f4e8ccbcb6c9275f8a54e26abb19df7e15a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:42:26 +0000 Subject: r23798: updated old Temple Place FSF addresses to new URL (This used to be commit 40c0919aaa9c1b14bbaebb95ecce53eb0380fdbb) --- source4/lib/replace/dlfcn.c | 3 +-- source4/lib/replace/repdir_getdents.c | 3 +-- source4/lib/replace/repdir_getdirentries.c | 3 +-- source4/lib/replace/replace.c | 3 +-- source4/lib/replace/replace.h | 3 +-- source4/lib/replace/system/aio.h | 3 +-- source4/lib/replace/system/capability.h | 3 +-- source4/lib/replace/system/dir.h | 3 +-- source4/lib/replace/system/filesys.h | 3 +-- source4/lib/replace/system/glob.h | 3 +-- source4/lib/replace/system/iconv.h | 3 +-- source4/lib/replace/system/kerberos.h | 3 +-- source4/lib/replace/system/locale.h | 3 +-- source4/lib/replace/system/network.h | 3 +-- source4/lib/replace/system/passwd.h | 3 +-- source4/lib/replace/system/printing.h | 3 +-- source4/lib/replace/system/readline.h | 3 +-- source4/lib/replace/system/select.h | 3 +-- source4/lib/replace/system/shmem.h | 3 +-- source4/lib/replace/system/syslog.h | 3 +-- source4/lib/replace/system/terminal.h | 3 +-- source4/lib/replace/system/time.h | 3 +-- source4/lib/replace/system/wait.h | 3 +-- source4/lib/replace/test/testsuite.c | 3 +-- 24 files changed, 24 insertions(+), 48 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c index 3e2232ce80..46aaaa4087 100644 --- a/source4/lib/replace/dlfcn.c +++ b/source4/lib/replace/dlfcn.c @@ -19,8 +19,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ #include "replace.h" diff --git a/source4/lib/replace/repdir_getdents.c b/source4/lib/replace/repdir_getdents.c index 4ce981a619..afc634a796 100644 --- a/source4/lib/replace/repdir_getdents.c +++ b/source4/lib/replace/repdir_getdents.c @@ -18,8 +18,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ /* a replacement for opendir/readdir/telldir/seekdir/closedir for BSD systems diff --git a/source4/lib/replace/repdir_getdirentries.c b/source4/lib/replace/repdir_getdirentries.c index 34dd0dd314..197e5931fc 100644 --- a/source4/lib/replace/repdir_getdirentries.c +++ b/source4/lib/replace/repdir_getdirentries.c @@ -18,8 +18,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ /* a replacement for opendir/readdir/telldir/seekdir/closedir for BSD diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 1b4a82cb03..cec158be31 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -18,8 +18,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ #include "replace.h" diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index ce41fc4e26..06173bd84b 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -21,8 +21,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ #ifndef _LIBREPLACE_REPLACE_H diff --git a/source4/lib/replace/system/aio.h b/source4/lib/replace/system/aio.h index 8bc4fdfd42..784d77fa28 100644 --- a/source4/lib/replace/system/aio.h +++ b/source4/lib/replace/system/aio.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ #ifdef HAVE_LIBAIO_H diff --git a/source4/lib/replace/system/capability.h b/source4/lib/replace/system/capability.h index c2048d3946..4fe7c8d51b 100644 --- a/source4/lib/replace/system/capability.h +++ b/source4/lib/replace/system/capability.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ #ifdef HAVE_SYS_CAPABILITY_H diff --git a/source4/lib/replace/system/dir.h b/source4/lib/replace/system/dir.h index d6829c3f19..dec2d54649 100644 --- a/source4/lib/replace/system/dir.h +++ b/source4/lib/replace/system/dir.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ #if HAVE_DIRENT_H diff --git a/source4/lib/replace/system/filesys.h b/source4/lib/replace/system/filesys.h index aa86a9f58f..4bf1f64865 100644 --- a/source4/lib/replace/system/filesys.h +++ b/source4/lib/replace/system/filesys.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/glob.h b/source4/lib/replace/system/glob.h index c05e9f64f7..3e23db6828 100644 --- a/source4/lib/replace/system/glob.h +++ b/source4/lib/replace/system/glob.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/iconv.h b/source4/lib/replace/system/iconv.h index a7299799d1..3c8a71f2f7 100644 --- a/source4/lib/replace/system/iconv.h +++ b/source4/lib/replace/system/iconv.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/kerberos.h b/source4/lib/replace/system/kerberos.h index 685d2e9462..78aa7b943f 100644 --- a/source4/lib/replace/system/kerberos.h +++ b/source4/lib/replace/system/kerberos.h @@ -23,8 +23,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/locale.h b/source4/lib/replace/system/locale.h index 9b47cb1ef4..e73a9bb274 100644 --- a/source4/lib/replace/system/locale.h +++ b/source4/lib/replace/system/locale.h @@ -23,8 +23,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 4594f2237d..13d95a8ba7 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/passwd.h b/source4/lib/replace/system/passwd.h index 6820d05b97..4e858fc89c 100644 --- a/source4/lib/replace/system/passwd.h +++ b/source4/lib/replace/system/passwd.h @@ -23,8 +23,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/printing.h b/source4/lib/replace/system/printing.h index cccd6b0e62..7eb02d004a 100644 --- a/source4/lib/replace/system/printing.h +++ b/source4/lib/replace/system/printing.h @@ -23,8 +23,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/readline.h b/source4/lib/replace/system/readline.h index 0dbdd70618..ba34dc6a61 100644 --- a/source4/lib/replace/system/readline.h +++ b/source4/lib/replace/system/readline.h @@ -20,8 +20,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/select.h b/source4/lib/replace/system/select.h index 635b725d79..da18de0cfc 100644 --- a/source4/lib/replace/system/select.h +++ b/source4/lib/replace/system/select.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/shmem.h b/source4/lib/replace/system/shmem.h index 80b4b65f44..64fe39b6cb 100644 --- a/source4/lib/replace/system/shmem.h +++ b/source4/lib/replace/system/shmem.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/syslog.h b/source4/lib/replace/system/syslog.h index fd7214f73d..104be1df84 100644 --- a/source4/lib/replace/system/syslog.h +++ b/source4/lib/replace/system/syslog.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/terminal.h b/source4/lib/replace/system/terminal.h index 56f6aedeff..9ad601ace0 100644 --- a/source4/lib/replace/system/terminal.h +++ b/source4/lib/replace/system/terminal.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/time.h b/source4/lib/replace/system/time.h index d3dc6da4ad..6bbb6b15bb 100644 --- a/source4/lib/replace/system/time.h +++ b/source4/lib/replace/system/time.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/system/wait.h b/source4/lib/replace/system/wait.h index 8b2daa9ffc..de94cf09d5 100644 --- a/source4/lib/replace/system/wait.h +++ b/source4/lib/replace/system/wait.h @@ -22,8 +22,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 48d597ce89..9b684f31bb 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -20,8 +20,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ #include "replace.h" -- cgit From e1c15c74af7366901eac9fb9a8e1e674928855ec Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:52:17 +0000 Subject: r23799: updated old Franklin Street FSF addresses to new URL (This used to be commit db92b76a0034899f5f0dc2d012ee7709ff9a6132) --- source4/lib/replace/config.guess | 4 +--- source4/lib/replace/config.sub | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/config.guess b/source4/lib/replace/config.guess index 30af5be004..354dbe175a 100755 --- a/source4/lib/replace/config.guess +++ b/source4/lib/replace/config.guess @@ -16,9 +16,7 @@ timestamp='2005-08-03' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a diff --git a/source4/lib/replace/config.sub b/source4/lib/replace/config.sub index f0fcaf6361..23cd6fd75c 100755 --- a/source4/lib/replace/config.sub +++ b/source4/lib/replace/config.sub @@ -20,9 +20,7 @@ timestamp='2005-07-08' # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a -- cgit From b8875bee5f0c5385ba02646c7a8b2380fdfabb7a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 04:04:46 +0000 Subject: r23800: LGPL is now called GNU Lesser General Public License not GNU Library General Public License (This used to be commit 01e3fe7533b5670236c026ec3c6cc1e25655fbc3) --- source4/lib/replace/getpass.c | 4 ++-- source4/lib/replace/strptime.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 2cbb30e2da..9e975ee7ef 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -2,7 +2,7 @@ This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as +modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. @@ -11,7 +11,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public +You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ diff --git a/source4/lib/replace/strptime.c b/source4/lib/replace/strptime.c index 002ea66212..0e40f7561a 100644 --- a/source4/lib/replace/strptime.c +++ b/source4/lib/replace/strptime.c @@ -4,7 +4,7 @@ Contributed by Ulrich Drepper , 1996. The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as + modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. @@ -13,7 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Library General Public + You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; see the file COPYING.LIB. If not, see . */ -- cgit From cd1217ff5ff18e53c6c9fa3d4f4fd56193fe2a17 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 05:23:25 +0000 Subject: r23801: The FSF has moved around a lot. This fixes their Mass Ave address. (This used to be commit 5c9b19271e0e3ad897499707003ce4703ffa4870) --- source4/lib/replace/configure.ac | 2 -- source4/lib/replace/getpass.c | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index beeb77e152..48fb7ce259 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -19,6 +19,4 @@ if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wno-format-y2k" fi -AC_SUBST(LDFLAGS) - AC_OUTPUT(Makefile) diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 9e975ee7ef..f6a72ad86a 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -13,8 +13,7 @@ Library General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ +not, see . */ /* Modified to use with samba by Jeremy Allison, 8th July 1995. */ -- cgit From 6dad5b6e06242f29b7da6f9ea91d911b0f20d7b9 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 26 Jul 2007 07:48:14 +0000 Subject: r24054: Fix some warnings (This used to be commit b3473db397476d05e7ffca50a5f7a9b65e0a5b4a) --- source4/lib/replace/test/testsuite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 9b684f31bb..8584bcaa66 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -519,7 +519,7 @@ static int test_strtoll(void) { printf("test: strtoll\n"); -#define TEST_STRTOLL(str,base,res,diff,errnoo) TEST_STRTO_X(int64_t, "%lld", strtoll,str,base,res,diff,errnoo) +#define TEST_STRTOLL(str,base,res,diff,errnoo) TEST_STRTO_X(long long int, "%lld", strtoll,str,base,res,diff,errnoo) TEST_STRTOLL("15", 10, 15LL, 2, 0); TEST_STRTOLL(" 15", 10, 15LL, 4, 0); @@ -618,7 +618,7 @@ static int test_strtoull(void) { printf("test: strtoull\n"); -#define TEST_STRTOULL(str,base,res,diff,errnoo) TEST_STRTO_X(uint64_t,"%llu",strtoull,str,base,res,diff,errnoo) +#define TEST_STRTOULL(str,base,res,diff,errnoo) TEST_STRTO_X(long long unsigned int,"%llu",strtoull,str,base,res,diff,errnoo) TEST_STRTOULL("15", 10, 15LLU, 2, 0); TEST_STRTOULL(" 15", 10, 15LLU, 4, 0); -- cgit From bc13766a76c88e45117c8a1fd95a08d2c96789cd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 11 Aug 2007 21:30:19 +0000 Subject: r24337: Make libreplace provide offsetof. (This used to be commit 48d1aa4fcf6a323e3e6a14825f83cd20e3fc3a26) --- source4/lib/replace/README | 1 + source4/lib/replace/replace.h | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 77558b2ca9..e7b89936c0 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -92,6 +92,7 @@ ZERO_STRUCTPN ZERO_ARRAY ARRAY_SIZE PTR_DIFF +offsetof Headers: stdint.h diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 06173bd84b..e827719951 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -52,6 +52,10 @@ #define QSORT_CAST (int (*)(const void *, const void *)) #endif +#ifndef offsetof +#define offsetof(t,f) ((unsigned int)&((t *)0)->f) +#endif + #ifdef HAVE_STDINT_H #include /* force off HAVE_INTTYPES_H so that roken doesn't try to include both, -- cgit From b159717785a170719cde784eaaa2a6353368e934 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 12 Aug 2007 12:21:34 +0000 Subject: r24350: Remove offsetof() replacement to see if there are actually any hosts that don't have it. (This used to be commit b37d86242de1ee82b0cd760d965f8ad37a83cf09) --- source4/lib/replace/README | 1 - source4/lib/replace/replace.h | 4 ---- 2 files changed, 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index e7b89936c0..77558b2ca9 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -92,7 +92,6 @@ ZERO_STRUCTPN ZERO_ARRAY ARRAY_SIZE PTR_DIFF -offsetof Headers: stdint.h diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index e827719951..06173bd84b 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -52,10 +52,6 @@ #define QSORT_CAST (int (*)(const void *, const void *)) #endif -#ifndef offsetof -#define offsetof(t,f) ((unsigned int)&((t *)0)->f) -#endif - #ifdef HAVE_STDINT_H #include /* force off HAVE_INTTYPES_H so that roken doesn't try to include both, -- cgit From f96b1778a42d8388fd1c6384cd7c90b6e4bcd437 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 26 Aug 2007 19:58:40 +0000 Subject: r24674: Make sure results are always on a new line, fix typo in test name. (This used to be commit 40c1635b39b4acff0acecc734583daa0217215ce) --- source4/lib/replace/test/testsuite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 8584bcaa66..269a2ff5d6 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -743,7 +743,7 @@ static int test_strtoull(void) TEST_STRTOULL("-02000000000000000000000",8, 18446744073709551615LLU, 24, ERANGE); TEST_STRTOULL("-2000000000000000000000",8, 18446744073709551615LLU, 23, ERANGE); - printf("success: strtuoll\n"); + printf("success: strtoull\n"); return true; } -- cgit From 6131ff85d550b4c7b2f45e0860c5d90da61cc6b6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 1 Sep 2007 20:25:24 +0000 Subject: r24868: Don't use callbacks for prompting when stdout is not a tty. (This used to be commit 9b02a39c156862f9e9258dcdb9b8b86715022fc1) --- source4/lib/replace/libreplace.m4 | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index f06d7f83dc..c42d5bcf38 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -152,6 +152,7 @@ AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp socketpair) +AC_CHECK_FUNCS(isatty) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) -- cgit From d0f3d4a2f1c674f6b07b6ec4640a2c8d033bad2a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 01:39:31 +0000 Subject: r25017: Move MAXHOSTNAMELEN definition to replace.h as it is usually part of sys/param.h. (This used to be commit 7016d500287ae587d044744f2a318c402148ebea) --- source4/lib/replace/replace.h | 8 ++++++++ source4/lib/replace/system/network.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 06173bd84b..052c7346a3 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -375,6 +375,14 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) #define HOST_NAME_MAX 64 #endif +/* + * Some older systems seem not to have MAXHOSTNAMELEN + * defined. + */ +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN HOST_NAME_MAX +#endif + #ifndef UINT16_MAX #define UINT16_MAX 65535 #endif diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 13d95a8ba7..7469040b28 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -98,14 +98,6 @@ char *rep_inet_ntoa(struct in_addr ip); #define MSG_WAITALL 0 #endif -/* - * Some older systems seem not to have MAXHOSTNAMELEN - * defined. - */ -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 254 -#endif - #ifndef INADDR_LOOPBACK #define INADDR_LOOPBACK 0x7f000001 #endif -- cgit From 669adc9f4a77ef2fcb6d81e9dd86c8b5d01e17ee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 11 Sep 2007 18:02:30 +0000 Subject: r25098: Fix typo (This used to be commit 29415b661d103a80482b932172bf68cb9e394bc9) --- source4/lib/replace/dlfcn.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.m4 b/source4/lib/replace/dlfcn.m4 index a1b57d10ec..c5b7597d7a 100644 --- a/source4/lib/replace/dlfcn.m4 +++ b/source4/lib/replace/dlfcn.m4 @@ -12,7 +12,7 @@ AC_VERIFY_C_PROTOTYPE([void *dlopen(const char* filename, unsigned int flags)], [ return 0; ],[ - AC_DEFINE(DLOPEN_TAKES_UNSIGNED_FLAGS, 1, [Whether dlopen takes unsinged int flags]) + AC_DEFINE(DLOPEN_TAKES_UNSIGNED_FLAGS, 1, [Whether dlopen takes unsigned int flags]) ],[],[ #include ]) -- cgit From d232d1851cd07b8900f2eb9d454699618713532a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Sep 2007 12:00:29 +0000 Subject: r25210: fix typo metze (This used to be commit 489758afb22368399054d1306711e14cebce94e1) --- source4/lib/replace/replace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 052c7346a3..90d65931e7 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -474,7 +474,7 @@ typedef int bool; #define __STRING(x) #x #endif -#ifndef _STRINGSTRING +#ifndef __STRINGSTRING #define __STRINGSTRING(x) __STRING(x) #endif -- cgit From d73955ca77d82f4ad9ea23dc0d743f32f0b82351 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 18 Sep 2007 23:19:04 +0000 Subject: r25219: remove unused check for precompiled headers. (This used to be commit 17c92c091d9b9eb7f6a4cf1f263533f235d6717f) --- source4/lib/replace/libreplace.m4 | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index c42d5bcf38..a6b1c4f5e6 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -307,17 +307,6 @@ if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then fi -AC_CACHE_CHECK([that the C compiler can precompile header files],samba_cv_precompiled_headers, [ - dnl Check whether the compiler can generate precompiled headers - touch conftest.h - if ${CC-cc} conftest.h 2> /dev/null && test -f conftest.h.gch; then - precompiled_headers=yes - else - precompiled_headers=no - fi]) -AC_SUBST(precompiled_headers) - - dnl Check if the C compiler understands volatile (it should, being ANSI). AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [ AC_TRY_COMPILE([#include ],[volatile int i = 0], -- cgit From 90bd9f377013cd9d83b1d37e2833e980e8d6c735 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 19 Sep 2007 14:55:10 +0000 Subject: r25231: revert hunk that was commited together with the change to gplv3 was revision 23801 metze (This used to be commit 6ea0d61ab3bbf801709ca683ce84bfa71267f8f9) --- source4/lib/replace/configure.ac | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index 48fb7ce259..beeb77e152 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -19,4 +19,6 @@ if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wno-format-y2k" fi +AC_SUBST(LDFLAGS) + AC_OUTPUT(Makefile) -- cgit From d4f0d738f1ca3c4884a831a31bdd7c6de34b0961 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 20 Sep 2007 09:11:58 +0000 Subject: r25251: move macro defines to the end of replace.h and move the include location sys/param.h before we redefine missing macros metze (This used to be commit 87559febdf887940ca85571d301269b734906401) --- source4/lib/replace/replace.h | 67 ++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 32 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 90d65931e7..af05516e8c 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -44,13 +44,6 @@ #include "win32_replace.h" #endif -#ifdef __COMPAR_FN_T -#define QSORT_CAST (__compar_fn_t) -#endif - -#ifndef QSORT_CAST -#define QSORT_CAST (int (*)(const void *, const void *)) -#endif #ifdef HAVE_STDINT_H #include @@ -78,28 +71,6 @@ #include #endif -/** - this is a warning hack. The idea is to use this everywhere that we - get the "discarding const" warning from gcc. That doesn't actually - fix the problem of course, but it means that when we do get to - cleaning them up we can do it by searching the code for - discard_const. - - It also means that other error types aren't as swamped by the noise - of hundreds of const warnings, so we are more likely to notice when - we get new errors. - - Please only add more uses of this macro when you find it - _really_ hard to fix const warnings. Our aim is to eventually use - this function in only a very few places. - - Also, please call this via the discard_const_p() macro interface, as that - makes the return type safe. -*/ -#define discard_const(ptr) ((void *)((intptr_t)(ptr))) - -/** Type-safe version of discard_const */ -#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) #ifndef HAVE_STRERROR extern char *sys_errlist[]; @@ -363,6 +334,10 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) #include #endif +#ifdef HAVE_SYS_PARAM_H +#include +#endif + /* The extra casts work around common compiler bugs. */ #define _TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) /* The outer cast is needed to work around a bug in Cray C 5.0.3.0. @@ -458,9 +433,6 @@ typedef int bool; #endif #endif -#ifdef HAVE_SYS_PARAM_H -#include -#endif #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -470,6 +442,29 @@ typedef int bool; #define MAX(a,b) ((a)>(b)?(a):(b)) #endif +/** + this is a warning hack. The idea is to use this everywhere that we + get the "discarding const" warning from gcc. That doesn't actually + fix the problem of course, but it means that when we do get to + cleaning them up we can do it by searching the code for + discard_const. + + It also means that other error types aren't as swamped by the noise + of hundreds of const warnings, so we are more likely to notice when + we get new errors. + + Please only add more uses of this macro when you find it + _really_ hard to fix const warnings. Our aim is to eventually use + this function in only a very few places. + + Also, please call this via the discard_const_p() macro interface, as that + makes the return type safe. +*/ +#define discard_const(ptr) ((void *)((intptr_t)(ptr))) + +/** Type-safe version of discard_const */ +#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) + #ifndef __STRING #define __STRING(x) #x #endif @@ -519,4 +514,12 @@ typedef int bool; #undef HAVE_MMAP #endif +#ifdef __COMPAR_FN_T +#define QSORT_CAST (__compar_fn_t) +#endif + +#ifndef QSORT_CAST +#define QSORT_CAST (int (*)(const void *, const void *)) +#endif + #endif /* _LIBREPLACE_REPLACE_H */ -- cgit From a8f264eb2f5b3310d721e79f9ca7e8c47064267e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 Oct 2007 19:30:27 +0000 Subject: r25448: Remove IMMEDIATE_STRUCTURES define, which was used for splint. Newer versions of splint support immediate structures just fine. (This used to be commit d54a47ecdc418ee07c9479f519bd1a207e6ba3eb) --- source4/lib/replace/libreplace_cc.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index a01bf1b290..bd92867d6d 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -159,8 +159,8 @@ AC_CACHE_CHECK([for immediate structures],libreplace_cv_immediate_structures,[ libreplace_cv_immediate_structures=no, libreplace_cv_immediate_structures=cross) ]) -if test x"$libreplace_cv_immediate_structures" = x"yes"; then - AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures]) +if test x"$libreplace_cv_immediate_structures" = x"no"; then + AC_MSG_ERROR([compiler does not support immediate structures]) fi AC__LIBREPLACE_ONLY_CC_CHECKS_END -- cgit From 3b07f6aeb1a060efcf8218e76b8b84fb8850f337 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 5 Oct 2007 12:05:40 +0000 Subject: r25515: Revert r25448: Immediate structures are *not* supportet by the native C compiler at least on Solaris, Tru64 and HP-UX. Michael (This used to be commit 6d07e29de2a7e535139622fa688b407da232c816) --- source4/lib/replace/libreplace_cc.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index bd92867d6d..a01bf1b290 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -159,8 +159,8 @@ AC_CACHE_CHECK([for immediate structures],libreplace_cv_immediate_structures,[ libreplace_cv_immediate_structures=no, libreplace_cv_immediate_structures=cross) ]) -if test x"$libreplace_cv_immediate_structures" = x"no"; then - AC_MSG_ERROR([compiler does not support immediate structures]) +if test x"$libreplace_cv_immediate_structures" = x"yes"; then + AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures]) fi AC__LIBREPLACE_ONLY_CC_CHECKS_END -- cgit From e511090a4339221dfd1fa597964af7455f96ec28 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Oct 2007 23:54:12 +0000 Subject: r25543: Merge libreplace support for inet_pton, inet_ntop, getaddrinfo, getnameinfo (and friends) from SAMBA_3_2, with some minor tweaks: - avoid including network headers in replace.h unless absolutely required - autoconf tests for getaddrinfo() in lib/replace The heimdal-specific code also no longer looks for these functions anymore. (This used to be commit b6d3fd84a5d7d814035e60d6fa22f19bed9f77da) --- source4/lib/replace/getaddrinfo.c | 502 +++++++++++++++++++++++++++++++++++ source4/lib/replace/getaddrinfo.h | 158 +++++++++++ source4/lib/replace/inet_ntop.c | 191 +++++++++++++ source4/lib/replace/inet_ntop.m4 | 1 + source4/lib/replace/inet_pton.c | 213 +++++++++++++++ source4/lib/replace/inet_pton.m4 | 1 + source4/lib/replace/libreplace.m4 | 43 ++- source4/lib/replace/replace.h | 21 +- source4/lib/replace/system/network.h | 4 + 9 files changed, 1128 insertions(+), 6 deletions(-) create mode 100644 source4/lib/replace/getaddrinfo.c create mode 100644 source4/lib/replace/getaddrinfo.h create mode 100644 source4/lib/replace/inet_ntop.c create mode 100644 source4/lib/replace/inet_ntop.m4 create mode 100644 source4/lib/replace/inet_pton.c create mode 100644 source4/lib/replace/inet_pton.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getaddrinfo.c b/source4/lib/replace/getaddrinfo.c new file mode 100644 index 0000000000..519c30066b --- /dev/null +++ b/source4/lib/replace/getaddrinfo.c @@ -0,0 +1,502 @@ +/* +PostgreSQL Database Management System +(formerly known as Postgres, then as Postgres95) + +Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group + +Portions Copyright (c) 1994, The Regents of the University of California + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose, without fee, and without a written agreement +is hereby granted, provided that the above copyright notice and this paragraph +and the following two paragraphs appear in all copies. + +IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR +DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING +LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, +EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS +ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +*/ + +/*------------------------------------------------------------------------- + * + * getaddrinfo.c + * Support getaddrinfo() on platforms that don't have it. + * + * We also supply getnameinfo() here, assuming that the platform will have + * it if and only if it has getaddrinfo(). If this proves false on some + * platform, we'll need to split this file and provide a separate configure + * test for getnameinfo(). + * + * Copyright (c) 2003-2007, PostgreSQL Global Development Group + * + * Copyright (C) 2007 Jeremy Allison. + * Modified to return multiple IPv4 addresses for Samba. + * + *------------------------------------------------------------------------- + */ + +#include "replace.h" +#include "system/network.h" + +#ifndef SMB_MALLOC +#define SMB_MALLOC(s) malloc(s) +#endif + +#ifndef SMB_STRDUP +#define SMB_STRDUP(s) strdup(s) +#endif + +static int check_hostent_err(struct hostent *hp) +{ + if (!hp) { + switch (h_errno) { + case HOST_NOT_FOUND: + case NO_DATA: + return EAI_NONAME; + case TRY_AGAIN: + return EAI_AGAIN; + case NO_RECOVERY: + default: + return EAI_FAIL; + } + } + if (!hp->h_name || hp->h_addrtype != AF_INET) { + return EAI_FAIL; + } + return 0; +} + +static char *canon_name_from_hostent(struct hostent *hp, + int *perr) +{ + char *ret = NULL; + + *perr = check_hostent_err(hp); + if (*perr) { + return NULL; + } + ret = SMB_STRDUP(hp->h_name); + if (!ret) { + *perr = EAI_MEMORY; + } + return ret; +} + +static char *get_my_canon_name(int *perr) +{ + char name[HOST_NAME_MAX+1]; + + if (gethostname(name, HOST_NAME_MAX) == -1) { + *perr = EAI_FAIL; + return NULL; + } + /* Ensure null termination. */ + name[HOST_NAME_MAX] = '\0'; + return canon_name_from_hostent(gethostbyname(name), perr); +} + +static char *get_canon_name_from_addr(struct in_addr ip, + int *perr) +{ + return canon_name_from_hostent( + gethostbyaddr(&ip, sizeof(ip), AF_INET), + perr); +} + +static struct addrinfo *alloc_entry(const struct addrinfo *hints, + struct in_addr ip, + unsigned short port) +{ + struct sockaddr_in *psin = NULL; + struct addrinfo *ai = SMB_MALLOC(sizeof(*ai)); + + if (!ai) { + return NULL; + } + memset(ai, '\0', sizeof(*ai)); + + psin = SMB_MALLOC(sizeof(*psin)); + if (!psin) { + free(ai); + return NULL; + } + + memset(psin, '\0', sizeof(*psin)); + + psin->sin_family = AF_INET; + psin->sin_port = htons(port); + psin->sin_addr = ip; + + ai->ai_flags = 0; + ai->ai_family = AF_INET; + ai->ai_socktype = hints->ai_socktype; + ai->ai_protocol = hints->ai_protocol; + ai->ai_addrlen = sizeof(*psin); + ai->ai_addr = (struct sockaddr *) psin; + ai->ai_canonname = NULL; + ai->ai_next = NULL; + + return ai; +} + +/* + * get address info for a single ipv4 address. + * + * Bugs: - servname can only be a number, not text. + */ + +static int getaddr_info_single_addr(const char *service, + uint32_t addr, + const struct addrinfo *hints, + struct addrinfo **res) +{ + + struct addrinfo *ai = NULL; + struct in_addr ip; + unsigned short port = 0; + + if (service) { + port = (unsigned short)atoi(service); + } + ip.s_addr = htonl(addr); + + ai = alloc_entry(hints, ip, port); + if (!ai) { + return EAI_MEMORY; + } + + /* If we're asked for the canonical name, + * make sure it returns correctly. */ + if (!(hints->ai_flags & AI_NUMERICSERV) && + hints->ai_flags & AI_CANONNAME) { + int err; + if (addr == INADDR_LOOPBACK || addr == INADDR_ANY) { + ai->ai_canonname = get_my_canon_name(&err); + } else { + ai->ai_canonname = + get_canon_name_from_addr(ip,&err); + } + if (ai->ai_canonname == NULL) { + freeaddrinfo(ai); + return err; + } + } + + *res = ai; + return 0; +} + +/* + * get address info for multiple ipv4 addresses. + * + * Bugs: - servname can only be a number, not text. + */ + +static int getaddr_info_name(const char *node, + const char *service, + const struct addrinfo *hints, + struct addrinfo **res) +{ + struct addrinfo *listp = NULL, *prevp = NULL; + char **pptr = NULL; + int err; + struct hostent *hp = NULL; + unsigned short port = 0; + + if (service) { + port = (unsigned short)atoi(service); + } + + hp = gethostbyname(node); + err = check_hostent_err(hp); + if (err) { + return err; + } + + for(pptr = hp->h_addr_list; *pptr; pptr++) { + struct in_addr ip = *(struct in_addr *)pptr; + struct addrinfo *ai = alloc_entry(hints, ip, port); + + if (!ai) { + freeaddrinfo(listp); + return EAI_MEMORY; + } + + if (!listp) { + listp = ai; + prevp = ai; + ai->ai_canonname = SMB_STRDUP(hp->h_name); + if (!ai->ai_canonname) { + freeaddrinfo(listp); + return EAI_MEMORY; + } + } else { + prevp->ai_next = ai; + prevp = ai; + } + } + *res = listp; + return 0; +} + +/* + * get address info for ipv4 sockets. + * + * Bugs: - servname can only be a number, not text. + */ + +int getaddrinfo(const char *node, + const char *service, + const struct addrinfo * hintp, + struct addrinfo ** res) +{ + struct addrinfo hints; + + /* Setup the hints struct. */ + if (hintp == NULL) { + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_STREAM; + } else { + memcpy(&hints, hintp, sizeof(hints)); + } + + if (hints.ai_family != AF_INET && hints.ai_family != AF_UNSPEC) { + return EAI_FAMILY; + } + + if (hints.ai_socktype == 0) { + hints.ai_socktype = SOCK_STREAM; + } + + if (!node && !service) { + return EAI_NONAME; + } + + if (node) { + if (node[0] == '\0') { + return getaddr_info_single_addr(service, + INADDR_ANY, + &hints, + res); + } else if (hints.ai_flags & AI_NUMERICHOST) { + struct in_addr ip; + if (!inet_aton(node, &ip)) { + return EAI_FAIL; + } + return getaddr_info_single_addr(service, + ntohl(ip.s_addr), + &hints, + res); + } else { + return getaddr_info_name(node, + service, + &hints, + res); + } + } else if (hints.ai_flags & AI_PASSIVE) { + return getaddr_info_single_addr(service, + INADDR_ANY, + &hints, + res); + } + return getaddr_info_single_addr(service, + INADDR_LOOPBACK, + &hints, + res); +} + + +void freeaddrinfo(struct addrinfo *res) +{ + struct addrinfo *next = NULL; + + for (;res; res = next) { + next = res->ai_next; + if (res->ai_canonname) { + free(res->ai_canonname); + } + if (res->ai_addr) { + free(res->ai_addr); + } + free(res); + } +} + + +const char *gai_strerror(int errcode) +{ +#ifdef HAVE_HSTRERROR + int hcode; + + switch (errcode) + { + case EAI_NONAME: + hcode = HOST_NOT_FOUND; + break; + case EAI_AGAIN: + hcode = TRY_AGAIN; + break; + case EAI_FAIL: + default: + hcode = NO_RECOVERY; + break; + } + + return hstrerror(hcode); +#else /* !HAVE_HSTRERROR */ + + switch (errcode) + { + case EAI_NONAME: + return "Unknown host"; + case EAI_AGAIN: + return "Host name lookup failure"; +#ifdef EAI_BADFLAGS + case EAI_BADFLAGS: + return "Invalid argument"; +#endif +#ifdef EAI_FAMILY + case EAI_FAMILY: + return "Address family not supported"; +#endif +#ifdef EAI_MEMORY + case EAI_MEMORY: + return "Not enough memory"; +#endif +#ifdef EAI_NODATA + case EAI_NODATA: + return "No host data of that type was found"; +#endif +#ifdef EAI_SERVICE + case EAI_SERVICE: + return "Class type not found"; +#endif +#ifdef EAI_SOCKTYPE + case EAI_SOCKTYPE: + return "Socket type not supported"; +#endif + default: + return "Unknown server error"; + } +#endif /* HAVE_HSTRERROR */ +} + +static int gethostnameinfo(const struct sockaddr *sa, + char *node, + size_t nodelen, + int flags) +{ + int ret = -1; + char *p = NULL; + + if (!(flags & NI_NUMERICHOST)) { + struct hostent *hp = gethostbyaddr( + &((struct sockaddr_in *)sa)->sin_addr, + sizeof(struct in_addr), + sa->sa_family); + ret = check_hostent_err(hp); + if (ret == 0) { + /* Name looked up successfully. */ + ret = snprintf(node, nodelen, "%s", hp->h_name); + if (ret == -1 || ret > nodelen) { + return EAI_MEMORY; + } + if (flags & NI_NOFQDN) { + p = strchr(node,'.'); + if (p) { + *p = '\0'; + } + } + return 0; + } + + if (flags & NI_NAMEREQD) { + /* If we require a name and didn't get one, + * automatically fail. */ + return ret; + } + /* Otherwise just fall into the numeric host code... */ + } + p = inet_ntoa(((struct sockaddr_in *)sa)->sin_addr); + ret = snprintf(node, nodelen, "%s", p); + if (ret == -1 || ret > nodelen) { + return EAI_MEMORY; + } + return 0; +} + +static int getservicenameinfo(const struct sockaddr *sa, + char *service, + size_t servicelen, + int flags) +{ + int ret = -1; + int port = ntohs(((struct sockaddr_in *)sa)->sin_port); + + if (!(flags & NI_NUMERICSERV)) { + struct servent *se = getservbyport( + port, + (flags & NI_DGRAM) ? "udp" : "tcp"); + if (se && se->s_name) { + /* Service name looked up successfully. */ + ret = snprintf(service, servicelen, "%s", se->s_name); + if (ret == -1 || ret > servicelen) { + return EAI_MEMORY; + } + return 0; + } + /* Otherwise just fall into the numeric service code... */ + } + ret = snprintf(service, servicelen, "%d", port); + if (ret == -1 || ret > servicelen) { + return EAI_MEMORY; + } + return 0; +} + +/* + * Convert an ipv4 address to a hostname. + * + * Bugs: - No IPv6 support. + */ +int getnameinfo(const struct sockaddr *sa, socklen_t salen, + char *node, size_t nodelen, + char *service, size_t servicelen, int flags) +{ + + /* Invalid arguments. */ + if (sa == NULL || (node == NULL && service == NULL)) { + return EAI_FAIL; + } + + if (sa->sa_family != AF_INET) { + return EAI_FAIL; + } + + if (salen < sizeof(struct sockaddr_in)) { + return EAI_FAIL; + } + + /* We don't support those. */ + if ((node && !(flags & NI_NUMERICHOST)) + || (service && !(flags & NI_NUMERICSERV))) + return EAI_FAIL; + + if (node) { + return gethostnameinfo(sa, node, nodelen, flags); + } + + if (service) { + return getservicenameinfo(sa, service, servicelen, flags); + } + return 0; +} diff --git a/source4/lib/replace/getaddrinfo.h b/source4/lib/replace/getaddrinfo.h new file mode 100644 index 0000000000..ed678bd065 --- /dev/null +++ b/source4/lib/replace/getaddrinfo.h @@ -0,0 +1,158 @@ +/* +PostgreSQL Database Management System +(formerly known as Postgres, then as Postgres95) + +Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group + +Portions Copyright (c) 1994, The Regents of the University of California + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose, without fee, and without a written agreement +is hereby granted, provided that the above copyright notice and this paragraph +and the following two paragraphs appear in all copies. + +IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR +DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING +LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, +EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS +ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +*/ + +/*------------------------------------------------------------------------- + * + * getaddrinfo.h + * Support getaddrinfo() on platforms that don't have it. + * + * Note: we use our own routines on platforms that don't HAVE_STRUCT_ADDRINFO, + * whether or not the library routine getaddrinfo() can be found. This + * policy is needed because on some platforms a manually installed libbind.a + * may provide getaddrinfo(), yet the system headers may not provide the + * struct definitions needed to call it. To avoid conflict with the libbind + * definition in such cases, we rename our routines to pg_xxx() via macros. + * + * This code will also work on platforms where struct addrinfo is defined + * in the system headers but no getaddrinfo() can be located. + * + * Copyright (c) 2003-2007, PostgreSQL Global Development Group + * + *------------------------------------------------------------------------- + */ +#ifndef GETADDRINFO_H +#define GETADDRINFO_H + + +/* Various macros that ought to be in , but might not be */ + +#ifndef EAI_FAIL +#define EAI_BADFLAGS (-1) +#define EAI_NONAME (-2) +#define EAI_AGAIN (-3) +#define EAI_FAIL (-4) +#define EAI_FAMILY (-6) +#define EAI_SOCKTYPE (-7) +#define EAI_SERVICE (-8) +#define EAI_MEMORY (-10) +#define EAI_SYSTEM (-11) +#endif /* !EAI_FAIL */ + +#ifndef AI_PASSIVE +#define AI_PASSIVE 0x0001 +#endif + +#ifndef AI_NUMERICHOST +/* + * some platforms don't support AI_NUMERICHOST; define as zero if using + * the system version of getaddrinfo... + */ +#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO) +#define AI_NUMERICHOST 0 +#else +#define AI_NUMERICHOST 0x0004 +#endif +#endif + +#ifndef NI_NUMERICHOST +#define NI_NUMERICHOST 1 +#endif + +#ifndef NI_NUMERICSERV +#define NI_NUMERICSERV 2 +#endif + +#ifndef NI_NOFQDN +#define NI_NOFQDN 4 +#endif + +#ifndef NI_NAMEREQD +#define NI_NAMEREQD 8 +#endif + +#ifndef NI_DGRAM +#define NI_DGRAM 16 +#endif + + +#ifndef NI_MAXHOST +#define NI_MAXHOST 1025 +#endif + +#ifndef NI_MAXSERV +#define NI_MAXSERV 32 +#endif + +#ifndef HAVE_STRUCT_ADDRINFO + +struct addrinfo +{ + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + size_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; +#endif /* HAVE_STRUCT_ADDRINFO */ + + +#ifndef HAVE_GETADDRINFO + +/* Rename private copies per comments above */ +#ifdef getaddrinfo +#undef getaddrinfo +#endif +#define getaddrinfo pg_getaddrinfo + +#ifdef freeaddrinfo +#undef freeaddrinfo +#endif +#define freeaddrinfo pg_freeaddrinfo + +#ifdef gai_strerror +#undef gai_strerror +#endif +#define gai_strerror pg_gai_strerror + +#ifdef getnameinfo +#undef getnameinfo +#endif +#define getnameinfo pg_getnameinfo + +extern int getaddrinfo(const char *node, const char *service, + const struct addrinfo * hints, struct addrinfo ** res); +extern void freeaddrinfo(struct addrinfo * res); +extern const char *gai_strerror(int errcode); +extern int getnameinfo(const struct sockaddr * sa, socklen_t salen, + char *node, size_t nodelen, + char *service, size_t servicelen, int flags); +#endif /* HAVE_GETADDRINFO */ + +#endif /* GETADDRINFO_H */ diff --git a/source4/lib/replace/inet_ntop.c b/source4/lib/replace/inet_ntop.c new file mode 100644 index 0000000000..fb3d8e90c8 --- /dev/null +++ b/source4/lib/replace/inet_ntop.c @@ -0,0 +1,191 @@ +/* + * Copyright (C) 1996-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "replace.h" +#include "system/network.h" + +#define NS_INT16SZ 2 +#define NS_IN6ADDRSZ 16 + +/* + * WARNING: Don't even consider trying to compile this on a system where + * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. + */ + +static const char *inet_ntop4(const unsigned char *src, char *dst, + socklen_t size); + +#ifdef AF_INET6 +static const char *inet_ntop6(const unsigned char *src, char *dst, + socklen_t size); +#endif + +/* char * + * isc_net_ntop(af, src, dst, size) + * convert a network format address to presentation format. + * return: + * pointer to presentation format address (`dst'), or NULL (see errno). + * author: + * Paul Vixie, 1996. + */ +const char * +rep_inet_ntop(int af, const void *src, char *dst, socklen_t size) +{ + switch (af) { + case AF_INET: + return (inet_ntop4(src, dst, size)); +#ifdef AF_INET6 + case AF_INET6: + return (inet_ntop6(src, dst, size)); +#endif + default: + errno = EAFNOSUPPORT; + return (NULL); + } + /* NOTREACHED */ +} + +/* const char * + * inet_ntop4(src, dst, size) + * format an IPv4 address + * return: + * `dst' (as a const) + * notes: + * (1) uses no statics + * (2) takes a unsigned char* not an in_addr as input + * author: + * Paul Vixie, 1996. + */ +static const char * +inet_ntop4(const unsigned char *src, char *dst, socklen_t size) +{ + static const char *fmt = "%u.%u.%u.%u"; + char tmp[sizeof "255.255.255.255"]; + size_t len; + + len = snprintf(tmp, sizeof tmp, fmt, src[0], src[1], src[2], src[3]); + if (len >= size) { + errno = ENOSPC; + return (NULL); + } + memcpy(dst, tmp, len + 1); + + return (dst); +} + +/* const char * + * isc_inet_ntop6(src, dst, size) + * convert IPv6 binary address into presentation (printable) format + * author: + * Paul Vixie, 1996. + */ +#ifdef AF_INET6 +static const char * +inet_ntop6(const unsigned char *src, char *dst, socklen_t size) +{ + /* + * Note that int32_t and int16_t need only be "at least" large enough + * to contain a value of the specified size. On some systems, like + * Crays, there is no such thing as an integer variable with 16 bits. + * Keep this in mind if you think this function should have been coded + * to use pointer overlays. All the world's not a VAX. + */ + char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; + struct { int base, len; } best, cur; + unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ]; + int i, inc; + + /* + * Preprocess: + * Copy the input (bytewise) array into a wordwise array. + * Find the longest run of 0x00's in src[] for :: shorthanding. + */ + memset(words, '\0', sizeof words); + for (i = 0; i < NS_IN6ADDRSZ; i++) + words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); + best.base = -1; + best.len = 0; + cur.base = -1; + cur.len = 0; + for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { + if (words[i] == 0) { + if (cur.base == -1) + cur.base = i, cur.len = 1; + else + cur.len++; + } else { + if (cur.base != -1) { + if (best.base == -1 || cur.len > best.len) + best = cur; + cur.base = -1; + } + } + } + if (cur.base != -1) { + if (best.base == -1 || cur.len > best.len) + best = cur; + } + if (best.base != -1 && best.len < 2) + best.base = -1; + + /* + * Format the result. + */ + tp = tmp; + for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { + /* Are we inside the best run of 0x00's? */ + if (best.base != -1 && i >= best.base && + i < (best.base + best.len)) { + if (i == best.base) + *tp++ = ':'; + continue; + } + /* Are we following an initial run of 0x00s or any real hex? */ + if (i != 0) + *tp++ = ':'; + /* Is this address an encapsulated IPv4? */ + if (i == 6 && best.base == 0 && + (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { + if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) + return (NULL); + tp += strlen(tp); + break; + } + inc = snprintf(tp, 5, "%x", words[i]); + if (inc >= 5) { + abort(); + } + tp += inc; + } + /* Was it a trailing run of 0x00's? */ + if (best.base != -1 && (best.base + best.len) == + (NS_IN6ADDRSZ / NS_INT16SZ)) + *tp++ = ':'; + *tp++ = '\0'; + + /* + * Check for overflow, copy, and we're done. + */ + if ((size_t)(tp - tmp) > size) { + errno = ENOSPC; + return (NULL); + } + memcpy(dst, tmp, tp - tmp); + return (dst); +} +#endif /* AF_INET6 */ diff --git a/source4/lib/replace/inet_ntop.m4 b/source4/lib/replace/inet_ntop.m4 new file mode 100644 index 0000000000..6f39056f1d --- /dev/null +++ b/source4/lib/replace/inet_ntop.m4 @@ -0,0 +1 @@ +AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"]) diff --git a/source4/lib/replace/inet_pton.c b/source4/lib/replace/inet_pton.c new file mode 100644 index 0000000000..80e4865ef4 --- /dev/null +++ b/source4/lib/replace/inet_pton.c @@ -0,0 +1,213 @@ +/* + * Copyright (C) 1996-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "replace.h" +#include "system/network.h" + +#define NS_INT16SZ 2 +#define NS_INADDRSZ 4 +#define NS_IN6ADDRSZ 16 + +/* + * WARNING: Don't even consider trying to compile this on a system where + * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. + */ + +static int inet_pton4(const char *src, unsigned char *dst); +#ifdef AF_INET6 +static int inet_pton6(const char *src, unsigned char *dst); +#endif + +/* int + * inet_pton(af, src, dst) + * convert from presentation format (which usually means ASCII printable) + * to network format (which is usually some kind of binary format). + * return: + * 1 if the address was valid for the specified address family + * 0 if the address wasn't valid (`dst' is untouched in this case) + * -1 if some other error occurred (`dst' is untouched in this case, too) + * author: + * Paul Vixie, 1996. + */ +int +rep_inet_pton(int af, + const char *src, + void *dst) +{ + switch (af) { + case AF_INET: + return (inet_pton4(src, dst)); +#ifdef AF_INET6 + case AF_INET6: + return (inet_pton6(src, dst)); +#endif + default: + errno = EAFNOSUPPORT; + return (-1); + } + /* NOTREACHED */ +} + +/* int + * inet_pton4(src, dst) + * like inet_aton() but without all the hexadecimal and shorthand. + * return: + * 1 if `src' is a valid dotted quad, else 0. + * notice: + * does not touch `dst' unless it's returning 1. + * author: + * Paul Vixie, 1996. + */ +static int +inet_pton4(src, dst) + const char *src; + unsigned char *dst; +{ + static const char digits[] = "0123456789"; + int saw_digit, octets, ch; + unsigned char tmp[NS_INADDRSZ], *tp; + + saw_digit = 0; + octets = 0; + *(tp = tmp) = 0; + while ((ch = *src++) != '\0') { + const char *pch; + + if ((pch = strchr(digits, ch)) != NULL) { + unsigned int new = *tp * 10 + (pch - digits); + + if (new > 255) + return (0); + *tp = new; + if (! saw_digit) { + if (++octets > 4) + return (0); + saw_digit = 1; + } + } else if (ch == '.' && saw_digit) { + if (octets == 4) + return (0); + *++tp = 0; + saw_digit = 0; + } else + return (0); + } + if (octets < 4) + return (0); + memcpy(dst, tmp, NS_INADDRSZ); + return (1); +} + +/* int + * inet_pton6(src, dst) + * convert presentation level address to network order binary form. + * return: + * 1 if `src' is a valid [RFC1884 2.2] address, else 0. + * notice: + * (1) does not touch `dst' unless it's returning 1. + * (2) :: in a full address is silently ignored. + * credit: + * inspired by Mark Andrews. + * author: + * Paul Vixie, 1996. + */ +#ifdef AF_INET6 +static int +inet_pton6(src, dst) + const char *src; + unsigned char *dst; +{ + static const char xdigits_l[] = "0123456789abcdef", + xdigits_u[] = "0123456789ABCDEF"; + unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; + const char *xdigits, *curtok; + int ch, saw_xdigit; + unsigned int val; + + memset((tp = tmp), '\0', NS_IN6ADDRSZ); + endp = tp + NS_IN6ADDRSZ; + colonp = NULL; + /* Leading :: requires some special handling. */ + if (*src == ':') + if (*++src != ':') + return (0); + curtok = src; + saw_xdigit = 0; + val = 0; + while ((ch = *src++) != '\0') { + const char *pch; + + if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) + pch = strchr((xdigits = xdigits_u), ch); + if (pch != NULL) { + val <<= 4; + val |= (pch - xdigits); + if (val > 0xffff) + return (0); + saw_xdigit = 1; + continue; + } + if (ch == ':') { + curtok = src; + if (!saw_xdigit) { + if (colonp) + return (0); + colonp = tp; + continue; + } + if (tp + NS_INT16SZ > endp) + return (0); + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; + saw_xdigit = 0; + val = 0; + continue; + } + if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && + inet_pton4(curtok, tp) > 0) { + tp += NS_INADDRSZ; + saw_xdigit = 0; + break; /* '\0' was seen by inet_pton4(). */ + } + return (0); + } + if (saw_xdigit) { + if (tp + NS_INT16SZ > endp) + return (0); + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; + } + if (colonp != NULL) { + /* + * Since some memmove()'s erroneously fail to handle + * overlapping regions, we'll do the shift by hand. + */ + const int n = tp - colonp; + int i; + + for (i = 1; i <= n; i++) { + endp[- i] = colonp[n - i]; + colonp[n - i] = 0; + } + tp = endp; + } + if (tp != endp) + return (0); + memcpy(dst, tmp, NS_IN6ADDRSZ); + return (1); +} +#endif diff --git a/source4/lib/replace/inet_pton.m4 b/source4/lib/replace/inet_pton.m4 new file mode 100644 index 0000000000..51de9275d0 --- /dev/null +++ b/source4/lib/replace/inet_pton.m4 @@ -0,0 +1 @@ +AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"]) diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index a6b1c4f5e6..29ec2acdab 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -137,6 +137,45 @@ if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) fi +dnl test for struct addrinfo +AC_CACHE_CHECK([for struct addrinfo],samba_cv_HAVE_STRUCT_ADDRINFO,[ +AC_TRY_COMPILE([ +#include +#include +#include ], +[ +struct addrinfo ai; +], +samba_cv_HAVE_STRUCT_ADDRINFO=yes,samba_cv_HAVE_STRUCT_ADDRINFO=no)]) +if test x"$samba_cv_HAVE_STRUCT_ADDRINFO" = x"yes"; then + AC_DEFINE(HAVE_STRUCT_ADDRINFO,1,[Whether the system has struct addrinfo]) +fi + +dnl test for getaddrinfo/getnameinfo +AC_CACHE_CHECK([for getaddrinfo],samba_cv_HAVE_GETADDRINFO,[ +AC_TRY_COMPILE([ +#include +#include +#include ], +[ +struct sockaddr sa; +struct addrinfo *ai = NULL; +int ret = getaddrinfo(NULL, NULL, NULL, &ai); +if (ret != 0) { + const char *es = gai_strerror(ret); +} +freeaddrinfo(ai); +ret = getnameinfo(&sa, sizeof(sa), + NULL, 0, + NULL, 0, 0); + +], +samba_cv_HAVE_GETADDRINFO=yes,samba_cv_HAVE_GETADDRINFO=no)]) +if test x"$samba_cv_HAVE_GETADDRINFO" = x"yes"; then + AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo and getnameinfo]) +fi + + dnl Provided by replace.c: AC_TRY_COMPILE([ #include @@ -304,7 +343,7 @@ AC_TRY_COMPILE([ samba_cv_HAVE_OPEN_O_DIRECT=yes,samba_cv_HAVE_OPEN_O_DIRECT=no)]) if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT]) -fi +fi dnl Check if the C compiler understands volatile (it should, being ANSI). @@ -322,6 +361,8 @@ m4_include(getpass.m4) m4_include(strptime.m4) m4_include(win32.m4) m4_include(timegm.m4) +m4_include(inet_ntop.m4) +m4_include(inet_pton.m4) m4_include(repdir.m4) AC_CHECK_FUNCS([syslog memset memcpy],,[AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index af05516e8c..26e39ac603 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -1,15 +1,16 @@ -/* +/* Unix SMB/CIFS implementation. macros to go along with the lib/replace/ portability layer code Copyright (C) Andrew Tridgell 2005 Copyright (C) Jelmer Vernooij 2006 + Copyright (C) Jeremy Allison 2007. ** NOTE! The following LGPL license applies to the replace ** library. This does NOT imply that all of Samba is released ** under the LGPL - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -71,7 +72,6 @@ #include #endif - #ifndef HAVE_STRERROR extern char *sys_errlist[]; #define strerror(i) sys_errlist[i] @@ -139,7 +139,7 @@ int setenv(const char *name, const char *value, int overwrite); #ifndef HAVE_UNSETENV #define unsetenv rep_unsetenv -int rep_unsetenv(const char *name); +int rep_unsetenv(const char *name); #endif #ifndef HAVE_SETEUID @@ -163,7 +163,7 @@ char *rep_strcasestr(const char *haystack, const char *needle); #endif #ifndef HAVE_STRTOK_R -#define strtok_r rep_strtok_r +#define strtok_r rep_strtok_r char *rep_strtok_r(char *s, const char *delim, char **save_ptr); #endif @@ -330,6 +330,17 @@ ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset); ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset); #endif +#ifndef HAVE_INET_PTON +int rep_inet_pton(int af, const char *src, void *dst); +#define inet_pton rep_inet_pton +#endif + +#ifndef HAVE_INET_NTOP +#include "system/network.h" +const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); +#define inet_ntop rep_inet_ntop +#endif + #ifdef HAVE_LIMITS_H #include #endif diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 7469040b28..877f5f25e6 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -49,6 +49,10 @@ #include #endif +#if !defined(HAVE_GETADDRINFO) +#include "getaddrinfo.h" +#endif + /* * The next three defines are needed to access the IPTOS_* options * on some systems. -- cgit From f3e212ff6948dcd6d12f90cc18ba4f65ad7d9323 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:58:15 +0000 Subject: r25556: Update README. (This used to be commit 1a7dbfde5fcef19998b8af470c152a76386fb79f) --- source4/lib/replace/README | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 77558b2ca9..c61f78a951 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -50,10 +50,16 @@ pwrite getpass readline (the library) inet_ntoa +inet_ntop +inet_pton strtoll strtoull socketpair strptime +getaddrinfo +freeaddrinfo +getnameinfo +gai_strerror Types: bool -- cgit From 775a3d034d903243d9dd4309817f188c7984d037 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 7 Oct 2007 00:25:27 +0000 Subject: r25558: Define HAVE_* for other gai functions to prevent problems with libroken. (This used to be commit e09828a634bf10bda9c6f28b18106c2bcab84643) --- source4/lib/replace/libreplace.m4 | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 29ec2acdab..9063f5029d 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -173,6 +173,8 @@ ret = getnameinfo(&sa, sizeof(sa), samba_cv_HAVE_GETADDRINFO=yes,samba_cv_HAVE_GETADDRINFO=no)]) if test x"$samba_cv_HAVE_GETADDRINFO" = x"yes"; then AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo and getnameinfo]) + AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo]) + AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror]) fi -- cgit From 397a0aaa43681114500f28f4950f0b88b7cde6d3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 8 Oct 2007 23:10:09 +0000 Subject: r25586: Fix getaddrinfo detection - from Timur. Jeremy. (This used to be commit 48819012f81167f07d2e909329432d2ef222b1bf) --- source4/lib/replace/libreplace.m4 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 9063f5029d..4bdbf3a504 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -141,6 +141,10 @@ dnl test for struct addrinfo AC_CACHE_CHECK([for struct addrinfo],samba_cv_HAVE_STRUCT_ADDRINFO,[ AC_TRY_COMPILE([ #include +#if STDC_HEADERS +#include +#include +#endif #include #include ], [ @@ -154,8 +158,12 @@ fi dnl test for getaddrinfo/getnameinfo AC_CACHE_CHECK([for getaddrinfo],samba_cv_HAVE_GETADDRINFO,[ AC_TRY_COMPILE([ -#include #include +#if STDC_HEADERS +#include +#include +#endif +#include #include ], [ struct sockaddr sa; -- cgit From 39f5745c16e294d95591edb44645ca9751fcee9c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 10 Oct 2007 07:18:24 +0000 Subject: r25597: HPUX doesn't have INET_ADDRSTRLEN defined metze (This used to be commit f9696109cc8f4646599f73b78e1eacd94d1a6c2c) --- source4/lib/replace/system/network.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 877f5f25e6..02942f9a44 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -110,4 +110,8 @@ char *rep_inet_ntoa(struct in_addr ip); #define INADDR_NONE 0xffffffff #endif +#ifndef INET_ADDRSTRLEN +#define INET_ADDRSTRLEN 16 +#endif + #endif -- cgit From 6876d2613da8e579146040babd33e71fc1889d46 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 10 Oct 2007 11:57:16 +0200 Subject: r25601: replace.h should never imply any "system/*.h" (here it's "system/time.h") metze (This used to be commit 00467c25930a527eb9831cfd893bd8e217ca4f74) --- source4/lib/replace/replace.h | 9 ++------- source4/lib/replace/system/time.h | 10 ++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 26e39ac603..fcf75635a7 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -91,19 +91,14 @@ char *rep_strdup(const char *s); void *rep_memmove(void *dest,const void *src,int size); #endif -#if !defined(HAVE_MKTIME) || !defined(HAVE_TIMEGM) -#include "system/time.h" -#endif - #ifndef HAVE_MKTIME #define mktime rep_mktime -time_t rep_mktime(struct tm *t); +/* prototype is in "system/time.h" */ #endif #ifndef HAVE_TIMEGM -struct tm; #define timegm rep_timegm -time_t rep_timegm(struct tm *tm); +/* prototype is in "system/time.h" */ #endif #ifndef HAVE_STRLCPY diff --git a/source4/lib/replace/system/time.h b/source4/lib/replace/system/time.h index 6bbb6b15bb..036812ab8f 100644 --- a/source4/lib/replace/system/time.h +++ b/source4/lib/replace/system/time.h @@ -41,4 +41,14 @@ #include #endif +#ifndef HAVE_MKTIME +/* define is in "replace.h" */ +time_t rep_mktime(struct tm *t); +#endif + +#ifndef HAVE_TIMEGM +/* define is in "replace.h" */ +time_t rep_timegm(struct tm *tm); +#endif + #endif -- cgit From a3e5710eda2e9fc7ee9dce1e9082dbf03f96faeb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 10 Oct 2007 12:09:06 +0200 Subject: r25602: don't imply "system/network.h" within replace.h, as this brings in the socket_wrapper.h in unexpected code and we endup with a missing 'swrap_close' while linking metze (This used to be commit 507d5ca7d994f0771dbb66e61d2d22e391508658) --- source4/lib/replace/replace.h | 10 +++++++--- source4/lib/replace/system/network.h | 12 +++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index fcf75635a7..e42d5ff168 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -325,15 +325,19 @@ ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset); ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset); #endif +#ifdef REPLACE_INET_NTOA +#define inet_ntoa rep_inet_ntoa +/* prototype is in "system/network.h" */ +#endif + #ifndef HAVE_INET_PTON -int rep_inet_pton(int af, const char *src, void *dst); #define inet_pton rep_inet_pton +/* prototype is in "system/network.h" */ #endif #ifndef HAVE_INET_NTOP -#include "system/network.h" -const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #define inet_ntop rep_inet_ntop +/* prototype is in "system/network.h" */ #endif #ifdef HAVE_LIMITS_H diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 02942f9a44..8b911cf7d3 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -90,8 +90,18 @@ #endif #ifdef REPLACE_INET_NTOA +/* define is in "replace.h" */ char *rep_inet_ntoa(struct in_addr ip); -#define inet_ntoa rep_inet_ntoa +#endif + +#ifndef HAVE_INET_PTON +/* define is in "replace.h" */ +int rep_inet_pton(int af, const char *src, void *dst); +#endif + +#ifndef HAVE_INET_NTOP +/* define is in "replace.h" */ +const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #endif /* -- cgit From ce7a3abcd8174c9693db853734f3d17bde9a4194 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 13:58:19 +0200 Subject: r25677: add missing stuff from samba3 metze (This used to be commit d286c0533dd2726ebc547dcaf99f45169d4a9d2f) --- source4/lib/replace/system/network.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 8b911cf7d3..0b0dbcb88d 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -120,8 +120,38 @@ const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #define INADDR_NONE 0xffffffff #endif +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT EINVAL +#endif + #ifndef INET_ADDRSTRLEN #define INET_ADDRSTRLEN 16 #endif +#ifndef INET6_ADDRSTRLEN +#define INET6_ADDRSTRLEN 46 +#endif + +#ifndef HAVE_SOCKLEN_T +typedef int socklen_t; +#endif + +#ifndef HAVE_SA_FAMILY_T +typedef unsigned short int sa_family_t; +#endif + +#ifndef HAVE_STRUCT_SOCKADDR_STORAGE +#ifdef HAVE_STRUCT_SOCKADDR_IN6 +#define sockaddr_storage sockaddr_in6 +#define ss_family sin6_family +#else +#define sockaddr_storage sockaddr_in +#define ss_family sin_family +#endif +#endif + +#ifndef HOST_NAME_MAX +#define HOST_NAME_MAX 256 +#endif + #endif -- cgit From 090015a6fb40cf3dd925bc7db9015f91567c475e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:00:09 +0200 Subject: r25678: reformat getpass() replacement code metze (cherry picked from commit 3e8f43e3cf97f10be4717978643ef3edca8650a5) (This used to be commit 78da4477a7ef920ff77b41abb841465511b8db31) --- source4/lib/replace/getpass.c | 120 ++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 62 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index f6a72ad86a..eb69e68f19 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -140,69 +140,65 @@ static void catch_signal(int signum,void (*handler)(int )) char *getsmbpass(const char *prompt) { - FILE *in, *out; - int echo_off; - static char buf[256]; - static size_t bufsize = sizeof(buf); - size_t nread; - - /* Catch problematic signals */ - catch_signal(SIGINT, SIGNAL_CAST SIG_IGN); - - /* Try to write to and read from the terminal if we can. - If we can't open the terminal, use stderr and stdin. */ - - in = fopen ("/dev/tty", "w+"); - if (in == NULL) - { - in = stdin; - out = stderr; - } - else - out = in; - - setvbuf(in, NULL, _IONBF, 0); - - /* Turn echoing off if it is on now. */ - - if (tcgetattr (fileno (in), &t) == 0) - { - if (ECHO_IS_ON(t)) - { - TURN_ECHO_OFF(t); - echo_off = tcsetattr (fileno (in), TCSAFLUSH, &t) == 0; - TURN_ECHO_ON(t); + FILE *in, *out; + int echo_off; + static char buf[256]; + static size_t bufsize = sizeof(buf); + size_t nread; + + /* Catch problematic signals */ + catch_signal(SIGINT, SIGNAL_CAST SIG_IGN); + + /* Try to write to and read from the terminal if we can. + If we can't open the terminal, use stderr and stdin. */ + + in = fopen ("/dev/tty", "w+"); + if (in == NULL) { + in = stdin; + out = stderr; + } else { + out = in; } - else - echo_off = 0; - } - else - echo_off = 0; - - /* Write the prompt. */ - fputs (prompt, out); - fflush (out); - - /* Read the password. */ - buf[0] = 0; - fgets(buf, bufsize, in); - nread = strlen(buf); - if (buf[nread - 1] == '\n') - buf[nread - 1] = '\0'; - - /* Restore echoing. */ - if (echo_off) - (void) tcsetattr (fileno (in), TCSANOW, &t); - - if (in != stdin) - /* We opened the terminal; now close it. */ - fclose (in); - - /* Catch problematic signals */ - catch_signal(SIGINT, SIGNAL_CAST SIG_DFL); - - printf("\n"); - return buf; + + setvbuf(in, NULL, _IONBF, 0); + + /* Turn echoing off if it is on now. */ + + if (tcgetattr (fileno (in), &t) == 0) { + if (ECHO_IS_ON(t)) { + TURN_ECHO_OFF(t); + echo_off = tcsetattr (fileno (in), TCSAFLUSH, &t) == 0; + TURN_ECHO_ON(t); + } else { + echo_off = 0; + } + } else { + echo_off = 0; + } + + /* Write the prompt. */ + fputs(prompt, out); + fflush(out); + + /* Read the password. */ + buf[0] = 0; + fgets(buf, bufsize, in); + nread = strlen(buf); + if (buf[nread - 1] == '\n') + buf[nread - 1] = '\0'; + + /* Restore echoing. */ + if (echo_off) + tcsetattr (fileno (in), TCSANOW, &t); + + if (in != stdin) /* We opened the terminal; now close it. */ + fclose(in); + + /* Catch problematic signals */ + catch_signal(SIGINT, SIGNAL_CAST SIG_DFL); + + printf("\n"); + return buf; } #else -- cgit From 2627603506452debf018e2ed8ae0b7912d64e58e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:00:23 +0200 Subject: r25679: reapply: Allow ^C to interrupt smbpasswd if using our getpass. from Jeremy metze (cherry picked from commit d4ae42b1b2982dd786d6da16d7fa964d25fd3356) (This used to be commit a11d21790fc2ee33998e042195ccbad73631bad8) --- source4/lib/replace/getpass.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index eb69e68f19..1cabf0bd87 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -138,6 +138,21 @@ static void catch_signal(int signum,void (*handler)(int )) #endif } +static sig_atomic_t gotintr; +static int in_fd = -1; + +/*************************************************************** + Signal function to tell us were ^C'ed. +****************************************************************/ + +static void gotintr_sig(void) +{ + gotintr = 1; + if (in_fd != -1) + close(in_fd); /* Safe way to force a return. */ + in_fd = -1; +} + char *getsmbpass(const char *prompt) { FILE *in, *out; @@ -147,7 +162,7 @@ char *getsmbpass(const char *prompt) size_t nread; /* Catch problematic signals */ - catch_signal(SIGINT, SIGNAL_CAST SIG_IGN); + catch_signal(SIGINT, SIGNAL_CAST gotintr_sig); /* Try to write to and read from the terminal if we can. If we can't open the terminal, use stderr and stdin. */ @@ -182,14 +197,21 @@ char *getsmbpass(const char *prompt) /* Read the password. */ buf[0] = 0; - fgets(buf, bufsize, in); + if (!gotintr) { + in_fd = fileno(in); + fgets(buf, bufsize, in); + } nread = strlen(buf); if (buf[nread - 1] == '\n') buf[nread - 1] = '\0'; /* Restore echoing. */ - if (echo_off) - tcsetattr (fileno (in), TCSANOW, &t); + if (echo_off) { + if (gotintr && in_fd == -1) + in = fopen ("/dev/tty", "w+"); + if (in != NULL) + tcsetattr (fileno (in), TCSANOW, &t); + } if (in != stdin) /* We opened the terminal; now close it. */ fclose(in); @@ -198,6 +220,12 @@ char *getsmbpass(const char *prompt) catch_signal(SIGINT, SIGNAL_CAST SIG_DFL); printf("\n"); + + if (gotintr) { + printf("Interupted by signal.\n"); + fflush(stdout); + exit(1); + } return buf; } -- cgit From 50a749404bb1d86f0881fab06414469fda307c26 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:00:42 +0200 Subject: r25680: Volker's fix for bug #668. Change the \n after the password prompt to go to tty instead of stdout. (cherry picked from commit 0cd1ed0424ce87f60070d43caffda41be6706d59) (This used to be commit 249d69fd85b67657a4523ffc9244a8b4ab01270a) --- source4/lib/replace/getpass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 1cabf0bd87..96f508ead2 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -213,14 +213,15 @@ char *getsmbpass(const char *prompt) tcsetattr (fileno (in), TCSANOW, &t); } + fprintf(out, "\n"); + fflush(out); + if (in != stdin) /* We opened the terminal; now close it. */ fclose(in); /* Catch problematic signals */ catch_signal(SIGINT, SIGNAL_CAST SIG_DFL); - printf("\n"); - if (gotintr) { printf("Interupted by signal.\n"); fflush(stdout); -- cgit From 066f56bfeffcbd4808606d4a81c0f0cefa92e07e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:00:57 +0200 Subject: r25681: r16245: Cope with string being zero len. Klocwork bug #410. Jeremy. (cherry picked from commit 46c12de07fe6f44bcf58ca9de276e7932384843d) (This used to be commit 7099dde3fd8962e752451ebe2d5d79de4d7caee9) --- source4/lib/replace/getpass.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 96f508ead2..c67ff2bda7 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -202,8 +202,10 @@ char *getsmbpass(const char *prompt) fgets(buf, bufsize, in); } nread = strlen(buf); - if (buf[nread - 1] == '\n') - buf[nread - 1] = '\0'; + if (nread) { + if (buf[nread - 1] == '\n') + buf[nread - 1] = '\0'; + } /* Restore echoing. */ if (echo_off) { -- cgit From 190039a378ee208a026f868d083d7c00918d1b5f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:01:15 +0200 Subject: r25682: r16320: Ensure variable is not null before calling fclose. Klocwork #412. Jeremy. (cherry picked from commit 33ee0cfb190a883229d0824d7194898fd8966ceb) (This used to be commit 3910d069413834744b17175bb29775a69002712e) --- source4/lib/replace/getpass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index c67ff2bda7..dace5fbb8a 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -218,7 +218,7 @@ char *getsmbpass(const char *prompt) fprintf(out, "\n"); fflush(out); - if (in != stdin) /* We opened the terminal; now close it. */ + if (in && in != stdin) /* We opened the terminal; now close it. */ fclose(in); /* Catch problematic signals */ -- cgit From 2367364094824e03ce890e961bdb70d42c57471f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:01:34 +0200 Subject: r25683: fix the compilation of getpass.c and it's configure test metze (cherry picked from commit f4c0961a16a84dcdfe6e2faafb75c76983e6d466) (This used to be commit 5d747fcad0b0ac66584da500148e7647122e0544) --- source4/lib/replace/getpass.c | 10 +--------- source4/lib/replace/getpass.m4 | 5 +---- 2 files changed, 2 insertions(+), 13 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index dace5fbb8a..4b21849089 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -49,8 +49,6 @@ typedef int sig_atomic_t; #define SIGNAL_CAST (RETSIGTYPE (*)(int)) #endif -#ifdef REPLACE_GETPASS - #ifdef SYSV_TERMIO /* SYSTEM V TERMIO HANDLING */ @@ -131,10 +129,9 @@ static void catch_signal(int signum,void (*handler)(int )) sigemptyset(&act.sa_mask); sigaddset(&act.sa_mask,signum); sigaction(signum,&act,&oldact); - return oldact.sa_handler; #else /* !HAVE_SIGACTION */ /* FIXME: need to handle sigvec and systems with broken signal() */ - return signal(signum, handler); + signal(signum, handler); #endif } @@ -231,8 +228,3 @@ char *getsmbpass(const char *prompt) } return buf; } - -#else - void getsmbpasswd_dummy(void); - void getsmbpasswd_dummy(void) {;} -#endif diff --git a/source4/lib/replace/getpass.m4 b/source4/lib/replace/getpass.m4 index 20d04a63f6..17dfdf7bf5 100644 --- a/source4/lib/replace/getpass.m4 +++ b/source4/lib/replace/getpass.m4 @@ -3,11 +3,8 @@ SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$libreplacedir/" AC_TRY_COMPILE([ #include "confdefs.h" -#define _LIBREPLACE_REPLACE_H -#define REPLACE_GETPASS 1 -#define main dont_declare_main +#define NO_CONFIG_H #include "$libreplacedir/getpass.c" -#undef main ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no) CPPFLAGS="$SAVE_CPPFLAGS" ]) -- cgit From de0343b77bcbe0ad19f02c0894f703ade4d7fff2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:01:49 +0200 Subject: r25684: use "system/*.h" to get the system includes metze (cherry picked from commit d20c2fa274297e9577ed28b8ed04806a425bdc57) (This used to be commit ee8557783534ac5b075a8a4655a12b33b854c050) --- source4/lib/replace/getpass.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 4b21849089..f4819e9df5 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -18,21 +18,9 @@ not, see . */ /* Modified to use with samba by Jeremy Allison, 8th July 1995. */ #include "replace.h" - -#if defined(HAVE_TERMIOS_H) -/* POSIX terminal handling. */ -#include -#elif defined(HAVE_TERMIO_H) -/* Older SYSV terminal handling - don't use if we can avoid it. */ -#include -#elif defined(HAVE_SYS_TERMIO_H) -/* Older SYSV terminal handling - don't use if we can avoid it. */ -#include -#endif - -#ifdef HAVE_SYS_WAIT_H -#include -#endif +#include "system/filesys.h" +#include "system/wait.h" +#include "system/terminal.h" /* * Define additional missing types -- cgit From c68e3d8d652109edd95999755b31fd123bbffc90 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:02:06 +0200 Subject: r25685: rename getsmbpass -> rep_getpass and provide the function prototype metze (cherry picked from commit 96820f8d8f6522fc264efda0f069e2f6a420ac2e) (This used to be commit cd5069a8ca17a3a14814c0fbf55f113690291165) --- source4/lib/replace/getpass.c | 2 +- source4/lib/replace/system/passwd.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index f4819e9df5..1d13461573 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -138,7 +138,7 @@ static void gotintr_sig(void) in_fd = -1; } -char *getsmbpass(const char *prompt) +char *rep_getpass(const char *prompt) { FILE *in, *out; int echo_off; diff --git a/source4/lib/replace/system/passwd.h b/source4/lib/replace/system/passwd.h index 4e858fc89c..53d35e7b87 100644 --- a/source4/lib/replace/system/passwd.h +++ b/source4/lib/replace/system/passwd.h @@ -65,7 +65,8 @@ #endif #ifdef REPLACE_GETPASS -#define getpass(prompt) getsmbpass((prompt)) +#define getpass(prompt) rep_getpass(prompt) +char *rep_getpass(const char *prompt); #endif #ifndef NGROUPS_MAX -- cgit From 1b73fcadb2ffa4c9d538c027848c8aa6ceafdb0e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:02:20 +0200 Subject: r25686: Added in missing def for AI_ADDRCONFIG. Jeremy. (cherry picked from commit 3ef3c3afc3f56b0f4fdb384d55d2e712060fbedf) (This used to be commit 5d2995c413ff3da801c40fc6d631e2cd443695e3) --- source4/lib/replace/getaddrinfo.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getaddrinfo.h b/source4/lib/replace/getaddrinfo.h index ed678bd065..3e1fea8c4c 100644 --- a/source4/lib/replace/getaddrinfo.h +++ b/source4/lib/replace/getaddrinfo.h @@ -78,6 +78,10 @@ TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #endif #endif +#ifndef AI_ADDRCONFIG +#define AI_ADDRCONFIG 0x0020 +#endif + #ifndef NI_NUMERICHOST #define NI_NUMERICHOST 1 #endif -- cgit From 9f53479997da6768113c347e4e31374328f72835 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:02:33 +0200 Subject: r25687: Move #defined for getaddrinfo into network.h (as other defines). Allows RHEL4 compile to work. Jeremy. (cherry picked from commit 0ffdf4fdeea88c21880c8bf69d8db56fb49effa7) (This used to be commit facb811bb3c77a0b98089c283fe0707c5f486c88) --- source4/lib/replace/getaddrinfo.h | 80 ------------------------------ source4/lib/replace/system/network.h | 95 ++++++++++++++++++++++++++++++++++-- 2 files changed, 91 insertions(+), 84 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getaddrinfo.h b/source4/lib/replace/getaddrinfo.h index 3e1fea8c4c..47a62eb8b2 100644 --- a/source4/lib/replace/getaddrinfo.h +++ b/source4/lib/replace/getaddrinfo.h @@ -47,86 +47,6 @@ TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #ifndef GETADDRINFO_H #define GETADDRINFO_H - -/* Various macros that ought to be in , but might not be */ - -#ifndef EAI_FAIL -#define EAI_BADFLAGS (-1) -#define EAI_NONAME (-2) -#define EAI_AGAIN (-3) -#define EAI_FAIL (-4) -#define EAI_FAMILY (-6) -#define EAI_SOCKTYPE (-7) -#define EAI_SERVICE (-8) -#define EAI_MEMORY (-10) -#define EAI_SYSTEM (-11) -#endif /* !EAI_FAIL */ - -#ifndef AI_PASSIVE -#define AI_PASSIVE 0x0001 -#endif - -#ifndef AI_NUMERICHOST -/* - * some platforms don't support AI_NUMERICHOST; define as zero if using - * the system version of getaddrinfo... - */ -#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO) -#define AI_NUMERICHOST 0 -#else -#define AI_NUMERICHOST 0x0004 -#endif -#endif - -#ifndef AI_ADDRCONFIG -#define AI_ADDRCONFIG 0x0020 -#endif - -#ifndef NI_NUMERICHOST -#define NI_NUMERICHOST 1 -#endif - -#ifndef NI_NUMERICSERV -#define NI_NUMERICSERV 2 -#endif - -#ifndef NI_NOFQDN -#define NI_NOFQDN 4 -#endif - -#ifndef NI_NAMEREQD -#define NI_NAMEREQD 8 -#endif - -#ifndef NI_DGRAM -#define NI_DGRAM 16 -#endif - - -#ifndef NI_MAXHOST -#define NI_MAXHOST 1025 -#endif - -#ifndef NI_MAXSERV -#define NI_MAXSERV 32 -#endif - -#ifndef HAVE_STRUCT_ADDRINFO - -struct addrinfo -{ - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - size_t ai_addrlen; - struct sockaddr *ai_addr; - char *ai_canonname; - struct addrinfo *ai_next; -}; -#endif /* HAVE_STRUCT_ADDRINFO */ - - #ifndef HAVE_GETADDRINFO /* Rename private copies per comments above */ diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 0b0dbcb88d..61de2b728d 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -49,10 +49,6 @@ #include #endif -#if !defined(HAVE_GETADDRINFO) -#include "getaddrinfo.h" -#endif - /* * The next three defines are needed to access the IPTOS_* options * on some systems. @@ -104,6 +100,97 @@ int rep_inet_pton(int af, const char *src, void *dst); const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #endif +#if !defined(HAVE_GETADDRINFO) +#include "getaddrinfo.h" +#endif + +/* + * Some systems have getaddrinfo but not the + * defines needed to use it. + */ + +/* Various macros that ought to be in , but might not be */ + +#ifndef EAI_FAIL +#define EAI_BADFLAGS (-1) +#define EAI_NONAME (-2) +#define EAI_AGAIN (-3) +#define EAI_FAIL (-4) +#define EAI_FAMILY (-6) +#define EAI_SOCKTYPE (-7) +#define EAI_SERVICE (-8) +#define EAI_MEMORY (-10) +#define EAI_SYSTEM (-11) +#endif /* !EAI_FAIL */ + +#ifndef AI_PASSIVE +#define AI_PASSIVE 0x0001 +#endif + +#ifndef AI_CANONNAME +#define AI_CANONNAME 0x0002 +#endif + +#ifndef AI_NUMERICHOST +/* + * some platforms don't support AI_NUMERICHOST; define as zero if using + * the system version of getaddrinfo... + */ +#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO) +#define AI_NUMERICHOST 0 +#else +#define AI_NUMERICHOST 0x0004 +#endif +#endif + +#ifndef AI_ADDRCONFIG +#define AI_ADDRCONFIG 0x0020 +#endif + +#ifndef NI_NUMERICHOST +#define NI_NUMERICHOST 1 +#endif + +#ifndef NI_NUMERICSERV +#define NI_NUMERICSERV 2 +#endif + +#ifndef NI_NOFQDN +#define NI_NOFQDN 4 +#endif + +#ifndef NI_NAMEREQD +#define NI_NAMEREQD 8 +#endif + +#ifndef NI_DGRAM +#define NI_DGRAM 16 +#endif + + +#ifndef NI_MAXHOST +#define NI_MAXHOST 1025 +#endif + +#ifndef NI_MAXSERV +#define NI_MAXSERV 32 +#endif + +#ifndef HAVE_STRUCT_ADDRINFO + +struct addrinfo +{ + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + size_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; +#endif /* HAVE_STRUCT_ADDRINFO */ + /* * glibc on linux doesn't seem to have MSG_WAITALL * defined. I think the kernel has it though.. -- cgit From 1a766af41e9e3bdffc343098c2ec1b5018b33a26 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 18 Oct 2007 08:34:19 +0200 Subject: r25695: [libreplace] fix the standalone build of libreplace all configure results which are used in replace.h or any system/*.h should be in the in the libreplace *.m4 files! metze (This used to be commit 95462d614d68a93e85232e3a779f8bfa86fba4d1) --- source4/lib/replace/libreplace.m4 | 39 ++++++++++---------------------- source4/lib/replace/libreplace_macros.m4 | 23 ++++++++++++++++++- 2 files changed, 34 insertions(+), 28 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 4bdbf3a504..26b4c3636d 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -137,23 +137,20 @@ if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) fi -dnl test for struct addrinfo -AC_CACHE_CHECK([for struct addrinfo],samba_cv_HAVE_STRUCT_ADDRINFO,[ -AC_TRY_COMPILE([ +AC_HAVE_TYPE([socklen_t],[#include ]) +AC_HAVE_TYPE([sa_family_t],[#include ]) +AC_HAVE_TYPE([struct addrinfo], [#include ]) +AC_HAVE_TYPE([struct sockaddr], [#include ]) +AC_HAVE_TYPE([struct sockaddr_storage], [ +#include #include -#if STDC_HEADERS -#include -#include -#endif +#include +]) +AC_HAVE_TYPE([struct sockaddr_in6], [ #include -#include ], -[ -struct addrinfo ai; -], -samba_cv_HAVE_STRUCT_ADDRINFO=yes,samba_cv_HAVE_STRUCT_ADDRINFO=no)]) -if test x"$samba_cv_HAVE_STRUCT_ADDRINFO" = x"yes"; then - AC_DEFINE(HAVE_STRUCT_ADDRINFO,1,[Whether the system has struct addrinfo]) -fi +#include +#include +]) dnl test for getaddrinfo/getnameinfo AC_CACHE_CHECK([for getaddrinfo],samba_cv_HAVE_GETADDRINFO,[ @@ -185,18 +182,6 @@ if test x"$samba_cv_HAVE_GETADDRINFO" = x"yes"; then AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror]) fi - -dnl Provided by replace.c: -AC_TRY_COMPILE([ -#include -#if STDC_HEADERS -#include -#include -#endif -#include ], -[socklen_t foo;],, -[AC_DEFINE(socklen_t, int,[Socket length type])]) - AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index f262b9b6eb..da46f6734f 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -314,4 +314,25 @@ AC_DEFUN(LIBREPLACE_PROVIDE_HEADER, ) ]) - +dnl AC_HAVE_TYPE(TYPE,INCLUDES) +AC_DEFUN([AC_HAVE_TYPE], [ +AC_REQUIRE([AC_HEADER_STDC]) +cv=`echo "$1" | sed 'y%./+- %__p__%'` +AC_MSG_CHECKING(for $1) +AC_CACHE_VAL([ac_cv_type_$cv], +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +AC_INCLUDES_DEFAULT +$2]], +[[$1 foo;]])], +[eval "ac_cv_type_$cv=yes"], +[eval "ac_cv_type_$cv=no"]))dnl +ac_foo=`eval echo \\$ac_cv_type_$cv` +AC_MSG_RESULT($ac_foo) +if test "$ac_foo" = yes; then + ac_tr_hdr=HAVE_`echo $1 | sed 'y%abcdefghijklmnopqrstuvwxyz./- %ABCDEFGHIJKLMNOPQRSTUVWXYZ____%'` +if false; then + AC_CHECK_TYPES($1) +fi + AC_DEFINE_UNQUOTED($ac_tr_hdr, 1, [Define if you have type `$1']) +fi +]) -- cgit From 1cfd89c6aa50334b21fb8db16ab79a42679dd54b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 24 Oct 2007 12:53:34 +0200 Subject: r25713: [libreplace] include socket_wrapper.h after we have typedef'ed socklen_t metze (This used to be commit a3657a4e7175e35707e7a00330f6924833774253) --- source4/lib/replace/system/network.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 61de2b728d..79fe21405f 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -78,13 +78,6 @@ #include #endif -#ifdef SOCKET_WRAPPER -#ifndef SOCKET_WRAPPER_NOT_REPLACE -#define SOCKET_WRAPPER_REPLACE -#endif -#include "lib/socket_wrapper/socket_wrapper.h" -#endif - #ifdef REPLACE_INET_NTOA /* define is in "replace.h" */ char *rep_inet_ntoa(struct in_addr ip); @@ -241,4 +234,11 @@ typedef unsigned short int sa_family_t; #define HOST_NAME_MAX 256 #endif +#ifdef SOCKET_WRAPPER +#ifndef SOCKET_WRAPPER_NOT_REPLACE +#define SOCKET_WRAPPER_REPLACE +#endif +#include "lib/socket_wrapper/socket_wrapper.h" +#endif + #endif -- cgit From c01f61340bb1792d08e649708124f07ec19cc23d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 24 Oct 2007 12:55:40 +0200 Subject: r25714: [libreplace] move define of a constant to near to the others metze (This used to be commit 8bd2cf71bee1a08c3d420a330730434edbac5e28) --- source4/lib/replace/system/network.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 79fe21405f..1ac881e496 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -212,6 +212,10 @@ struct addrinfo #define INET6_ADDRSTRLEN 46 #endif +#ifndef HOST_NAME_MAX +#define HOST_NAME_MAX 256 +#endif + #ifndef HAVE_SOCKLEN_T typedef int socklen_t; #endif @@ -230,10 +234,6 @@ typedef unsigned short int sa_family_t; #endif #endif -#ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 256 -#endif - #ifdef SOCKET_WRAPPER #ifndef SOCKET_WRAPPER_NOT_REPLACE #define SOCKET_WRAPPER_REPLACE -- cgit From 582496f5d0e13e514e9c7cb02b138e730b8377d0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 24 Oct 2007 12:57:57 +0200 Subject: r25715: [libreplace] move definition of struct addrinfo so that it can use socklen_t metze (This used to be commit 12cec014c465a55974aedf44e0e782f5fb841088) --- source4/lib/replace/system/network.h | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 1ac881e496..774776dca3 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -169,21 +169,6 @@ const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #define NI_MAXSERV 32 #endif -#ifndef HAVE_STRUCT_ADDRINFO - -struct addrinfo -{ - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - size_t ai_addrlen; - struct sockaddr *ai_addr; - char *ai_canonname; - struct addrinfo *ai_next; -}; -#endif /* HAVE_STRUCT_ADDRINFO */ - /* * glibc on linux doesn't seem to have MSG_WAITALL * defined. I think the kernel has it though.. @@ -234,6 +219,19 @@ typedef unsigned short int sa_family_t; #endif #endif +#ifndef HAVE_STRUCT_ADDRINFO +struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + socklen_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; +#endif /* HAVE_STRUCT_ADDRINFO */ + #ifdef SOCKET_WRAPPER #ifndef SOCKET_WRAPPER_NOT_REPLACE #define SOCKET_WRAPPER_REPLACE -- cgit From 31569f1c881a735ef3db173ef57881540b0c5537 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 24 Oct 2007 13:01:03 +0200 Subject: r25718: [libreplace] if we replace types define the HAVE_ macro this is needed as heimdal's roken.h also tries to replace the types metze (This used to be commit 8b92b811015d0855efe3cf4c58cd08e3654f8e88) --- source4/lib/replace/system/network.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 774776dca3..44a1dcc8e1 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -202,10 +202,12 @@ const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #endif #ifndef HAVE_SOCKLEN_T +#define HAVE_SOCKLEN_T typedef int socklen_t; #endif #ifndef HAVE_SA_FAMILY_T +#define HAVE_SA_FAMILY_T typedef unsigned short int sa_family_t; #endif @@ -220,6 +222,7 @@ typedef unsigned short int sa_family_t; #endif #ifndef HAVE_STRUCT_ADDRINFO +#define HAVE_STRUCT_ADDRINFO struct addrinfo { int ai_flags; int ai_family; -- cgit From 88f6c5a1d2c337ffe7505e20b96a6b47dab1c063 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 25 Oct 2007 06:53:38 +0200 Subject: r25724: - include getaddrinfo.h after we have defined struct addrinfo - use rep_ instead of pg_ as prefix in getaddrinfo.[ch] - define HAVE_ macros when we replace functions metze (This used to be commit 57d5cf4b5fe8885b1375059aa143c9c71d2503b4) --- source4/lib/replace/getaddrinfo.c | 8 ++++---- source4/lib/replace/getaddrinfo.h | 23 +++++++++++++++-------- source4/lib/replace/system/network.h | 9 +++++---- 3 files changed, 24 insertions(+), 16 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getaddrinfo.c b/source4/lib/replace/getaddrinfo.c index 519c30066b..3cc1214b0e 100644 --- a/source4/lib/replace/getaddrinfo.c +++ b/source4/lib/replace/getaddrinfo.c @@ -253,7 +253,7 @@ static int getaddr_info_name(const char *node, * Bugs: - servname can only be a number, not text. */ -int getaddrinfo(const char *node, +int rep_getaddrinfo(const char *node, const char *service, const struct addrinfo * hintp, struct addrinfo ** res) @@ -315,7 +315,7 @@ int getaddrinfo(const char *node, } -void freeaddrinfo(struct addrinfo *res) +void rep_freeaddrinfo(struct addrinfo *res) { struct addrinfo *next = NULL; @@ -332,7 +332,7 @@ void freeaddrinfo(struct addrinfo *res) } -const char *gai_strerror(int errcode) +const char *rep_gai_strerror(int errcode) { #ifdef HAVE_HSTRERROR int hcode; @@ -468,7 +468,7 @@ static int getservicenameinfo(const struct sockaddr *sa, * * Bugs: - No IPv6 support. */ -int getnameinfo(const struct sockaddr *sa, socklen_t salen, +int rep_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node, size_t nodelen, char *service, size_t servicelen, int flags) { diff --git a/source4/lib/replace/getaddrinfo.h b/source4/lib/replace/getaddrinfo.h index 47a62eb8b2..dddd699b62 100644 --- a/source4/lib/replace/getaddrinfo.h +++ b/source4/lib/replace/getaddrinfo.h @@ -37,6 +37,9 @@ TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * struct definitions needed to call it. To avoid conflict with the libbind * definition in such cases, we rename our routines to pg_xxx() via macros. * + +in lib/replace we use rep_xxx() + * This code will also work on platforms where struct addrinfo is defined * in the system headers but no getaddrinfo() can be located. * @@ -53,28 +56,32 @@ TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #ifdef getaddrinfo #undef getaddrinfo #endif -#define getaddrinfo pg_getaddrinfo +#define getaddrinfo rep_getaddrinfo +#define HAVE_GETADDRINFO #ifdef freeaddrinfo #undef freeaddrinfo #endif -#define freeaddrinfo pg_freeaddrinfo +#define freeaddrinfo rep_freeaddrinfo +#define HAVE_FREEADDRINFO #ifdef gai_strerror #undef gai_strerror #endif -#define gai_strerror pg_gai_strerror +#define gai_strerror rep_gai_strerror +#define HAVE_GAI_STRERROR #ifdef getnameinfo #undef getnameinfo #endif -#define getnameinfo pg_getnameinfo +#define getnameinfo rep_getnameinfo +#define HAVE_GETNAMEINFO -extern int getaddrinfo(const char *node, const char *service, +extern int rep_getaddrinfo(const char *node, const char *service, const struct addrinfo * hints, struct addrinfo ** res); -extern void freeaddrinfo(struct addrinfo * res); -extern const char *gai_strerror(int errcode); -extern int getnameinfo(const struct sockaddr * sa, socklen_t salen, +extern void rep_freeaddrinfo(struct addrinfo * res); +extern const char *rep_gai_strerror(int errcode); +extern int rep_getnameinfo(const struct sockaddr * sa, socklen_t salen, char *node, size_t nodelen, char *service, size_t servicelen, int flags); #endif /* HAVE_GETADDRINFO */ diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 44a1dcc8e1..5de363f134 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -93,10 +93,6 @@ int rep_inet_pton(int af, const char *src, void *dst); const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #endif -#if !defined(HAVE_GETADDRINFO) -#include "getaddrinfo.h" -#endif - /* * Some systems have getaddrinfo but not the * defines needed to use it. @@ -212,6 +208,7 @@ typedef unsigned short int sa_family_t; #endif #ifndef HAVE_STRUCT_SOCKADDR_STORAGE +#define HAVE_STRUCT_SOCKADDR_STORAGE #ifdef HAVE_STRUCT_SOCKADDR_IN6 #define sockaddr_storage sockaddr_in6 #define ss_family sin6_family @@ -235,6 +232,10 @@ struct addrinfo { }; #endif /* HAVE_STRUCT_ADDRINFO */ +#if !defined(HAVE_GETADDRINFO) +#include "getaddrinfo.h" +#endif + #ifdef SOCKET_WRAPPER #ifndef SOCKET_WRAPPER_NOT_REPLACE #define SOCKET_WRAPPER_REPLACE -- cgit From 79affaf37a29d6c9c30cc7674cfad97e67bc1867 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 25 Oct 2007 06:56:27 +0200 Subject: r25725: merge commit bc9008aa1dcb66890795f0ff2d3046da7df867d9 from v3-2-test: Author: Jeremy Allison AuthorDate: Wed Oct 24 14:40:24 2007 -0700 We do support name lookups for host and service in our replacement code - remove the restrictions from the original Postgres code. Jeremy. (This used to be commit 25a892f2ad1b281869779686ca23f2ed29b46a5c) --- source4/lib/replace/getaddrinfo.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getaddrinfo.c b/source4/lib/replace/getaddrinfo.c index 3cc1214b0e..063bacd026 100644 --- a/source4/lib/replace/getaddrinfo.c +++ b/source4/lib/replace/getaddrinfo.c @@ -486,11 +486,6 @@ int rep_getnameinfo(const struct sockaddr *sa, socklen_t salen, return EAI_FAIL; } - /* We don't support those. */ - if ((node && !(flags & NI_NUMERICHOST)) - || (service && !(flags & NI_NUMERICSERV))) - return EAI_FAIL; - if (node) { return gethostnameinfo(sa, node, nodelen, flags); } -- cgit From 805eb06209e5ad5ff57cb41527b5b1642772f802 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 25 Oct 2007 08:43:00 +0200 Subject: r25726: [libreplace] move and fix getaddrinfo configure checks - move getaddrinfo check into getaddrinfo.m4 - add getaddrinfo.o to LIBREPLACEOBJ so that we really build the replacements metze (This used to be commit b594d9c9fa86249e3d3988702a2333460cd70436) --- source4/lib/replace/getaddrinfo.m4 | 32 ++++++++++++++++++++++++++++++++ source4/lib/replace/libreplace.m4 | 31 +------------------------------ 2 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 source4/lib/replace/getaddrinfo.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getaddrinfo.m4 b/source4/lib/replace/getaddrinfo.m4 new file mode 100644 index 0000000000..92620aa3d0 --- /dev/null +++ b/source4/lib/replace/getaddrinfo.m4 @@ -0,0 +1,32 @@ +dnl test for getaddrinfo/getnameinfo +AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[ +AC_TRY_COMPILE([ +#include +#if STDC_HEADERS +#include +#include +#endif +#include +#include ], +[ +struct sockaddr sa; +struct addrinfo *ai = NULL; +int ret = getaddrinfo(NULL, NULL, NULL, &ai); +if (ret != 0) { + const char *es = gai_strerror(ret); +} +freeaddrinfo(ai); +ret = getnameinfo(&sa, sizeof(sa), + NULL, 0, + NULL, 0, 0); + +], +libreplace_cv_HAVE_GETADDRINFO=yes,libreplace_cv_HAVE_GETADDRINFO=no)]) +if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then + AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo]) + AC_DEFINE(HAVE_GETNAMEINFO,1,[Whether the system has getnameinfo]) + AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo]) + AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror]) +else + LIBREPLACEOBJ="${LIBREPLACEOBJ} getaddrinfo.o" +fi diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 26b4c3636d..dd7dbf4e47 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -152,36 +152,6 @@ AC_HAVE_TYPE([struct sockaddr_in6], [ #include ]) -dnl test for getaddrinfo/getnameinfo -AC_CACHE_CHECK([for getaddrinfo],samba_cv_HAVE_GETADDRINFO,[ -AC_TRY_COMPILE([ -#include -#if STDC_HEADERS -#include -#include -#endif -#include -#include ], -[ -struct sockaddr sa; -struct addrinfo *ai = NULL; -int ret = getaddrinfo(NULL, NULL, NULL, &ai); -if (ret != 0) { - const char *es = gai_strerror(ret); -} -freeaddrinfo(ai); -ret = getnameinfo(&sa, sizeof(sa), - NULL, 0, - NULL, 0, 0); - -], -samba_cv_HAVE_GETADDRINFO=yes,samba_cv_HAVE_GETADDRINFO=no)]) -if test x"$samba_cv_HAVE_GETADDRINFO" = x"yes"; then - AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo and getnameinfo]) - AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo]) - AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror]) -fi - AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) @@ -358,6 +328,7 @@ m4_include(win32.m4) m4_include(timegm.m4) m4_include(inet_ntop.m4) m4_include(inet_pton.m4) +m4_include(getaddrinfo.m4) m4_include(repdir.m4) AC_CHECK_FUNCS([syslog memset memcpy],,[AC_MSG_ERROR([Required function not found])]) -- cgit From 74a2b05793851de3bcc12980221e238da5310d8b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 25 Oct 2007 09:16:11 +0200 Subject: r25728: [libreplace] define AI_NUMERICSERV as it's used in getaddrinfo.c metze (This used to be commit 5648c8a0de7482a28a5b95410c083ac87577d482) --- source4/lib/replace/system/network.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 5de363f134..c7b499a932 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -136,6 +136,17 @@ const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #define AI_ADDRCONFIG 0x0020 #endif +#ifndef AI_NUMERICSERV +/* + * logic copied from AI_NUMERICHOST + */ +#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO) +#define AI_NUMERICSERV 0 +#else +#define AI_NUMERICSERV 0x0400 +#endif +#endif + #ifndef NI_NUMERICHOST #define NI_NUMERICHOST 1 #endif -- cgit From 4d354fd58374df6ab5ae52e6cd61988377ceddb2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 5 Nov 2007 15:45:08 +0100 Subject: r25838: libreplace: include nss_wrapper.h if NSS_WRAPPER is defined metze (This used to be commit 17f9189fb4b34dbc08f6aded6b0c81ee8eb07a9f) --- source4/lib/replace/system/passwd.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/passwd.h b/source4/lib/replace/system/passwd.h index 53d35e7b87..513947c85d 100644 --- a/source4/lib/replace/system/passwd.h +++ b/source4/lib/replace/system/passwd.h @@ -93,4 +93,11 @@ char *rep_getpass(const char *prompt); #define ULTRIX_AUTH 1 #endif +#ifdef NSS_WRAPPER +#ifndef NSS_WRAPPER_NOT_REPLACE +#define NSS_WRAPPER_REPLACE +#endif +#include "lib/nss_wrapper/nss_wrapper.h" +#endif + #endif -- cgit From 48ed51e61ec4378a0c3d4063a28d7247813548dc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Nov 2007 01:05:19 +0100 Subject: r25846: Add configure test for -Wl,--export-dynamic. (This used to be commit f67040d2a0cb8723f1bf0e9a9d90a821b38697b1) --- source4/lib/replace/libreplace.m4 | 1 + source4/lib/replace/libreplace_ld.m4 | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 source4/lib/replace/libreplace_ld.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index dd7dbf4e47..a02167ed17 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -355,5 +355,6 @@ CFLAGS="$CFLAGS -I$libreplacedir" ]) m4_include(libreplace_cc.m4) +m4_include(libreplace_ld.m4) m4_include(libreplace_macros.m4) m4_include(autoconf-2.60.m4) diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 new file mode 100644 index 0000000000..8d7d3d7ebb --- /dev/null +++ b/source4/lib/replace/libreplace_ld.m4 @@ -0,0 +1,10 @@ +AC_DEFUN([AC_LD_EXPORT_DYNAMIC], +[ +saved_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS -Wl,--export-dynamic" +AC_LINK_IFELSE([ int main() { return 0; } ], +[ LD_EXPORT_DYNAMIC=-Wl,--export-dynamic ], +[ LD_EXPORT_DYNAMIC= ]) +AC_SUBST(LD_EXPORT_DYNAMIC) +LDFLAGS="$saved_LDFLAGS" +]) -- cgit From 6e561c7f7de2e1489033da40472311147a46c1f9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Nov 2007 02:16:55 +0100 Subject: r25850: Add macro for picflag. (This used to be commit 9ebc6f2d17349b214618d65b29826867796c12ce) --- source4/lib/replace/libreplace_ld.m4 | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 8d7d3d7ebb..d3d3f9464f 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -8,3 +8,58 @@ AC_LINK_IFELSE([ int main() { return 0; } ], AC_SUBST(LD_EXPORT_DYNAMIC) LDFLAGS="$saved_LDFLAGS" ]) + +AC_DEFUN([AC_LD_PICFLAG], +[ +case "$host_os" in + *linux*) + PICFLAG="-fPIC" + ;; + *solaris*) + if test "${GCC}" = "yes"; then + PICFLAG="-fPIC" + else + PICFLAG="-KPIC" + fi + ;; + *sunos*) + PICFLAG="-KPIC" # Is this correct for SunOS + ;; + *netbsd* | *freebsd* | *dragonfly* ) + PICFLAG="-fPIC -DPIC" + ;; + *openbsd*) + PICFLAG="-fPIC" + ;; + *irix*) + if test "${GCC}" = "yes"; then + PICFLAG="-fPIC" + else + PICFLAG="-KPIC" + fi + ;; + *aix*) + # as AIX code is always position independent... + PICFLAG="-O2" + ;; + *hpux*) + if test $ac_cv_prog_cc_Ae = yes; then + PICFLAG="+z +ESnolit" + elif test "${GCC}" = "yes"; then + PICFLAG="-fPIC" + fi + if test "$host_cpu" = "ia64"; then + PICFLAG="+z" + fi + ;; + *osf*) + PICFLAG="-fPIC" + ;; + *unixware*) + PICFLAG="-KPIC" + ;; + *darwin*) + ;; +esac +AC_SUBST(PICFLAG) +]) -- cgit From dd66e34d416a95c1a1d36b032c72f781b14a13b7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Nov 2007 02:17:05 +0100 Subject: r25851: Move system-specific ldflags checks to libreplace so they can be used by ldb. (This used to be commit d28c8b822e7b571f24542409376bba8701eeef79) --- source4/lib/replace/libreplace_ld.m4 | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index d3d3f9464f..07dd2db231 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -63,3 +63,41 @@ case "$host_os" in esac AC_SUBST(PICFLAG) ]) + +AC_DEFUN([AC_LD_SHLDFLAGS], +[ + SHLD_FLAGS="-shared" + + case "$host_os" in + *linux*) + SHLD_FLAGS="-shared -Wl,-Bsymbolic" + ;; + *solaris*) + SHLD_FLAGS="-G" + if test "${GCC}" = "no"; then + ## ${CFLAGS} added for building 64-bit shared + ## libs using Sun's Compiler + SHLD_FLAGS="-G \${CFLAGS}" + fi + ;; + *sunos*) + SHLD_FLAGS="-G" + ;; + *irix*) + SHLD_FLAGS="-set_version sgi1.0 -shared" + ;; + *aix*) + SHLD_FLAGS="-Wl,-G,-bexpall,-bbigtoc" + ;; + *hpux*) + if test $ac_cv_prog_cc_Ae = yes; then + SHLD_FLAGS="-b -Wl,-B,symbolic,-b,-z" + fi + ;; + *darwin*) + SHLD_FLAGS="-bundle -flat_namespace -undefined suppress" + ;; + esac + + AC_SUBST(SHLD_FLAGS) +]) -- cgit From 26c3cad60f4c04231efb7ff67ce77c5e3d701b58 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Nov 2007 02:35:46 +0100 Subject: r25852: Move SHLIBEXT determination into a test as well. (This used to be commit aaaed5edc06f3055794e55a8038dbbdac47ce5b6) --- source4/lib/replace/libreplace_ld.m4 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 07dd2db231..7f85fb4ccc 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -101,3 +101,21 @@ AC_DEFUN([AC_LD_SHLDFLAGS], AC_SUBST(SHLD_FLAGS) ]) + +AC_DEFUN([AC_LD_SHLIBEXT], +[ + SHLIBEXT="so" + case "$host_os" in + *hpux*) + if test "$host_cpu" = "ia64"; then + SHLIBEXT="so" + else + SHLIBEXT="sl" + fi + ;; + *darwin*) + SHLIBEXT="dylib" + ;; + esac + AC_SUBST(SHLIBEXT) +]) -- cgit From 145bc26a0f58943cfa41fe2955fc7258e6bb6f54 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Nov 2007 03:43:50 +0100 Subject: r25855: Check for HPUX dl functions. (This used to be commit 478b5ac8d92a23a32349bedfe7c6caf98b67fb39) --- source4/lib/replace/dlfcn.m4 | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.m4 b/source4/lib/replace/dlfcn.m4 index c5b7597d7a..42f56f26be 100644 --- a/source4/lib/replace/dlfcn.m4 +++ b/source4/lib/replace/dlfcn.m4 @@ -8,6 +8,11 @@ AC_SEARCH_LIBS(dlopen, dl) AC_CHECK_HEADERS(dlfcn.h) AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_cv_dlfcn=yes]) +libreplace_cv_shl=no +AC_SEARCH_LIBS(shl_load, sl) +AC_CHECK_HEADERS(dl.h) +AC_CHECK_FUNCS([shl_load shl_unload shl_findsym],[],[libreplace_cv_shl=yes]) + AC_VERIFY_C_PROTOTYPE([void *dlopen(const char* filename, unsigned int flags)], [ return 0; -- cgit From 3d6d80daba81a6cea396798dfe801c8d36c4685f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Nov 2007 04:26:52 +0100 Subject: r25859: Wrap native HPUX functions in dl implementation. (This used to be commit bf1685faa1c941d3ca56b29a1e15b8a134d02068) --- source4/lib/replace/dlfcn.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c index 46aaaa4087..42848848e8 100644 --- a/source4/lib/replace/dlfcn.c +++ b/source4/lib/replace/dlfcn.c @@ -23,6 +23,9 @@ */ #include "replace.h" +#ifdef HAVE_DL_H +#include +#endif #ifndef HAVE_DLOPEN #ifdef DLOPEN_TAKES_UNSIGNED_FLAGS @@ -31,13 +34,22 @@ void *rep_dlopen(const char *name, unsigned int flags) void *rep_dlopen(const char *name, int flags) #endif { +#ifdef HAVE_SHL_LOAD + return (void *)shl_load(name, flags, 0); +#else return NULL; +#endif } #endif #ifndef HAVE_DLSYM void *rep_dlsym(void *handle, const char *symbol) { +#ifdef HAVE_SHL_FINDSYM + void *sym_addr; + if (!shl_findsym((shl_t *)&handle, symbol, TYPE_UNDEFINED, &sym_addr)) + return sym_addr; +#endif return NULL; } #endif @@ -52,6 +64,10 @@ char *rep_dlerror(void) #ifndef HAVE_DLCLOSE int rep_dlclose(void *handle) { +#ifdef HAVE_SHL_CLOSE + return shl_unload((shl_t)handle); +#else return 0; +#endif } #endif -- cgit From 0cab8cc79f47ea0deded54598d2106f7bbe44a99 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Nov 2007 04:26:57 +0100 Subject: r25860: Remove flag that causes problems on some hosts. (This used to be commit 85b332650031b2969f79e6ca85e5d6d10983da91) --- source4/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 7f85fb4ccc..79367ba9db 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -84,7 +84,7 @@ AC_DEFUN([AC_LD_SHLDFLAGS], SHLD_FLAGS="-G" ;; *irix*) - SHLD_FLAGS="-set_version sgi1.0 -shared" + SHLD_FLAGS="-shared" ;; *aix*) SHLD_FLAGS="-Wl,-G,-bexpall,-bbigtoc" -- cgit From eea596951d7106c6ac0326e51b707ce1295db576 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Nov 2007 04:59:50 +0100 Subject: r25861: Fix export dynamic for HPUX. (This used to be commit 45ccf09bf96e915380b30150a701735318b67aa0) --- source4/lib/replace/libreplace_ld.m4 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 79367ba9db..cc5cefae60 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -1,10 +1,18 @@ AC_DEFUN([AC_LD_EXPORT_DYNAMIC], [ saved_LDFLAGS="$LDFLAGS" -LDFLAGS="$LDFLAGS -Wl,--export-dynamic" -AC_LINK_IFELSE([ int main() { return 0; } ], -[ LD_EXPORT_DYNAMIC=-Wl,--export-dynamic ], -[ LD_EXPORT_DYNAMIC= ]) +if AC_TRY_COMMAND([${CC-cc} $CFLAGS -Wl,--version 2>&1 | grep "GNU ld" >/dev/null]); then + LD_EXPORT_DYNAMIC="-Wl,-export-dynamic" +else + case "$host_os" in + hpux* ) + LD_EXPORT_DYNAMIC="-Wl,-E" + ;; + * ) + LD_EXPORT_DYNAMIC="" + ;; + esac +fi AC_SUBST(LD_EXPORT_DYNAMIC) LDFLAGS="$saved_LDFLAGS" ]) -- cgit From 9ed91eabdd9311f01c2595a60e4b05a5869cc699 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 6 Nov 2007 06:54:49 +0100 Subject: r25863: libreplace: we need include before nss_wrapper.h metze (This used to be commit a16f0e3cdbb9fb1238e25af8bb911c27b839c89b) --- source4/lib/replace/system/passwd.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/passwd.h b/source4/lib/replace/system/passwd.h index 513947c85d..36fca7b4f8 100644 --- a/source4/lib/replace/system/passwd.h +++ b/source4/lib/replace/system/passwd.h @@ -27,6 +27,9 @@ */ +/* this needs to be included before nss_wrapper.h on some systems */ +#include + #ifdef HAVE_PWD_H #include #endif -- cgit From 046cd2512e1a3a6d1093829667df6b12eaaf1707 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 6 Nov 2007 07:01:17 +0100 Subject: r25864: libreplace: we should only have one location where we check for required functions metze (This used to be commit 8748516d1668c66663ded50ff28a8d32f1720175) --- source4/lib/replace/libreplace.m4 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index a02167ed17..c10a4b2381 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -280,9 +280,6 @@ AC_TRY_CPP([ eprintf("bla", "bar"); ], AC_DEFINE(HAVE__VA_ARGS__MACRO, 1, [Whether the __VA_ARGS__ macro is available])) -# Check prerequisites -AC_CHECK_FUNCS([memset printf syslog], [], - [ AC_MSG_ERROR([Required function not found])]) AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ AC_TRY_COMPILE([ @@ -331,7 +328,7 @@ m4_include(inet_pton.m4) m4_include(getaddrinfo.m4) m4_include(repdir.m4) -AC_CHECK_FUNCS([syslog memset memcpy],,[AC_MSG_ERROR([Required function not found])]) +AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])]) echo "LIBREPLACE_BROKEN_CHECKS: END" ]) dnl end AC_LIBREPLACE_BROKEN_CHECKS -- cgit From 29598b83e0a39cc0a52252e924733f23d5a21afa Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 6 Nov 2007 07:26:12 +0100 Subject: r25865: libreplace: check for nss passwd|group get*_r functions metze (This used to be commit 98095b34257847b2fbb5efe343c3630a28170692) --- source4/lib/replace/system/config.m4 | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 index 74278787e7..2b2f76a8e6 100644 --- a/source4/lib/replace/system/config.m4 +++ b/source4/lib/replace/system/config.m4 @@ -18,6 +18,8 @@ AC_CHECK_HEADERS(sys/capability.h) # passwd AC_CHECK_HEADERS(grp.h sys/id.h compat.h shadow.h sys/priv.h pwd.h sys/security.h) +AC_CHECK_FUNCS(getpwnam_r getpwuid_r getpwent_r) +AC_CHECK_FUNCS(getgrnam_r getgrgid_r getgrent_r) # locale AC_CHECK_HEADERS(ctype.h locale.h) -- cgit From 49cb694041ac726bbff027bc6d6a9ce0ac5e15f9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 6 Nov 2007 09:15:11 +0100 Subject: r25867: libreplace: solaris has different prototypes for getpwent_r and getgrent_r metze (This used to be commit 44250ac6f987ba98e1efe8cd81b4e7eaa8017ed0) --- source4/lib/replace/system/config.m4 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 index 2b2f76a8e6..6500535982 100644 --- a/source4/lib/replace/system/config.m4 +++ b/source4/lib/replace/system/config.m4 @@ -19,7 +19,39 @@ AC_CHECK_HEADERS(sys/capability.h) # passwd AC_CHECK_HEADERS(grp.h sys/id.h compat.h shadow.h sys/priv.h pwd.h sys/security.h) AC_CHECK_FUNCS(getpwnam_r getpwuid_r getpwent_r) +AC_HAVE_DECL(getpwent_r, [ + #include + #include + ]) +AC_VERIFY_C_PROTOTYPE([struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)], + [ + #ifndef HAVE_GETPWENT_R_DECL + #error missing getpwent_r prototype + #endif + return NULL; + ],[ + AC_DEFINE(SOLARIS_GETPWENT_R, 1, [getpwent_r solaris function prototype]) + ],[],[ + #include + #include + ]) AC_CHECK_FUNCS(getgrnam_r getgrgid_r getgrent_r) +AC_HAVE_DECL(getgrent_r, [ + #include + #include + ]) +AC_VERIFY_C_PROTOTYPE([struct group *getgrent_r(struct group *src, char *buf, int buflen)], + [ + #ifndef HAVE_GETGRENT_R_DECL + #error missing getgrent_r prototype + #endif + return NULL; + ],[ + AC_DEFINE(SOLARIS_GETGRENT_R, 1, [getgrent_r solaris function prototype]) + ],[],[ + #include + #include + ]) # locale AC_CHECK_HEADERS(ctype.h locale.h) -- cgit From 37f6b948b7598ca8c532154f3c9833ea0965e887 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 6 Nov 2007 10:40:07 +0100 Subject: r25870: libreplace: AC_VERIFY_C_PROTOTYPE() needs AC_LANG_SOURCE() to bring in confdefs.h metze (This used to be commit c6b6466c33ffab2b59e1a275922b6f3a7f2af98c) --- source4/lib/replace/libreplace_macros.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index da46f6734f..92fecd3db8 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -291,14 +291,14 @@ dnl check if the prototype in the header matches the given one dnl AC_VERIFY_C_PROTOTYPE(prototype,functionbody,[IF-TRUE].[IF-FALSE],[extraheaders]) AC_DEFUN(AC_VERIFY_C_PROTOTYPE, [AC_CACHE_CHECK([for prototype $1], AS_TR_SH([ac_cv_c_prototype_$1]), - AC_COMPILE_IFELSE([ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ AC_INCLUDES_DEFAULT $5 $1 { $2 } - ],[ + ])],[ AS_TR_SH([ac_cv_c_prototype_$1])=yes ],[ AS_TR_SH([ac_cv_c_prototype_$1])=no -- cgit From a564ca1c739360b0933a2eab234378e4ec485b60 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Nov 2007 14:51:42 +0100 Subject: r25875: Try to fix the build on some HPUX machines. (This used to be commit 773a7cf234e08e05bb89072c42353e44915f8146) --- source4/lib/replace/libreplace_ld.m4 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index cc5cefae60..183c302aae 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -98,9 +98,7 @@ AC_DEFUN([AC_LD_SHLDFLAGS], SHLD_FLAGS="-Wl,-G,-bexpall,-bbigtoc" ;; *hpux*) - if test $ac_cv_prog_cc_Ae = yes; then - SHLD_FLAGS="-b -Wl,-B,symbolic,-b,-z" - fi + SHLD_FLAGS="-b -Wl,-B,symbolic,-b,-z" ;; *darwin*) SHLD_FLAGS="-bundle -flat_namespace -undefined suppress" -- cgit From 414e5eca2e1495916f4a52789a6bee63d2f1ab6d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Nov 2007 16:23:18 +0100 Subject: r25877: Add libreplace macro for soname flags. (This used to be commit 25aa875119622679881cd0e1b3b9dff8d2cf03ee) --- source4/lib/replace/libreplace_ld.m4 | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 183c302aae..c276a7a864 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -125,3 +125,44 @@ AC_DEFUN([AC_LD_SHLIBEXT], esac AC_SUBST(SHLIBEXT) ]) + +AC_DEFUN([AC_LD_SONAMEFLAG], +[ + AC_SUBST(SONAMEFLAG) + SONAMEFLAG="" + case "$host_os" in + *linux*) + SONAMEFLAG="-Wl,-soname=" + ;; + *solaris*) + SONAMEFLAG="-h " + if test "${GCC}" = "yes"; then + SONAMEFLAG="-Wl,-soname=" + fi + ;; + *sunos*) + SONAMEFLAG="-Wl,-h," + ;; + *netbsd* | *freebsd* | *dragonfly* ) + SONAMEFLAG="-Wl,-soname," + ;; + *openbsd*) + SONAMEFLAG="-Wl,-soname," + ;; + *irix*) + SONAMEFLAG="-soname " + ;; + *hpux*) + SONAMEFLAG="-Wl,+h " + ;; + *osf*) + SONAMEFLAG="-Wl,-soname," + ;; + *unixware*) + SONAMEFLAG="-Wl,-soname," + ;; + *darwin*) + SONAMEFLAG="-Wl,-soname," + ;; + esac +]) -- cgit From 2ca86c77699a50f7861095ad8c1c94cba8f20e01 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 6 Nov 2007 18:25:34 +0100 Subject: r25880: Try to get some more flags right. (This used to be commit bbc36fd3f693480e3ea01c5c9e858008a4f3c229) --- source4/lib/replace/libreplace_ld.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index c276a7a864..8147e692ec 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -8,7 +8,7 @@ else hpux* ) LD_EXPORT_DYNAMIC="-Wl,-E" ;; - * ) + *) LD_EXPORT_DYNAMIC="" ;; esac @@ -101,7 +101,7 @@ AC_DEFUN([AC_LD_SHLDFLAGS], SHLD_FLAGS="-b -Wl,-B,symbolic,-b,-z" ;; *darwin*) - SHLD_FLAGS="-bundle -flat_namespace -undefined suppress" + SHLD_FLAGS="-dynamiclib" ;; esac @@ -150,7 +150,7 @@ AC_DEFUN([AC_LD_SONAMEFLAG], SONAMEFLAG="-Wl,-soname," ;; *irix*) - SONAMEFLAG="-soname " + SONAMEFLAG="-Wl,-soname," ;; *hpux*) SONAMEFLAG="-Wl,+h " @@ -162,7 +162,7 @@ AC_DEFUN([AC_LD_SONAMEFLAG], SONAMEFLAG="-Wl,-soname," ;; *darwin*) - SONAMEFLAG="-Wl,-soname," + SONAMEFLAG="-install_name " ;; esac ]) -- cgit From 2109bf0515962997a6f8002a6a6e5124ce61a60b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 7 Nov 2007 01:32:17 +0100 Subject: r25886: Try to fix building dso's on hpux with gcc (This used to be commit 146c5226e61235a55155ef4493191a6c5eddea3f) --- source4/lib/replace/libreplace_ld.m4 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 8147e692ec..fd85ef9fc4 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -98,7 +98,11 @@ AC_DEFUN([AC_LD_SHLDFLAGS], SHLD_FLAGS="-Wl,-G,-bexpall,-bbigtoc" ;; *hpux*) - SHLD_FLAGS="-b -Wl,-B,symbolic,-b,-z" + if test "${GCC}" = "yes"; then + SHLD_FLAGS="-shared" + else + SHLD_FLAGS="-b" + fi ;; *darwin*) SHLD_FLAGS="-dynamiclib" -- cgit From 2cb22d93ae0eef86a4bcf0fe5f7fb138e43db880 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 7 Nov 2007 06:59:02 +0100 Subject: r25892: Keep the tdb code in sync between 3.2.x and 4.0. Add in the alarm fix to allow locks to exit on alarm signal. Sync up the changes in tools. Jeremy. (This used to be commit cb6c663fa8818f49cc36f196bb5f4dea47edd69e) --- source4/lib/replace/replace.h | 4 ++++ source4/lib/replace/system/wait.h | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index e42d5ff168..55ed2e9570 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -452,6 +452,10 @@ typedef int bool; #define MAX(a,b) ((a)>(b)?(a):(b)) #endif +#if !defined(HAVE_VOLATILE) +#define volatile +#endif + /** this is a warning hack. The idea is to use this everywhere that we get the "discarding const" warning from gcc. That doesn't actually diff --git a/source4/lib/replace/system/wait.h b/source4/lib/replace/system/wait.h index de94cf09d5..5784b1ae92 100644 --- a/source4/lib/replace/system/wait.h +++ b/source4/lib/replace/system/wait.h @@ -48,4 +48,8 @@ #define SA_RESETHAND SA_ONESHOT #endif +#if !defined(HAVE_SIG_ATOMIC_T_TYPE) +typedef int sig_atomic_t; +#endif + #endif -- cgit From 92897b1153ff5b46a3fe2980b2be3e4e5f9b616a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 Nov 2007 11:17:22 +0100 Subject: r25906: libreplace: we need to link to make sure the functions are available metze (This used to be commit 895d2644fbd72b9770460d6628fa6b09963967e7) --- source4/lib/replace/getaddrinfo.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getaddrinfo.m4 b/source4/lib/replace/getaddrinfo.m4 index 92620aa3d0..bc6e69ea56 100644 --- a/source4/lib/replace/getaddrinfo.m4 +++ b/source4/lib/replace/getaddrinfo.m4 @@ -1,6 +1,6 @@ dnl test for getaddrinfo/getnameinfo AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[ -AC_TRY_COMPILE([ +AC_TRY_LINK([ #include #if STDC_HEADERS #include -- cgit From a4a7447f130d144317e9b7d110ea20f046cd708f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 08:22:21 +0100 Subject: r25909: Fix the snprintf checks, and fix a typo in pointer indirection. These fixes are needed for a working getaddrinfo etc. replacement. Fixes from Wayne Davison from rsync. Jeremy. from v3-2-test commit 494bf6293bedbda4b10aa2eae452377b8130cd01 (This used to be commit e562832ad19e8c3a0380759a22b0267e365ecc2e) --- source4/lib/replace/getaddrinfo.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getaddrinfo.c b/source4/lib/replace/getaddrinfo.c index 063bacd026..c5cd52be93 100644 --- a/source4/lib/replace/getaddrinfo.c +++ b/source4/lib/replace/getaddrinfo.c @@ -222,7 +222,7 @@ static int getaddr_info_name(const char *node, } for(pptr = hp->h_addr_list; *pptr; pptr++) { - struct in_addr ip = *(struct in_addr *)pptr; + struct in_addr ip = *(struct in_addr *)*pptr; struct addrinfo *ai = alloc_entry(hints, ip, port); if (!ai) { @@ -407,7 +407,7 @@ static int gethostnameinfo(const struct sockaddr *sa, if (ret == 0) { /* Name looked up successfully. */ ret = snprintf(node, nodelen, "%s", hp->h_name); - if (ret == -1 || ret > nodelen) { + if (ret < 0 || (size_t)ret >= nodelen) { return EAI_MEMORY; } if (flags & NI_NOFQDN) { @@ -428,7 +428,7 @@ static int gethostnameinfo(const struct sockaddr *sa, } p = inet_ntoa(((struct sockaddr_in *)sa)->sin_addr); ret = snprintf(node, nodelen, "%s", p); - if (ret == -1 || ret > nodelen) { + if (ret < 0 || (size_t)ret >= nodelen) { return EAI_MEMORY; } return 0; @@ -449,7 +449,7 @@ static int getservicenameinfo(const struct sockaddr *sa, if (se && se->s_name) { /* Service name looked up successfully. */ ret = snprintf(service, servicelen, "%s", se->s_name); - if (ret == -1 || ret > servicelen) { + if (ret < 0 || (size_t)ret >= servicelen) { return EAI_MEMORY; } return 0; @@ -457,7 +457,7 @@ static int getservicenameinfo(const struct sockaddr *sa, /* Otherwise just fall into the numeric service code... */ } ret = snprintf(service, servicelen, "%d", port); - if (ret == -1 || ret > servicelen) { + if (ret < 0 || (size_t)ret >= servicelen) { return EAI_MEMORY; } return 0; -- cgit From 319ecac5b12dd183b657cb6f5bee2dbbdd013e35 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 08:24:36 +0100 Subject: r25910: Try and fix the Solaris build by adding a missing define (from Jerry). Jeremy merge from v3-2-test commit a68bbea0d42cc64b9fa731ab2a1da82ef30937c6 (This used to be commit b833dce5e6d6475a04538d9754b9b0bfeb5915e4) --- source4/lib/replace/system/network.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index c7b499a932..d3ae2bf398 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -247,6 +247,11 @@ struct addrinfo { #include "getaddrinfo.h" #endif +/* Needed for some systems that don't define it (Solaris). */ +#ifndef ifr_netmask +#define ifr_netmask ifr_addrs +#endif + #ifdef SOCKET_WRAPPER #ifndef SOCKET_WRAPPER_NOT_REPLACE #define SOCKET_WRAPPER_REPLACE -- cgit From 2baec5a557d64e6df3518923f05a87aa94bdb8aa Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 08:40:05 +0100 Subject: r25911: Remove more fstring/pstring bad useage. Go talloc ! Jeremy. merge from v3-2-test commit 2a0173743d2cf615d52278f3dd87cc804abe2d16 (This used to be commit cb0eca66dc5121fa73404a7c41aad6086a96e7ec) --- source4/lib/replace/replace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 55ed2e9570..973c68ee14 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -357,7 +357,7 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) #define _TYPE_MAXIMUM(t) ((t) (~ (t) 0 - _TYPE_MINIMUM (t))) #ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 64 +#define HOST_NAME_MAX 255 #endif /* -- cgit From 88f0c3bfa7773999d2a6dfd1123c95f019e87d84 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 08:42:55 +0100 Subject: r25912: Two patches Hi! Can you check and push them? Thanks, Volker From b488af5905e2dee12a1a72a3b40801ae5c26f24f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 27 Oct 2007 14:20:09 +0200 Subject: [PATCH] Fix some warnings and errors merge from v3-2-test commit e17d3e10e860c96b6d5208e5fe51e43b8e58c174 (This used to be commit 4087731e1b4e97017c0f5659e6659e8181d8e038) --- source4/lib/replace/getpass.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 1d13461573..d91d029f6a 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -21,6 +21,7 @@ not, see . */ #include "system/filesys.h" #include "system/wait.h" #include "system/terminal.h" +#include "system/passwd.h" /* * Define additional missing types -- cgit From 5adade2f2f6db9f76c5d1bfbb08d9c0b17d454a9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 14 Nov 2007 00:22:31 +0100 Subject: r25943: Fix soname on hpux. (This used to be commit fd762b01ed378739241dc14b6af9df9fcfe7659c) --- source4/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index fd85ef9fc4..35d09d0652 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -157,7 +157,7 @@ AC_DEFUN([AC_LD_SONAMEFLAG], SONAMEFLAG="-Wl,-soname," ;; *hpux*) - SONAMEFLAG="-Wl,+h " + SONAMEFLAG="-Wl,+h," ;; *osf*) SONAMEFLAG="-Wl,-soname," -- cgit From 0969ac9e6189d1b990ca86b7611341fe6a404b5e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 14 Nov 2007 01:01:31 +0100 Subject: r25944: Fix handling of sonameflag on AIX, which doesn't have anything like that. (This used to be commit 228dd6830eb9c91287bb3e0233d8b3a404ff3676) --- source4/lib/replace/libreplace_ld.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 35d09d0652..a8bc22cb5b 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -168,5 +168,9 @@ AC_DEFUN([AC_LD_SONAMEFLAG], *darwin*) SONAMEFLAG="-install_name " ;; + *aix*) + # Not supported + SONAMEFLAG="#" + ;; esac ]) -- cgit From 3e0efe23833f6277b121b19e85e693737530ec6b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 14 Nov 2007 01:07:39 +0100 Subject: r25945: Fix flags for MacOS X. (This used to be commit b01303b5677b03c1d3cc6f219d4c461726613767) --- source4/lib/replace/libreplace_ld.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index a8bc22cb5b..04a472df4c 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -67,6 +67,7 @@ case "$host_os" in PICFLAG="-KPIC" ;; *darwin*) + PICFLAG="-fno-common" ;; esac AC_SUBST(PICFLAG) @@ -166,7 +167,7 @@ AC_DEFUN([AC_LD_SONAMEFLAG], SONAMEFLAG="-Wl,-soname," ;; *darwin*) - SONAMEFLAG="-install_name " + SONAMEFLAG="-compatibility_version " ;; *aix*) # Not supported -- cgit From 85dd023f9900dbb256eda44220a37e04ed192395 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 14 Nov 2007 11:42:03 +0100 Subject: r25955: libreplace: add a useful link about linking shared libraries http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html metze (This used to be commit 403c5521d1bbd78a6b20d7da121870a5aa1d3546) --- source4/lib/replace/libreplace_ld.m4 | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 04a472df4c..7a37b1b23b 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -1,3 +1,8 @@ +# +# This offers a nice overview how to build shared libraries on all platforms +# http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html +# + AC_DEFUN([AC_LD_EXPORT_DYNAMIC], [ saved_LDFLAGS="$LDFLAGS" -- cgit From 36a1640b277c88c6725b8325e43e309a20e7a94f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 14 Nov 2007 22:46:29 +0100 Subject: r25956: Try metze's suggestion for Mac OS X shld flags. (This used to be commit 5fea6e0d9ae671ea00292b66a2608b3ee954f917) --- source4/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 7a37b1b23b..3a476dc90b 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -111,7 +111,7 @@ AC_DEFUN([AC_LD_SHLDFLAGS], fi ;; *darwin*) - SHLD_FLAGS="-dynamiclib" + SHLD_FLAGS="-bundle -flat_namespace -undefined suppress -Wl,-search_paths_first" ;; esac -- cgit From 04cf937b8de8b055767b87965a996e3c7741d266 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Nov 2007 10:20:55 +0100 Subject: r25963: libreplace: samba3 doesn't use SONAMEFLAG on Mac OS 10, so also try this metze (This used to be commit e145accfc25c04597c786e0bddbaf37e0d493863) --- source4/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 3a476dc90b..506933ce31 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -172,7 +172,7 @@ AC_DEFUN([AC_LD_SONAMEFLAG], SONAMEFLAG="-Wl,-soname," ;; *darwin*) - SONAMEFLAG="-compatibility_version " + SONAMEFLAG="#" ;; *aix*) # Not supported -- cgit From 0f134fab53489ad254ac23c740bc0a722ffa592c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Nov 2007 14:46:47 +0100 Subject: r25970: libreplace: fix AC_N_DEFINE() so that some appears in config.h metze (This used to be commit a07c983fde52607806745914bb41039afb5618cc) --- source4/lib/replace/libreplace_macros.m4 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 92fecd3db8..54e6b7ac75 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -248,11 +248,18 @@ m4_define([AH_CHECK_FUNC_EXT], dnl Define an AC_DEFINE with ifndef guard. dnl AC_N_DEFINE(VARIABLE [, VALUE]) -define(AC_N_DEFINE, -[cat >> confdefs.h <<\EOF -[#ifndef] $1 -[#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1) -[#endif] +AC_DEFUN([AC_N_DEFINE], +[ +AH_VERBATIM([$1], [ +#ifndef $1 +# undef $1 +#endif +]) + + cat >>confdefs.h <<\EOF +#ifndef $1 +[#define] $1 m4_if($#, 1, 1, [$2]) +#endif EOF ]) -- cgit From ae75b115787994540ccf1aa1b384331955384fd9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Nov 2007 14:55:48 +0100 Subject: r25971: libreplace: remove AC_EXTENSION_FLAG as it's the same as AC_N_DEFINE metze (This used to be commit 05b4619c5beff474488d1abe5e647acd94a3e20c) --- source4/lib/replace/libreplace_cc.m4 | 4 ++-- source4/lib/replace/libreplace_macros.m4 | 13 ------------- 2 files changed, 2 insertions(+), 15 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index a01bf1b290..a0722b2fcf 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -48,8 +48,8 @@ LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not su AC_PROG_INSTALL AC_ISC_POSIX -AC_EXTENSION_FLAG(_XOPEN_SOURCE_EXTENDED) -AC_EXTENSION_FLAG(_OSF_SOURCE) +AC_N_DEFINE(_XOPEN_SOURCE_EXTENDED) +AC_N_DEFINE(_OSF_SOURCE) AC_SYS_LARGEFILE diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 54e6b7ac75..1856eacf66 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -87,19 +87,6 @@ fi rm -f conftest* ])]) -AC_DEFUN([AC_EXTENSION_FLAG], -[ - cat >>confdefs.h <<\EOF -#ifndef $1 -# define $1 1 -#endif -EOF -AH_VERBATIM([$1], [#ifndef $1 -# define $1 1 -#endif]) -]) - - dnl see if a declaration exists for a function or variable dnl defines HAVE_function_DECL if it exists dnl AC_HAVE_DECL(var, includes) -- cgit From fc2df89cd7aa702a03bf1a2c47c19af8b0bfa55a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Nov 2007 15:43:14 +0100 Subject: r25974: libreplace: see what the build-farm says if we use _XOPEN_SOURCE=600 On Tru64 this brings in socklen_t and some other socket stuff metze (This used to be commit d42f2e5759332f1f0c6c1269bd29ac62ddb11016) --- source4/lib/replace/libreplace_cc.m4 | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index a0722b2fcf..3f0a337083 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -49,6 +49,7 @@ AC_PROG_INSTALL AC_ISC_POSIX AC_N_DEFINE(_XOPEN_SOURCE_EXTENDED) +AC_N_DEFINE(_XOPEN_SOURCE,600) AC_N_DEFINE(_OSF_SOURCE) AC_SYS_LARGEFILE -- cgit From f744d3bc9fb98491c0b7105eac867b1d3a355d47 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Nov 2007 16:40:32 +0100 Subject: r25976: libreplace: not all platforms like _XOPEN_SOURCE=600 - Only use _XOPEN_SOURCE=600 on Tru64 - _OSF_SOURCE is also Tru64 specific metze (This used to be commit d19ab62081ce4ee4273ff752ad0443782a994826) --- source4/lib/replace/libreplace_cc.m4 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 3f0a337083..bf5056838d 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -49,8 +49,6 @@ AC_PROG_INSTALL AC_ISC_POSIX AC_N_DEFINE(_XOPEN_SOURCE_EXTENDED) -AC_N_DEFINE(_XOPEN_SOURCE,600) -AC_N_DEFINE(_OSF_SOURCE) AC_SYS_LARGEFILE @@ -78,6 +76,11 @@ case "$host_os" in CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000" fi ;; + *osf*) + # this brings in socklen_t + AC_N_DEFINE(_XOPEN_SOURCE,600) + AC_N_DEFINE(_OSF_SOURCE) + ;; # # VOS may need to have POSIX support and System V compatibility enabled. # -- cgit From b415712d3fe7c71f79334bf7c1cdd246150ff077 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Nov 2007 16:44:28 +0100 Subject: r25977: libreplace: add AC_LIBREPLACE_MDLD and AC_LIBREPLACE_MDLD_FLAGS macros They define the linker and link flags for building shared modules metze (This used to be commit 128b4e1a512a9ae5592ba7ccf8adde11189fc5a9) --- source4/lib/replace/libreplace_ld.m4 | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 506933ce31..2f9834838d 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -180,3 +180,53 @@ AC_DEFUN([AC_LD_SONAMEFLAG], ;; esac ]) + +AC_DEFUN([AC_LIBREPLACE_MDLD], +[ + MDLD="${CC}" + + case "$host_os" in + *irix*) + MDLD="${PROG_LD}" + ;; + esac + + AC_SUBST(MDLD) +]) + +AC_DEFUN([AC_LIBREPLACE_MDLD_FLAGS], +[ + MDLD_FLAGS="-shared" + + case "$host_os" in + *linux*) + MDLD_FLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined" + ;; + *solaris*) + MDLD_FLAGS="-G" + if test "${GCC}" = "no"; then + ## ${CFLAGS} added for building 64-bit shared + ## libs using Sun's Compiler + NDLD_FLAGS="-G \${CFLAGS}" + fi + ;; + *sunos*) + MDLD_FLAGS="-G" + ;; + *aix*) + MDLD_FLAGS="-Wl,-G,-bexpall,-bbigtoc" + ;; + *hpux*) + if test "${GCC}" = "yes"; then + MDLD_FLAGS="-shared" + else + MDLD_FLAGS="-b" + fi + ;; + *darwin*) + MDLD_FLAGS="-bundle -flat_namespace -undefined suppress -Wl,-search_paths_first" + ;; + esac + + AC_SUBST(MDLD_FLAGS) +]) -- cgit From 31fe478cec856bf90404833923583a7793aba0c0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 Nov 2007 08:30:32 +0100 Subject: r25982: libreplace: try to ignore unresolved symbols in modules on Tru64 metze (This used to be commit bfde13b70b6be4c4aeeafa50d4619237930f9e0e) --- source4/lib/replace/libreplace_ld.m4 | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 2f9834838d..9356ebdf6e 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -223,6 +223,9 @@ AC_DEFUN([AC_LIBREPLACE_MDLD_FLAGS], MDLD_FLAGS="-b" fi ;; + *osf*) + MDLD_FLAGS="-shared -expect_unresolved '*'" + ;; *darwin*) MDLD_FLAGS="-bundle -flat_namespace -undefined suppress -Wl,-search_paths_first" ;; -- cgit From 896e46aa6c3952b4955c87a867c24705ed85f47d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 Nov 2007 09:31:49 +0100 Subject: r25986: libreplace: warn about unresolved symbols when link shared libraries On Tru64 and Mac OS X this hopefully works Note: -Wl,--no-allow-shlib-undefined doesn't tests what we want on Linux. metze (This used to be commit 7bee9a62ffda64a1bdcdbdd38dbb181eac8b641e) --- source4/lib/replace/libreplace_ld.m4 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 9356ebdf6e..ac8c870a64 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -110,8 +110,11 @@ AC_DEFUN([AC_LD_SHLDFLAGS], SHLD_FLAGS="-b" fi ;; + *osf*) + SHLD_FLAGS="-shared -warning_unresolved" + ;; *darwin*) - SHLD_FLAGS="-bundle -flat_namespace -undefined suppress -Wl,-search_paths_first" + SHLD_FLAGS="-bundle -flat_namespace -undefined warning -Wl,-search_paths_first" ;; esac -- cgit From 676bb230fcb310e56ef6cc9f15e257ffca4304ba Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 Nov 2007 10:10:58 +0100 Subject: r25987: libreplace: rename AC_LD_SHLDFLAGS into AC_LIBREPLACE_SHLD_FLAGS metze (This used to be commit 410cdf789a72209f9e10321519fe18ab40a43f95) --- source4/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index ac8c870a64..e78450bc1b 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -78,7 +78,7 @@ esac AC_SUBST(PICFLAG) ]) -AC_DEFUN([AC_LD_SHLDFLAGS], +AC_DEFUN([AC_LIBREPLACE_SHLD_FLAGS], [ SHLD_FLAGS="-shared" -- cgit From 0aa43592cbcdd3caeaca97e18c1057b0b69cefaf Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 Nov 2007 10:14:48 +0100 Subject: r25988: libreplace: add AC_LIBREPLACE_SHLD metze (This used to be commit 2abae42d70903710d1a289d945fa08c1d94ceb80) --- source4/lib/replace/libreplace_ld.m4 | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index e78450bc1b..cef0089cd1 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -78,6 +78,19 @@ esac AC_SUBST(PICFLAG) ]) +AC_DEFUN([AC_LIBREPLACE_SHLD], +[ + SHLD="${CC}" + + case "$host_os" in + *irix*) + SHLD="${PROG_LD}" + ;; + esac + + AC_SUBST(SHLD) +]) + AC_DEFUN([AC_LIBREPLACE_SHLD_FLAGS], [ SHLD_FLAGS="-shared" -- cgit From 413e992ae4a5641acbad3c0ad2b88ddd00f56714 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 16 Nov 2007 11:40:52 +0100 Subject: r25998: Add test for run time library path environment variable. (This used to be commit b2355857baf4d9dad0d9d6a465744be11bbb9beb) --- source4/lib/replace/libreplace_ld.m4 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index cef0089cd1..8bac16094e 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -249,3 +249,32 @@ AC_DEFUN([AC_LIBREPLACE_MDLD_FLAGS], AC_SUBST(MDLD_FLAGS) ]) + +AC_DEFUN([AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR], +[ + case "$host_os" in + *linux*) + LIB_PATH_VAR=LD_LIBRARY_PATH + ;; + *solaris*) + LIB_PATH_VAR=LD_LIBRARY_PATH + ;; + *hpux*) + LIB_PATH_VAR=SHLIB_PATH + ;; + *tru64*) + LIB_PATH_VAR=LD_LIBRARY_PATH + ;; + *aix*) + LIB_PATH_VAR=LIB_PATH + ;; + *irix*) + LIB_PATH_VAR=LD_LIBRARY_PATH + ;; + *darwin*) + LIB_PATH_VAR=DYLD_LIBRARY_PATH + ;; + esac + + AC_SUBST(LIB_PATH_VAR) +]) -- cgit From 25f1ea12693a5ae24c879e7d01d695e3dde5c623 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 Nov 2007 11:48:59 +0100 Subject: r25999: libreplace: add AC_LIBREPLACE_STLD and AC_LIBREPLACE_STLD_FLAGS metze (This used to be commit c7b0b4c21e1fc4093c9109e046f23c19489e7400) --- source4/lib/replace/libreplace_ld.m4 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 8bac16094e..46ddfb4ed6 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -3,6 +3,21 @@ # http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html # +AC_DEFUN([AC_LIBREPLACE_STLD], +[ + AC_PATH_PROG(PROG_AR, ar) + + STLD=${PROG_AR} + + AC_SUBST(STLD) +]) + +AC_DEFUN([AC_LIBREPLACE_STLD_FLAGS], +[ + STLD_FLAGS="-rcs" + AC_SUBST(STLD_FLAGS) +]) + AC_DEFUN([AC_LD_EXPORT_DYNAMIC], [ saved_LDFLAGS="$LDFLAGS" -- cgit From 4b546eada1cbf36de1d040452ff9cf5445d26ab3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 16 Nov 2007 20:11:48 +0100 Subject: r26001: Share some code between macros, add macro specifically for testing the ld flag that allows undefined symbols. (This used to be commit 6cd3a3a46a6a9b630502ebfff1a90e2d035d9e39) --- source4/lib/replace/libreplace_ld.m4 | 50 ++++++++++-------------------------- 1 file changed, 14 insertions(+), 36 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 46ddfb4ed6..e9c7629643 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -214,54 +214,32 @@ AC_DEFUN([AC_LD_SONAMEFLAG], AC_DEFUN([AC_LIBREPLACE_MDLD], [ - MDLD="${CC}" - - case "$host_os" in - *irix*) - MDLD="${PROG_LD}" - ;; - esac - + AC_LIBREPLACE_SHLD() + MDLD=$SHLD AC_SUBST(MDLD) ]) -AC_DEFUN([AC_LIBREPLACE_MDLD_FLAGS], +AC_DEFUN([AC_LIBREPLACE_LD_ALLOW_SHLIB_UNDEF_FLAG], [ - MDLD_FLAGS="-shared" - case "$host_os" in *linux*) - MDLD_FLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined" - ;; - *solaris*) - MDLD_FLAGS="-G" - if test "${GCC}" = "no"; then - ## ${CFLAGS} added for building 64-bit shared - ## libs using Sun's Compiler - NDLD_FLAGS="-G \${CFLAGS}" - fi - ;; - *sunos*) - MDLD_FLAGS="-G" - ;; - *aix*) - MDLD_FLAGS="-Wl,-G,-bexpall,-bbigtoc" - ;; - *hpux*) - if test "${GCC}" = "yes"; then - MDLD_FLAGS="-shared" - else - MDLD_FLAGS="-b" - fi + SHLD_ALLOW_SHLIB_UNDEF_FLAG="-Wl,--allow-shlib-undefined" ;; *osf*) - MDLD_FLAGS="-shared -expect_unresolved '*'" + SHLD_ALLOW_SHLIB_UNDEF_FLAG="-expect_unresolved '*'" ;; *darwin*) - MDLD_FLAGS="-bundle -flat_namespace -undefined suppress -Wl,-search_paths_first" + SHLD_ALLOW_SHLIB_UNDEF_FLAG="-undefined suppress" ;; - esac + esac + AC_SUBST(SHLD_ALLOW_SHLIB_UNDEF_FLAG) +]) +AC_DEFUN([AC_LIBREPLACE_MDLD_FLAGS], +[ + AC_LIBREPLACE_SHLD_FLAGS() + AC_LIBREPLACE_LD_ALLOW_SHLIB_UNDEF_FLAG() + MDLD_FLAGS="$SHLD_FLAGS $SHLD_ALLOW_SHLIB_UNDEF_FLAG" AC_SUBST(MDLD_FLAGS) ]) -- cgit From b7c5d2b0c9e3366e61bf83ea7b49aff4da05ac0d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 16 Nov 2007 20:11:53 +0100 Subject: r26002: Use osf rather than tru64 - pointed out by metze. (This used to be commit df10de42958e65f46298c2fc879688985d1f7ef3) --- source4/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index e9c7629643..58b94673dc 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -255,7 +255,7 @@ AC_DEFUN([AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR], *hpux*) LIB_PATH_VAR=SHLIB_PATH ;; - *tru64*) + *osf*) LIB_PATH_VAR=LD_LIBRARY_PATH ;; *aix*) -- cgit From 662cda2138872d7a6b72278cb9561e64ee35fbdc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 19 Nov 2007 10:07:29 +0100 Subject: r26025: libreplace: AC_LIBREPLACE_LD_ALLOW_SHLIB_UNDEF_FLAG should fill LD_ALLOW_SHLIB_UNDEF_FLAG metze (This used to be commit d2fb7d876bb1960c02fa7b9c0fb53315ae0cd99c) --- source4/lib/replace/libreplace_ld.m4 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 58b94673dc..e98885445d 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -221,25 +221,28 @@ AC_DEFUN([AC_LIBREPLACE_MDLD], AC_DEFUN([AC_LIBREPLACE_LD_ALLOW_SHLIB_UNDEF_FLAG], [ + LD_ALLOW_SHLIB_UNDEF_FLAG="" + case "$host_os" in *linux*) - SHLD_ALLOW_SHLIB_UNDEF_FLAG="-Wl,--allow-shlib-undefined" + LD_ALLOW_SHLIB_UNDEF_FLAG="-Wl,--allow-shlib-undefined" ;; *osf*) - SHLD_ALLOW_SHLIB_UNDEF_FLAG="-expect_unresolved '*'" + LD_ALLOW_SHLIB_UNDEF_FLAG="-expect_unresolved '*'" ;; *darwin*) - SHLD_ALLOW_SHLIB_UNDEF_FLAG="-undefined suppress" + LD_ALLOW_SHLIB_UNDEF_FLAG="-undefined suppress" ;; - esac - AC_SUBST(SHLD_ALLOW_SHLIB_UNDEF_FLAG) + esac + + AC_SUBST(LD_ALLOW_SHLIB_UNDEF_FLAG) ]) AC_DEFUN([AC_LIBREPLACE_MDLD_FLAGS], [ AC_LIBREPLACE_SHLD_FLAGS() AC_LIBREPLACE_LD_ALLOW_SHLIB_UNDEF_FLAG() - MDLD_FLAGS="$SHLD_FLAGS $SHLD_ALLOW_SHLIB_UNDEF_FLAG" + MDLD_FLAGS="$SHLD_FLAGS $LD_ALLOW_SHLIB_UNDEF_FLAG" AC_SUBST(MDLD_FLAGS) ]) -- cgit From c5e16f339cd5d29aa86b5d6158ec384c7e687915 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 19 Nov 2007 11:34:26 +0100 Subject: r26026: libreplace: split some linker macros create: AC_LIBREPLACE_LD_SHLIB_LINKER AC_LIBREPLACE_LD_SHLIB_FLAGS AC_LIBREPLACE_LD_SHLIB_DISALLOW_UNDEF_FLAG and prerequire them for: AC_LIBREPLACE_SHLD AC_LIBREPLACE_SHLD_FLAGS AC_LIBREPLACE_MDLD AC_LIBREPLACE_MDLD_FLAGS metze (This used to be commit cc8692265d6e9161679a779480d6b22dee23f8bb) --- source4/lib/replace/libreplace_ld.m4 | 79 ++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 21 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index e98885445d..f156fa8e9f 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -93,59 +93,96 @@ esac AC_SUBST(PICFLAG) ]) -AC_DEFUN([AC_LIBREPLACE_SHLD], +AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_LINKER], [ - SHLD="${CC}" + LD_SHLIB_LINKER="${CC}" case "$host_os" in *irix*) - SHLD="${PROG_LD}" + LD_SHLIB_LINKER="${PROG_LD}" ;; esac - AC_SUBST(SHLD) + AC_SUBST(LD_SHLIB_LINKER) ]) -AC_DEFUN([AC_LIBREPLACE_SHLD_FLAGS], +AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_FLAGS], [ - SHLD_FLAGS="-shared" + LD_SHLIB_FLAGS="-shared" case "$host_os" in *linux*) - SHLD_FLAGS="-shared -Wl,-Bsymbolic" + LD_SHLIB_FLAGS="-shared -Wl,-Bsymbolic" ;; *solaris*) - SHLD_FLAGS="-G" + LD_SHLIB_FLAGS="-G" if test "${GCC}" = "no"; then ## ${CFLAGS} added for building 64-bit shared ## libs using Sun's Compiler - SHLD_FLAGS="-G \${CFLAGS}" + LD_SHLIB_FLAGS="-G \${CFLAGS}" fi ;; *sunos*) - SHLD_FLAGS="-G" + LD_SHLIB_FLAGS="-G" ;; *irix*) - SHLD_FLAGS="-shared" + LD_SHLIB_FLAGS="-shared" ;; *aix*) - SHLD_FLAGS="-Wl,-G,-bexpall,-bbigtoc" + LD_SHLIB_FLAGS="-Wl,-G,-bexpall,-bbigtoc" ;; *hpux*) if test "${GCC}" = "yes"; then - SHLD_FLAGS="-shared" + LD_SHLIB_FLAGS="-shared" else - SHLD_FLAGS="-b" + LD_SHLIB_FLAGS="-b" fi ;; *osf*) - SHLD_FLAGS="-shared -warning_unresolved" + LD_SHLIB_FLAGS="-shared" ;; *darwin*) - SHLD_FLAGS="-bundle -flat_namespace -undefined warning -Wl,-search_paths_first" + LD_SHLIB_FLAGS="-bundle -flat_namespace -Wl,-search_paths_first" ;; esac + AC_SUBST(LD_SHLIB_FLAGS) +]) + +AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_DISALLOW_UNDEF_FLAG], +[ + LD_SHLIB_DISALLOW_UNDEF_FLAG="" + + # + # TODO: enforce error not only warnings + # + # NOTE: -Wl,--no-allow-shlib-undefined isn't what we want... + # as it bails out on broken system libraries + # + case "$host_os" in + *osf*) + LD_SHLIB_DISALLOW_UNDEF_FLAG="-warning_unresolved" + ;; + *darwin*) + LD_SHLIB_DISALLOW_UNDEF_FLAG="-undefined warning" + ;; + esac + + AC_SUBST(LD_SHLIB_DISALLOW_UNDEF_FLAG) +]) + +AC_DEFUN([AC_LIBREPLACE_SHLD], +[ + AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_LINKER]) + SHLD="$LD_SHLIB_LINKER" + AC_SUBST(SHLD) +]) + +AC_DEFUN([AC_LIBREPLACE_SHLD_FLAGS], +[ + AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_FLAGS]) + AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_DISALLOW_UNDEF_FLAG]) + SHLD_FLAGS="$LD_SHLIB_FLAGS $LD_SHLIB_DISALLOW_UNDEF_FLAG" AC_SUBST(SHLD_FLAGS) ]) @@ -214,8 +251,8 @@ AC_DEFUN([AC_LD_SONAMEFLAG], AC_DEFUN([AC_LIBREPLACE_MDLD], [ - AC_LIBREPLACE_SHLD() - MDLD=$SHLD + AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_LINKER]) + MDLD="$LD_SHLIB_LINKER" AC_SUBST(MDLD) ]) @@ -240,9 +277,9 @@ AC_DEFUN([AC_LIBREPLACE_LD_ALLOW_SHLIB_UNDEF_FLAG], AC_DEFUN([AC_LIBREPLACE_MDLD_FLAGS], [ - AC_LIBREPLACE_SHLD_FLAGS() - AC_LIBREPLACE_LD_ALLOW_SHLIB_UNDEF_FLAG() - MDLD_FLAGS="$SHLD_FLAGS $LD_ALLOW_SHLIB_UNDEF_FLAG" + AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_FLAGS]) + AC_REQUIRE([AC_LIBREPLACE_LD_ALLOW_SHLIB_UNDEF_FLAG]) + MDLD_FLAGS="$LD_SHLIB_FLAGS $LD_ALLOW_SHLIB_UNDEF_FLAG" AC_SUBST(MDLD_FLAGS) ]) -- cgit From b41a25c104da46ac45ef2449e36a76cc5be84413 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 19 Nov 2007 12:12:13 +0100 Subject: r26027: libreplace: rename AC_LIBREPLACE_LD_ALLOW_SHLIB_UNDEF_FLAG into AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG metze (This used to be commit 8ec94633c4d46bb9ca03d59fed40e278d35ad580) --- source4/lib/replace/libreplace_ld.m4 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index f156fa8e9f..a2e43bbe13 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -256,30 +256,30 @@ AC_DEFUN([AC_LIBREPLACE_MDLD], AC_SUBST(MDLD) ]) -AC_DEFUN([AC_LIBREPLACE_LD_ALLOW_SHLIB_UNDEF_FLAG], +AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG], [ LD_ALLOW_SHLIB_UNDEF_FLAG="" case "$host_os" in *linux*) - LD_ALLOW_SHLIB_UNDEF_FLAG="-Wl,--allow-shlib-undefined" + LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,--allow-shlib-undefined" ;; *osf*) - LD_ALLOW_SHLIB_UNDEF_FLAG="-expect_unresolved '*'" + LD_SHLIB_ALLOW_UNDEF_FLAG="-expect_unresolved '*'" ;; *darwin*) - LD_ALLOW_SHLIB_UNDEF_FLAG="-undefined suppress" + LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined suppress" ;; esac - AC_SUBST(LD_ALLOW_SHLIB_UNDEF_FLAG) + AC_SUBST(LD_SHLIB_ALLOW_UNDEF_FLAG) ]) AC_DEFUN([AC_LIBREPLACE_MDLD_FLAGS], [ AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_FLAGS]) - AC_REQUIRE([AC_LIBREPLACE_LD_ALLOW_SHLIB_UNDEF_FLAG]) - MDLD_FLAGS="$LD_SHLIB_FLAGS $LD_ALLOW_SHLIB_UNDEF_FLAG" + AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG]) + MDLD_FLAGS="$LD_SHLIB_FLAGS $LD_SHLIB_ALLOW_UNDEF_FLAG" AC_SUBST(MDLD_FLAGS) ]) -- cgit From b24e7a15051518806b50768cfc2a840d2b395fe3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 Nov 2007 14:42:14 +0100 Subject: r26102: libreplace: remove system/printing.h as it only contains samba3 stuff metze (This used to be commit 1ecb4ec01b0506c95a5f90a62040329e7a39ee93) --- source4/lib/replace/system/printing.h | 50 ----------------------------------- source4/lib/replace/test/testsuite.c | 1 - 2 files changed, 51 deletions(-) delete mode 100644 source4/lib/replace/system/printing.h (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/printing.h b/source4/lib/replace/system/printing.h deleted file mode 100644 index 7eb02d004a..0000000000 --- a/source4/lib/replace/system/printing.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _system_printing_h -#define _system_printing_h - -/* - Unix SMB/CIFS implementation. - - printing system include wrappers - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the replace - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . - -*/ - -#ifdef AIX -#define DEFAULT_PRINTING PRINT_AIX -#define PRINTCAP_NAME "/etc/qconfig" -#endif - -#ifdef HPUX -#define DEFAULT_PRINTING PRINT_HPUX -#endif - -#ifdef QNX -#define DEFAULT_PRINTING PRINT_QNX -#endif - -#ifndef DEFAULT_PRINTING -#define DEFAULT_PRINTING PRINT_BSD -#endif -#ifndef PRINTCAP_NAME -#define PRINTCAP_NAME "/etc/printcap" -#endif - -#endif diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 269a2ff5d6..5b95ae395c 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -37,7 +37,6 @@ #include "system/locale.h" #include "system/network.h" #include "system/passwd.h" -#include "system/printing.h" #include "system/readline.h" #include "system/select.h" #include "system/shmem.h" -- cgit From 9e367b13d94770f652cb096595722b17d77ab7b4 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 3 Dec 2007 16:29:54 +0100 Subject: r26253: Add check for broken RedHat 7.2 system header files to lib/replace. This is taken (with slight reformatting) from samba3:configure.in. It is already used in lib/replace/system/capablity.h. Michael (This used to be commit 4d1df9c0b4248717d6f235572f5f68e27934741e) --- source4/lib/replace/system/config.m4 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 index 6500535982..64143fe371 100644 --- a/source4/lib/replace/system/config.m4 +++ b/source4/lib/replace/system/config.m4 @@ -16,6 +16,28 @@ AC_HEADER_SYS_WAIT # capability AC_CHECK_HEADERS(sys/capability.h) +case "$host_os" in +*linux*) +AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[ +AC_TRY_COMPILE([ + #ifdef HAVE_SYS_VFS_H + #include + #endif + #ifdef HAVE_SYS_CAPABILITY_H + #include + #endif + ],[ + int i; + ], + samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no, + samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes +)]) +if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then + AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files]) +fi +;; +esac + # passwd AC_CHECK_HEADERS(grp.h sys/id.h compat.h shadow.h sys/priv.h pwd.h sys/security.h) AC_CHECK_FUNCS(getpwnam_r getpwuid_r getpwent_r) -- cgit From b08a82de587afdd561d55580957fec7cbeb2e43f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 3 Dec 2007 16:32:28 +0100 Subject: r26254: Add check for PPC statfs.h to workaround for broken capability.h. Synced from Samba3. Michael (This used to be commit dfdfac2b57ecbca8bddece846f5c2103a518e34d) --- source4/lib/replace/system/capability.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/capability.h b/source4/lib/replace/system/capability.h index 4fe7c8d51b..59b5845721 100644 --- a/source4/lib/replace/system/capability.h +++ b/source4/lib/replace/system/capability.h @@ -27,14 +27,16 @@ #ifdef HAVE_SYS_CAPABILITY_H -#if defined(BROKEN_REDHAT_7_SYSTEM_HEADERS) && !defined(_I386_STATFS_H) +#if defined(BROKEN_REDHAT_7_SYSTEM_HEADERS) && !defined(_I386_STATFS_H) && !defined(_PPC_STATFS_H) #define _I386_STATFS_H +#define _PPC_STATFS_H #define BROKEN_REDHAT_7_STATFS_WORKAROUND #endif #include #ifdef BROKEN_REDHAT_7_STATFS_WORKAROUND +#undef _PPC_STATFS_H #undef _I386_STATFS_H #undef BROKEN_REDHAT_7_STATFS_WORKAROUND #endif -- cgit From cbdad76b0d6b893a26c5dc20def034149fb3aa97 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 3 Dec 2007 16:46:45 +0100 Subject: r26255: Work around another broken aspect of sys/capability.h on RHEL5. This is synced from samba3 v3-2-test/11bcdf780e164659b89: The /usr/include/sys/capability.h defines _LINUX_TYPES_H which prevents /usr/include/linux/types.h from being parsed (when included afterwards). Thus certain types are undefined that are for instance needed in /usr/include/linux/dqblk_xfs.h. This breaks the build of lib/sysquotas_xfs.c in Samba3. This commit adds a configure check and a workaround for this. Michael (This used to be commit df3e151992f0b942554034dd143ab8d7f0d7a75b) --- source4/lib/replace/system/capability.h | 9 +++++++++ source4/lib/replace/system/config.m4 | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/capability.h b/source4/lib/replace/system/capability.h index 59b5845721..a7b78f0275 100644 --- a/source4/lib/replace/system/capability.h +++ b/source4/lib/replace/system/capability.h @@ -33,8 +33,17 @@ #define BROKEN_REDHAT_7_STATFS_WORKAROUND #endif +#if defined(BROKEN_RHEL5_SYS_CAP_HEADER) && !defined(_LINUX_TYPES_H) +#define BROKEN_RHEL5_SYS_CAP_HEADER_WORKAROUND +#endif + #include +#ifdef BROKEN_RHEL5_SYS_CAP_HEADER_WORKAROUND +#undef _LINUX_TYPES_H +#undef BROKEN_RHEL5_SYS_CAP_HEADER_WORKAROUND +#endif + #ifdef BROKEN_REDHAT_7_STATFS_WORKAROUND #undef _PPC_STATFS_H #undef _I386_STATFS_H diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 index 64143fe371..799187af7d 100644 --- a/source4/lib/replace/system/config.m4 +++ b/source4/lib/replace/system/config.m4 @@ -35,6 +35,22 @@ AC_TRY_COMPILE([ if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files]) fi + +AC_CACHE_CHECK([for broken RHEL5 sys/capability.h],samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER,[ +AC_TRY_COMPILE([ + #ifdef HAVE_SYS_CAPABILITY_H + #include + #endif + #include + ],[ + __s8 i; + ], + samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER=no, + samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER=yes +)]) +if test x"$samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER" = x"yes"; then + AC_DEFINE(BROKEN_RHEL5_SYS_CAP_HEADER,1,[Broken RHEL5 sys/capability.h]) +fi ;; esac -- cgit From be4decb2b73e3431155663c2dae3a8452ecde28a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 16 Dec 2007 02:39:01 +0100 Subject: r26467: Use getifaddrs() for interface enumeration and provide replacements for platforms that don't have it in lib/replace. (This used to be commit 9b4924fbd8619033c55b4c6e2589da247332e7db) --- source4/lib/replace/getifaddrs.c | 391 +++++++++++++++++++++++++++++++++++ source4/lib/replace/getifaddrs.m4 | 94 +++++++++ source4/lib/replace/libreplace.m4 | 1 + source4/lib/replace/system/network.h | 25 +++ 4 files changed, 511 insertions(+) create mode 100644 source4/lib/replace/getifaddrs.c create mode 100644 source4/lib/replace/getifaddrs.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c new file mode 100644 index 0000000000..3969535a0b --- /dev/null +++ b/source4/lib/replace/getifaddrs.c @@ -0,0 +1,391 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Jeremy Allison 2007 + Copyright (C) Jelmer Vernooij 2007 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "replace.h" +#include "system/network.h" + +#include +#include +#include + +#ifdef HAVE_SYS_TIME_H +#include +#endif + +#ifndef SIOCGIFCONF +#ifdef HAVE_SYS_SOCKIO_H +#include +#endif +#endif + +#ifdef HAVE_IFACE_GETIFADDRS +#define _FOUND_IFACE_ANY +#else + +void freeifaddrs(struct ifaddrs *ifp) +{ + free(ifp->ifa_name); + free(ifp->ifa_addr); + free(ifp->ifa_netmask); + free(ifp->ifa_dstaddr); + if (ifp->ifa_next != NULL) + freeifaddrs(ifp->ifa_next); + free(ifp); +} + +struct sockaddr *sockaddr_dup(struct sockaddr *sa) +{ + struct sockaddr *ret = calloc(1, sa->sa_len); + if (ret == NULL) + return NULL; + memcpy(ret, sa, sa->sa_len); + return ret; +} +#endif + +#if HAVE_IFACE_IFCONF + +/* this works for Linux 2.2, Solaris 2.5, SunOS4, HPUX 10.20, OSF1 + V4.0, Ultrix 4.4, SCO Unix 3.2, IRIX 6.4 and FreeBSD 3.2. + + It probably also works on any BSD style system. */ + +int getifaddrs(struct ifaddrs **ifap) +{ + struct ifconf ifc; + char buff[8192]; + int fd, i, n; + struct ifreq *ifr=NULL; + int total = 0; + struct in_addr ipaddr; + struct in_addr nmask; + char *iname; + struct ifaddrs *curif, *lastif; + + *ifap = NULL; + + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + return -1; + } + + ifc.ifc_len = sizeof(buff); + ifc.ifc_buf = buff; + + if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) { + close(fd); + return -1; + } + + ifr = ifc.ifc_req; + + n = ifc.ifc_len / sizeof(struct ifreq); + + /* Loop through interfaces, looking for given IP address */ + for (i=n-1;i>=0 && total < max_interfaces;i--) { + if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) { + freeifaddrs(*ifap); + } + + curif = calloc(1, sizeof(struct ifaddrs)); + if (lastif == NULL) { + *ifap = curif; + } else { + lastif->ifa_next = (*ifap); + } + + curif->ifa_name = strdup(ifr[i].ifr_name); + curif->ifa_flags = ifreq.ifr_flags; + curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr); + curif->ifa_dstaddr = NULL; + curif->ifa_data = NULL; + curif->ifa_next = NULL; + curif->ifa_netmask = NULL; + + if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) != 0) { + freeifaddrs(*ifap); + return -1; + } + + if (!(ifr[i].ifr_flags & IFF_UP)) { + freeifaddrs(curif); + continue; + } + + if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) { + freeifaddrs(*ifap); + return -1; + } + + curif->ifa_netmask = sockaddr_dup(&ifr[i].ifr_addr); + + lastif = curif; + } + + close(fd); + + return 0; +} + +#define _FOUND_IFACE_ANY +#endif /* HAVE_IFACE_IFCONF */ +#ifdef HAVE_IFACE_IFREQ + +#ifndef I_STR +#include +#endif + +/**************************************************************************** +this should cover most of the streams based systems +Thanks to Andrej.Borsenkow@mow.siemens.ru for several ideas in this code +****************************************************************************/ +int getifaddrs(struct ifaddrs **ifap) +{ + struct ifreq ifreq; + struct strioctl strioctl; + char buff[8192]; + int fd, i, n; + struct ifreq *ifr=NULL; + int total = 0; + struct in_addr ipaddr; + struct in_addr nmask; + char *iname; + struct ifaddrs *curif; + + *ifap = NULL; + + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + return -1; + } + + strioctl.ic_cmd = SIOCGIFCONF; + strioctl.ic_dp = buff; + strioctl.ic_len = sizeof(buff); + if (ioctl(fd, I_STR, &strioctl) < 0) { + close(fd); + return -1; + } + + /* we can ignore the possible sizeof(int) here as the resulting + number of interface structures won't change */ + n = strioctl.ic_len / sizeof(struct ifreq); + + /* we will assume that the kernel returns the length as an int + at the start of the buffer if the offered size is a + multiple of the structure size plus an int */ + if (n*sizeof(struct ifreq) + sizeof(int) == strioctl.ic_len) { + ifr = (struct ifreq *)(buff + sizeof(int)); + } else { + ifr = (struct ifreq *)buff; + } + + /* Loop through interfaces */ + + for (i = 0; iifa_next = (*ifap); + } + + curif->ifa_name = strdup(ifreq.ifr_name); + curif->ifa_flags = ifreq.ifr_flags; + curif->ifa_addr = sockaddr_dup(&ifreq.ifr_addr); + curif->ifa_dstaddr = NULL; + curif->ifa_data = NULL; + curif->ifa_next = NULL; + curif->ifa_netmask = NULL; + + strioctl.ic_cmd = SIOCGIFNETMASK; + strioctl.ic_dp = (char *)&ifreq; + strioctl.ic_len = sizeof(struct ifreq); + if (ioctl(fd, I_STR, &strioctl) != 0) { + freeifaddrs(*ifap); + return -1; + } + + curif->ifa_netmask = sockaddr_dup(&ifreq.ifr_addr); + + lastif = curif; + } + + close(fd); + + return 0; +} + +#define _FOUND_IFACE_ANY +#endif /* HAVE_IFACE_IFREQ */ +#ifdef HAVE_IFACE_AIX + +/**************************************************************************** +this one is for AIX (tested on 4.2) +****************************************************************************/ +int getifaddrs(struct ifaddrs **ifap) +{ + char buff[8192]; + int fd, i; + struct ifconf ifc; + struct ifreq *ifr=NULL; + struct in_addr ipaddr; + struct in_addr nmask; + char *iname; + int total = 0; + struct ifaddrs *curif, *lastif; + + *ifap = NULL; + + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + return -1; + } + + ifc.ifc_len = sizeof(buff); + ifc.ifc_buf = buff; + + if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) { + close(fd); + return -1; + } + + ifr = ifc.ifc_req; + + /* Loop through interfaces */ + i = ifc.ifc_len; + + while (i > 0) { + uint_t inc; + + inc = ifr->ifr_addr.sa_len; + + if (ioctl(fd, SIOCGIFADDR, ifr) != 0) { + freeaddrinfo(*ifap); + return -1; + } + + curif = calloc(1, sizeof(struct ifaddrs)); + if (lastif == NULL) { + *ifap = curif; + } else { + lastif->ifa_next = (*ifap); + } + + curif->ifa_name = strdup(ifr->ifr_name); + curif->ifa_flags = ifr->ifr_flags; + curif->ifa_addr = sockaddr_dup(&ifr->ifr_addr); + curif->ifa_dstaddr = NULL; + curif->ifa_data = NULL; + curif->ifa_netmask = NULL; + curif->ifa_next = NULL; + + if (ioctl(fd, SIOCGIFFLAGS, ifr) != 0) { + freeaddrinfo(*ifap); + return -1; + } + + if (!(ifr->ifr_flags & IFF_UP)) { + freeaddrinfo(curif); + continue; + } + + if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) { + freeaddrinfo(*ifap); + return -1; + } + + curif->ifa_netmask = sockaddr_dup(&ifr->ifr_addr); + + lastif = curif; + + next: + /* + * Patch from Archie Cobbs (archie@whistle.com). The + * addresses in the SIOCGIFCONF interface list have a + * minimum size. Usually this doesn't matter, but if + * your machine has tunnel interfaces, etc. that have + * a zero length "link address", this does matter. */ + + if (inc < sizeof(ifr->ifr_addr)) + inc = sizeof(ifr->ifr_addr); + inc += IFNAMSIZ; + + ifr = (struct ifreq*) (((char*) ifr) + inc); + i -= inc; + } + + close(fd); + return 0; +} + +#define _FOUND_IFACE_ANY +#endif /* HAVE_IFACE_AIX */ +#ifndef _FOUND_IFACE_ANY +int getifaddrs(struct ifaddrs **ifap) +{ + errno = ENOSYS; + return -1; +} +#endif + +#ifdef AUTOCONF_TEST +/* this is the autoconf driver to test get_interfaces() */ + + int main() +{ + struct ifaddrs *ifs; + int total = get_interfaces(ifaces, MAX_INTERFACES); + int i; + + int ret = getifaddrs(&ifs); + if (ret != 0) { + perror("getifaddrs() failed"); + return 1; + } + + while (ifs) { + printf("%-10s ", ifs->ifr_name); + printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifr_addr)->sin_addr)); + printf("NETMASK=%s\n", inet_ntoa(((struct sockaddr_in *)ifs->ifr_netmask)->sin_addr)); + } + return 0; +} +#endif diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 new file mode 100644 index 0000000000..f38827406d --- /dev/null +++ b/source4/lib/replace/getifaddrs.m4 @@ -0,0 +1,94 @@ +AC_CHECK_HEADERS([ifaddrs.h]) + +dnl test for getifaddrs and freeifaddrs +AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ +AC_TRY_COMPILE([ +#include +#include +#include +#include +#include +#include ], +[ +struct ifaddrs *ifp = NULL; +int ret = getifaddrs (&ifp); +freeifaddrs(ifp); +], +samba_cv_HAVE_GETIFADDRS=yes,samba_cv_HAVE_GETIFADDRS=no)]) +if test x"$samba_cv_HAVE_GETIFADDRS" = x"yes"; then + AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs]) + AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs]) + AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available]) +fi + +################## +# look for a method of finding the list of network interfaces +# +# This tests need LIBS="$NSL_LIBS $SOCKET_LIBS" +# +old_CFLAGS=$CFLAGS +old_LIBS=$LIBS +LIBS="$NSL_LIBS $SOCKET_LIBS" +CFLAGS="$CFLAGS -Ilib/replace" +iface=no; +################## +# look for a method of finding the list of network interfaces +iface=no; +AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[ +SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}" +AC_TRY_RUN([ +#define NO_CONFIG_H 1 +#define HAVE_IFACE_GETIFADDRS 1 +#define AUTOCONF_TEST 1 +#include "${srcdir-.}/lib/replace/replace.c" +#include "${srcdir-.}/lib/replace/getifaddrs.c"], + samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)]) +CPPFLAGS="$SAVE_CPPFLAGS" +if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) +else + LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o" +fi + + +if test $iface = no; then +AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[ +AC_TRY_RUN([ +#define HAVE_IFACE_AIX 1 +#define AUTOCONF_TEST 1 +#undef _XOPEN_SOURCE_EXTENDED +#include "${srcdir-.}/lib/replace/getifaddrs.c"], + samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)]) +if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) +fi +fi + + +if test $iface = no; then +AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[ +AC_TRY_RUN([ +#define HAVE_IFACE_IFCONF 1 +#define AUTOCONF_TEST 1 +#include "${srcdir-.}/lib/replace/getifaddrs.c"], + samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)]) +if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) +fi +fi + +if test $iface = no; then +AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[ +AC_TRY_RUN([ +#define HAVE_IFACE_IFREQ 1 +#define AUTOCONF_TEST 1 +#include "${srcdir-.}/lib/replace/getifaddrs.c"], + samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)]) +if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) +fi +fi + +CFLAGS=$old_CFLAGS +LIBS=$old_LIBS diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index c10a4b2381..7e456b4d03 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -327,6 +327,7 @@ m4_include(inet_ntop.m4) m4_include(inet_pton.m4) m4_include(getaddrinfo.m4) m4_include(repdir.m4) +m4_include(getifaddrs.m4) AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index d3ae2bf398..45d84e0386 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -6,6 +6,7 @@ networking system include wrappers Copyright (C) Andrew Tridgell 2004 + Copyright (C) Jelmer Vernooij 2007 ** NOTE! The following LGPL license applies to the replace ** library. This does NOT imply that all of Samba is released @@ -93,6 +94,30 @@ int rep_inet_pton(int af, const char *src, void *dst); const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #endif +#ifdef HAVE_IFADDRS_H +#include +#endif + +#ifndef HAVE_STRUCT_IFADDRS +struct ifaddrs { + struct ifaddrs *ifa_next; /* Pointer to next struct */ + char *ifa_name; /* Interface name */ + u_int ifa_flags; /* Interface flags */ + struct sockaddr *ifa_addr; /* Interface address */ + struct sockaddr *ifa_netmask; /* Interface netmask */ + struct sockaddr *ifa_dstaddr; /* P2P interface destination */ + void *ifa_data; /* Address specific data */ +}; +#endif + +#ifndef HAVE_GETIFADDRS +int rep_getifaddrs(struct ifaddrs **); +#endif + +#ifndef HAVE_FREEIFADDRS +int rep_freeifaddrs(struct ifaddrs **); +#endif + /* * Some systems have getaddrinfo but not the * defines needed to use it. -- cgit From 41e45d690ff5074d861b486c8711bf03cffa2efc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 16 Dec 2007 02:49:52 +0100 Subject: r26468: Match getifaddrs more closely, add trivial test. (This used to be commit 92898c043b5a2649a2e423d02bcdaea78ae55737) --- source4/lib/replace/getifaddrs.c | 33 +++++++++++---------------------- source4/lib/replace/test/testsuite.c | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 22 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index 3969535a0b..a4f16ddb76 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -112,7 +112,6 @@ int getifaddrs(struct ifaddrs **ifap) } curif->ifa_name = strdup(ifr[i].ifr_name); - curif->ifa_flags = ifreq.ifr_flags; curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr); curif->ifa_dstaddr = NULL; curif->ifa_data = NULL; @@ -124,10 +123,7 @@ int getifaddrs(struct ifaddrs **ifap) return -1; } - if (!(ifr[i].ifr_flags & IFF_UP)) { - freeifaddrs(curif); - continue; - } + curif->ifa_flags = ifr[i].ifr_flags; if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) { freeifaddrs(*ifap); @@ -201,6 +197,13 @@ int getifaddrs(struct ifaddrs **ifap) for (i = 0; iifa_next = (*ifap); + } + strioctl.ic_cmd = SIOCGIFFLAGS; strioctl.ic_dp = (char *)&ifreq; strioctl.ic_len = sizeof(struct ifreq); @@ -208,11 +211,9 @@ int getifaddrs(struct ifaddrs **ifap) freeifaddrs(*ifap); return -1; } - - if (!(ifreq.ifr_flags & IFF_UP)) { - continue; - } + curif->ifa_flags = ifreq.ifr_flags; + strioctl.ic_cmd = SIOCGIFADDR; strioctl.ic_dp = (char *)&ifreq; strioctl.ic_len = sizeof(struct ifreq); @@ -221,15 +222,7 @@ int getifaddrs(struct ifaddrs **ifap) return -1; } - curif = calloc(1, sizeof(struct ifaddrs)); - if (lastif == NULL) { - *ifap = curif; - } else { - lastif->ifa_next = (*ifap); - } - curif->ifa_name = strdup(ifreq.ifr_name); - curif->ifa_flags = ifreq.ifr_flags; curif->ifa_addr = sockaddr_dup(&ifreq.ifr_addr); curif->ifa_dstaddr = NULL; curif->ifa_data = NULL; @@ -310,7 +303,6 @@ int getifaddrs(struct ifaddrs **ifap) } curif->ifa_name = strdup(ifr->ifr_name); - curif->ifa_flags = ifr->ifr_flags; curif->ifa_addr = sockaddr_dup(&ifr->ifr_addr); curif->ifa_dstaddr = NULL; curif->ifa_data = NULL; @@ -322,10 +314,7 @@ int getifaddrs(struct ifaddrs **ifap) return -1; } - if (!(ifr->ifr_flags & IFF_UP)) { - freeaddrinfo(curif); - continue; - } + curif->ifa_flags = ifr->ifr_flags; if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) { freeaddrinfo(*ifap); diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index 5b95ae395c..c9f3301005 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -856,6 +856,25 @@ static int test_strptime(void) return libreplace_test_strptime(); } +static int test_getifaddrs(void) +{ + struct ifaddrs *ifa; + int ret; + + printf("test: getifaddrs\n"); + + ret = getifaddrs(&ifa); + if (ret != 0) { + printf("failure: getifaddrs\n"); + return false; + } + + freeifaddrs(ifa); + + printf("success: getifaddrs\n"); + return true; +} + struct torture_context; bool torture_local_replace(struct torture_context *ctx) { @@ -903,6 +922,7 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_MAX(); ret &= test_socketpair(); ret &= test_strptime(); + ret &= test_getifaddrs(); return ret; } -- cgit From 958864ccdf6062808433fc032577e7b175f027e0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 16 Dec 2007 03:22:13 +0100 Subject: r26469: Fix paths, only include IPv4 addresses for now. (This used to be commit fa9e3b6fa871b7541878f836ea54e882e614a3cf) --- source4/lib/replace/getifaddrs.c | 21 +++++++++++++-------- source4/lib/replace/getifaddrs.m4 | 13 +++++-------- source4/lib/replace/system/network.h | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index a4f16ddb76..e04c023209 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -360,20 +360,25 @@ int getifaddrs(struct ifaddrs **ifap) int main() { - struct ifaddrs *ifs; - int total = get_interfaces(ifaces, MAX_INTERFACES); - int i; - - int ret = getifaddrs(&ifs); + struct ifaddrs *ifs = NULL; + int ret; + + ret = getifaddrs(&ifs); if (ret != 0) { perror("getifaddrs() failed"); return 1; } while (ifs) { - printf("%-10s ", ifs->ifr_name); - printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifr_addr)->sin_addr)); - printf("NETMASK=%s\n", inet_ntoa(((struct sockaddr_in *)ifs->ifr_netmask)->sin_addr)); + printf("%-10s ", ifs->ifa_name); + if (ifs->ifa_addr != NULL && + ifs->ifa_addr->sa_family == AF_INET) { + printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifa_addr)->sin_addr)); + if (ifs->ifa_netmask != NULL) + printf("NETMASK=%s", inet_ntoa(((struct sockaddr_in *)ifs->ifa_netmask)->sin_addr)); + } + printf("\n"); + ifs = ifs->ifa_next; } return 0; } diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index f38827406d..7e6016ed8f 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -26,10 +26,8 @@ fi # # This tests need LIBS="$NSL_LIBS $SOCKET_LIBS" # -old_CFLAGS=$CFLAGS old_LIBS=$LIBS LIBS="$NSL_LIBS $SOCKET_LIBS" -CFLAGS="$CFLAGS -Ilib/replace" iface=no; ################## # look for a method of finding the list of network interfaces @@ -41,8 +39,8 @@ AC_TRY_RUN([ #define NO_CONFIG_H 1 #define HAVE_IFACE_GETIFADDRS 1 #define AUTOCONF_TEST 1 -#include "${srcdir-.}/lib/replace/replace.c" -#include "${srcdir-.}/lib/replace/getifaddrs.c"], +#include "$libreplacedir/replace.c" +#include "$libreplacedir/getifaddrs.c"], samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)]) CPPFLAGS="$SAVE_CPPFLAGS" if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then @@ -58,7 +56,7 @@ AC_TRY_RUN([ #define HAVE_IFACE_AIX 1 #define AUTOCONF_TEST 1 #undef _XOPEN_SOURCE_EXTENDED -#include "${srcdir-.}/lib/replace/getifaddrs.c"], +#include "$libreplacedir/getifaddrs.c"], samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)]) if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) @@ -71,7 +69,7 @@ AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[ AC_TRY_RUN([ #define HAVE_IFACE_IFCONF 1 #define AUTOCONF_TEST 1 -#include "${srcdir-.}/lib/replace/getifaddrs.c"], +#include "$libreplacedir/getifaddrs.c"], samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)]) if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) @@ -83,12 +81,11 @@ AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[ AC_TRY_RUN([ #define HAVE_IFACE_IFREQ 1 #define AUTOCONF_TEST 1 -#include "${srcdir-.}/lib/replace/getifaddrs.c"], +#include "$libreplacedir/getifaddrs.c"], samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)]) if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) fi fi -CFLAGS=$old_CFLAGS LIBS=$old_LIBS diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 45d84e0386..b8228687e3 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -102,7 +102,7 @@ const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); struct ifaddrs { struct ifaddrs *ifa_next; /* Pointer to next struct */ char *ifa_name; /* Interface name */ - u_int ifa_flags; /* Interface flags */ + unsigned int ifa_flags; /* Interface flags */ struct sockaddr *ifa_addr; /* Interface address */ struct sockaddr *ifa_netmask; /* Interface netmask */ struct sockaddr *ifa_dstaddr; /* P2P interface destination */ -- cgit From 9c80da07bfcac822ad7a5bfe839a5948475d0296 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 16 Dec 2007 14:50:11 +0100 Subject: r26470: Update README. (This used to be commit 51a78cfc3e72d6b32ef6c7a6079165a36863b908) --- source4/lib/replace/README | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index c61f78a951..268a1b15cf 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -60,6 +60,8 @@ getaddrinfo freeaddrinfo getnameinfo gai_strerror +getifaddrs +freeifaddrs Types: bool -- cgit From 70cea01a9ec0be4ef9fd141a16b52e8141a1c94a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 05:53:37 +0100 Subject: r26487: Cope with systems that don't have struct sockaddr.sa_len. (This used to be commit 56080469ab28ae5a2f456cced34814d9c33480c6) --- source4/lib/replace/getifaddrs.c | 11 +++++++++-- source4/lib/replace/getifaddrs.m4 | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index e04c023209..b681a8649c 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -53,10 +53,17 @@ void freeifaddrs(struct ifaddrs *ifp) struct sockaddr *sockaddr_dup(struct sockaddr *sa) { - struct sockaddr *ret = calloc(1, sa->sa_len); + struct sockaddr *ret; + socklen_t socklen; +#ifdef HAVE_SOCKADDR_SA_LEN + socklen = sa->sa_len; +#else + socklen = sizeof(struct sockaddr_storage); +#endif + ret = = calloc(1, socklen); if (ret == NULL) return NULL; - memcpy(ret, sa, sa->sa_len); + memcpy(ret, sa, socklen); return ret; } #endif diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 7e6016ed8f..85f08ee6c3 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -1,5 +1,11 @@ AC_CHECK_HEADERS([ifaddrs.h]) +dnl Used when getifaddrs is not available +AC_CHECK_MEMBERS([struct sockaddr.sa_len], + [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])], + [], + [#include ]) + dnl test for getifaddrs and freeifaddrs AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ AC_TRY_COMPILE([ -- cgit From 463d1f68d5fa0691c1919a10ff582d6e92facab9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 06:30:50 +0100 Subject: r26491: Fix syntax. (This used to be commit 2513230e286179747bb84e4e87121b80bea8f3f0) --- source4/lib/replace/getifaddrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index b681a8649c..c9b5c2f6ef 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -60,7 +60,7 @@ struct sockaddr *sockaddr_dup(struct sockaddr *sa) #else socklen = sizeof(struct sockaddr_storage); #endif - ret = = calloc(1, socklen); + ret = calloc(1, socklen); if (ret == NULL) return NULL; memcpy(ret, sa, socklen); -- cgit From af3c0b932402b5eb07121d1ea30570fe5b9d171c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 06:57:30 +0100 Subject: r26492: Some hosts have a define called ifa_dstaddr. (This used to be commit c4cd935ee783b2f4939e2c481bbdb1bbdb9190cd) --- source4/lib/replace/system/network.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index b8228687e3..c340cca657 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -105,6 +105,7 @@ struct ifaddrs { unsigned int ifa_flags; /* Interface flags */ struct sockaddr *ifa_addr; /* Interface address */ struct sockaddr *ifa_netmask; /* Interface netmask */ +#undef ifa_dstaddr struct sockaddr *ifa_dstaddr; /* P2P interface destination */ void *ifa_data; /* Address specific data */ }; -- cgit From 7c34f488278ba7513d3bf4ca9eb7867d5008c140 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 07:45:05 +0100 Subject: r26495: Add defines for getifaddrs/freeifaddrs. (This used to be commit c9e5a3078f7baa83743658d5648f0eefdeb05d2f) --- source4/lib/replace/replace.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 973c68ee14..f8a89a7213 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -340,6 +340,16 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) /* prototype is in "system/network.h" */ #endif +#ifndef HAVE_GETIFADDRS +#define getifaddrs rep_getifaddrs +/* prototype is in "system/network.h" */ +#endif + +#ifndef HAVE_FREEIFADDRS +#define freeifaddrs rep_freeifaddrs +/* prototype is in "system/network.h" */ +#endif + #ifdef HAVE_LIMITS_H #include #endif -- cgit From 83655ec0dd58c21cdb99d5e7c8008b4b3087449b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 08:20:29 +0100 Subject: r26497: Fix return type for freeifaddrs(). (This used to be commit 8c65053f51330bb55a81572264eefbcc56029dc1) --- source4/lib/replace/getifaddrs.c | 12 ++++++------ source4/lib/replace/system/network.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index c9b5c2f6ef..4037d647d7 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -40,7 +40,7 @@ #define _FOUND_IFACE_ANY #else -void freeifaddrs(struct ifaddrs *ifp) +void rep_freeifaddrs(struct ifaddrs *ifp) { free(ifp->ifa_name); free(ifp->ifa_addr); @@ -51,7 +51,7 @@ void freeifaddrs(struct ifaddrs *ifp) free(ifp); } -struct sockaddr *sockaddr_dup(struct sockaddr *sa) +static struct sockaddr *sockaddr_dup(struct sockaddr *sa) { struct sockaddr *ret; socklen_t socklen; @@ -75,7 +75,7 @@ struct sockaddr *sockaddr_dup(struct sockaddr *sa) It probably also works on any BSD style system. */ -int getifaddrs(struct ifaddrs **ifap) +int rep_getifaddrs(struct ifaddrs **ifap) { struct ifconf ifc; char buff[8192]; @@ -159,7 +159,7 @@ int getifaddrs(struct ifaddrs **ifap) this should cover most of the streams based systems Thanks to Andrej.Borsenkow@mow.siemens.ru for several ideas in this code ****************************************************************************/ -int getifaddrs(struct ifaddrs **ifap) +int rep_getifaddrs(struct ifaddrs **ifap) { struct ifreq ifreq; struct strioctl strioctl; @@ -261,7 +261,7 @@ int getifaddrs(struct ifaddrs **ifap) /**************************************************************************** this one is for AIX (tested on 4.2) ****************************************************************************/ -int getifaddrs(struct ifaddrs **ifap) +int rep_getifaddrs(struct ifaddrs **ifap) { char buff[8192]; int fd, i; @@ -355,7 +355,7 @@ int getifaddrs(struct ifaddrs **ifap) #define _FOUND_IFACE_ANY #endif /* HAVE_IFACE_AIX */ #ifndef _FOUND_IFACE_ANY -int getifaddrs(struct ifaddrs **ifap) +int rep_getifaddrs(struct ifaddrs **ifap) { errno = ENOSYS; return -1; diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index c340cca657..853c2a38bb 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -116,7 +116,7 @@ int rep_getifaddrs(struct ifaddrs **); #endif #ifndef HAVE_FREEIFADDRS -int rep_freeifaddrs(struct ifaddrs **); +void rep_freeifaddrs(struct ifaddrs **); #endif /* -- cgit From 89f34bb2133a125b1ddffbda30703bf7c551fb55 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 12:27:59 +0100 Subject: r26507: Fix function signature for freeifaddrs. (This used to be commit cc873bdd2e86e5b380c3056810ccc5ad98372f7c) --- source4/lib/replace/system/network.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 853c2a38bb..f72b233712 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -116,7 +116,7 @@ int rep_getifaddrs(struct ifaddrs **); #endif #ifndef HAVE_FREEIFADDRS -void rep_freeifaddrs(struct ifaddrs **); +void rep_freeifaddrs(struct ifaddrs *); #endif /* -- cgit From 93378b9893235596f2c88144e17a5809fefe5bc7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 17:40:57 +0100 Subject: r26510: attempt to fix shld flags for darwin. (This used to be commit 5dbe3aff3c34f64f35f1e13a11c60c5023348919) --- source4/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index a2e43bbe13..2652f89cb6 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -142,7 +142,7 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_FLAGS], LD_SHLIB_FLAGS="-shared" ;; *darwin*) - LD_SHLIB_FLAGS="-bundle -flat_namespace -Wl,-search_paths_first" + LD_SHLIB_FLAGS="-bundle -dynamiclib -Wl,-search_paths_first" ;; esac -- cgit From fe6faa4df2c693ec2b5d820fc15c4d1180a7fe9b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 19:18:55 +0100 Subject: r26512: Another attempt at fixing darwin (This used to be commit 4fa04924ab41bd6ad1a0c6d8d9b1987bf09d5270) --- source4/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 2652f89cb6..c317680a9a 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -142,7 +142,7 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_FLAGS], LD_SHLIB_FLAGS="-shared" ;; *darwin*) - LD_SHLIB_FLAGS="-bundle -dynamiclib -Wl,-search_paths_first" + LD_SHLIB_FLAGS="-dynamiclib -Wl,-search_paths_first" ;; esac -- cgit From 9d71dba42e3d4a31079c28ed6a456bfdfad7f124 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 19 Dec 2007 08:18:57 +0100 Subject: r26533: libreplace: hopefully fix the share library/module build on darwin metze (This used to be commit 3d64338f3cfeef2e9851ca8c932863af6f1f22c3) --- source4/lib/replace/libreplace_ld.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index c317680a9a..cb8e21434e 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -164,7 +164,7 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_DISALLOW_UNDEF_FLAG], LD_SHLIB_DISALLOW_UNDEF_FLAG="-warning_unresolved" ;; *darwin*) - LD_SHLIB_DISALLOW_UNDEF_FLAG="-undefined warning" + LD_SHLIB_DISALLOW_UNDEF_FLAG="-undefined error" ;; esac @@ -268,7 +268,7 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG], LD_SHLIB_ALLOW_UNDEF_FLAG="-expect_unresolved '*'" ;; *darwin*) - LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined suppress" + LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup" ;; esac -- cgit From 3e75f222bcdf114238cc4f2bcc61332dc059135f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 19 Dec 2007 23:27:42 +0100 Subject: r26539: Remove unnecessary statics. (This used to be commit e53e79eebef3ece6978f0a2b4a1ee0a0814bb5d2) --- source4/lib/replace/inet_ntop.c | 2 +- source4/lib/replace/inet_pton.c | 4 ++-- source4/lib/replace/timegm.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/inet_ntop.c b/source4/lib/replace/inet_ntop.c index fb3d8e90c8..1b84cda6f0 100644 --- a/source4/lib/replace/inet_ntop.c +++ b/source4/lib/replace/inet_ntop.c @@ -74,7 +74,7 @@ rep_inet_ntop(int af, const void *src, char *dst, socklen_t size) static const char * inet_ntop4(const unsigned char *src, char *dst, socklen_t size) { - static const char *fmt = "%u.%u.%u.%u"; + const char *fmt = "%u.%u.%u.%u"; char tmp[sizeof "255.255.255.255"]; size_t len; diff --git a/source4/lib/replace/inet_pton.c b/source4/lib/replace/inet_pton.c index 80e4865ef4..ea0fe6b78c 100644 --- a/source4/lib/replace/inet_pton.c +++ b/source4/lib/replace/inet_pton.c @@ -77,7 +77,7 @@ inet_pton4(src, dst) const char *src; unsigned char *dst; { - static const char digits[] = "0123456789"; + const char digits[] = "0123456789"; int saw_digit, octets, ch; unsigned char tmp[NS_INADDRSZ], *tp; @@ -131,7 +131,7 @@ inet_pton6(src, dst) const char *src; unsigned char *dst; { - static const char xdigits_l[] = "0123456789abcdef", + const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF"; unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; const char *xdigits, *curtok; diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c index 395c684e11..86f360bd3c 100644 --- a/source4/lib/replace/timegm.c +++ b/source4/lib/replace/timegm.c @@ -46,7 +46,7 @@ static int is_leap(unsigned y) time_t rep_timegm(struct tm *tm) { - static const unsigned ndays[2][12] ={ + const unsigned ndays[2][12] ={ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; time_t res = 0; -- cgit From 0500b87092540d300b4e021a0fb95ce16a44fbd2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Dec 2007 00:02:15 +0100 Subject: r26540: Revert my previous commit after concerns raised by Andrew. (This used to be commit 6ac86f8be7d9a8c5ab396a93e6d1e6819e11f173) --- source4/lib/replace/inet_ntop.c | 2 +- source4/lib/replace/inet_pton.c | 4 ++-- source4/lib/replace/timegm.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/inet_ntop.c b/source4/lib/replace/inet_ntop.c index 1b84cda6f0..fb3d8e90c8 100644 --- a/source4/lib/replace/inet_ntop.c +++ b/source4/lib/replace/inet_ntop.c @@ -74,7 +74,7 @@ rep_inet_ntop(int af, const void *src, char *dst, socklen_t size) static const char * inet_ntop4(const unsigned char *src, char *dst, socklen_t size) { - const char *fmt = "%u.%u.%u.%u"; + static const char *fmt = "%u.%u.%u.%u"; char tmp[sizeof "255.255.255.255"]; size_t len; diff --git a/source4/lib/replace/inet_pton.c b/source4/lib/replace/inet_pton.c index ea0fe6b78c..80e4865ef4 100644 --- a/source4/lib/replace/inet_pton.c +++ b/source4/lib/replace/inet_pton.c @@ -77,7 +77,7 @@ inet_pton4(src, dst) const char *src; unsigned char *dst; { - const char digits[] = "0123456789"; + static const char digits[] = "0123456789"; int saw_digit, octets, ch; unsigned char tmp[NS_INADDRSZ], *tp; @@ -131,7 +131,7 @@ inet_pton6(src, dst) const char *src; unsigned char *dst; { - const char xdigits_l[] = "0123456789abcdef", + static const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF"; unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; const char *xdigits, *curtok; diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c index 86f360bd3c..395c684e11 100644 --- a/source4/lib/replace/timegm.c +++ b/source4/lib/replace/timegm.c @@ -46,7 +46,7 @@ static int is_leap(unsigned y) time_t rep_timegm(struct tm *tm) { - const unsigned ndays[2][12] ={ + static const unsigned ndays[2][12] ={ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; time_t res = 0; -- cgit From 6afef7d624fbf734d93ebfe95689a282b202aa3c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 20 Dec 2007 15:59:39 +0100 Subject: r26550: libreplace: fallback to __ss_family of struct sockaddr_storage metze (This used to be commit 11bdc9bed80b9842ac1ab8f22509a5d191cddc91) --- source4/lib/replace/libreplace.m4 | 20 ++++++++++++++++++++ source4/lib/replace/system/network.h | 9 +++++++++ 2 files changed, 29 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 7e456b4d03..a577285639 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -152,6 +152,26 @@ AC_HAVE_TYPE([struct sockaddr_in6], [ #include ]) +if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then +AC_CHECK_MEMBER(struct sockaddr_storage.ss_family, + AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),, + [ +#include +#include +#include + ]) + +if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then +AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family, + AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),, + [ +#include +#include +#include + ]) +fi +fi + AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index f72b233712..e2fad5f686 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -249,9 +249,18 @@ typedef unsigned short int sa_family_t; #ifdef HAVE_STRUCT_SOCKADDR_IN6 #define sockaddr_storage sockaddr_in6 #define ss_family sin6_family +#define HAVE_SS_FAMILY 1 #else #define sockaddr_storage sockaddr_in #define ss_family sin_family +#define HAVE_SS_FAMILY 1 +#endif +#endif + +#ifndef HAVE_SS_FAMILY +#ifdef HAVE___SS_FAMILY +#define ss_family __ss_family +#define HAVE_SS_FAMILY 1 #endif #endif -- cgit From bf20aa02e6dc5934d693eacfa0b30a771f03bc63 Mon Sep 17 00:00:00 2001 From: James Peach Date: Thu, 20 Dec 2007 16:35:42 +0100 Subject: r26551: Make sure NULL is defined before using it to test for getifaddrs(). Patch from Timur I. Bakeyev . (This used to be commit 188156228b53c4bbc9c18c6ff1a0d3c6d0ba5fcb) --- source4/lib/replace/getifaddrs.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 85f08ee6c3..30b9d0264f 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -11,6 +11,10 @@ AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ AC_TRY_COMPILE([ #include #include +#if STDC_HEADERS +#include +#include +#endif #include #include #include -- cgit From 6890891b5f909f6b7a1c156d7dd0f811d7f8559d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Dec 2007 17:07:31 +0100 Subject: r26554: Fix test for getifaddr on FreeBSD. Patch by Timur Bakeyev. (This used to be commit 37c7b65546190bdce40cb48435cc4fd51d89a124) --- source4/lib/replace/getifaddrs.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 30b9d0264f..297a82d0c3 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -9,12 +9,12 @@ AC_CHECK_MEMBERS([struct sockaddr.sa_len], dnl test for getifaddrs and freeifaddrs AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ AC_TRY_COMPILE([ -#include #include #if STDC_HEADERS #include #include #endif +#include #include #include #include -- cgit From 1e19c859a337422faac5b34b6a370492d98ab3b2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 04:46:11 +0100 Subject: Try to fix the build on Tru64; avoid single quotes because they get expanded by perl in the build system. (This used to be commit bba8914af56cb161c275fbbdea2479d6f8bd703c) --- source4/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index cb8e21434e..0ca6f7a34d 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -265,7 +265,7 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG], LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,--allow-shlib-undefined" ;; *osf*) - LD_SHLIB_ALLOW_UNDEF_FLAG="-expect_unresolved '*'" + LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-expect_unresolved,*" ;; *darwin*) LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup" -- cgit From 2e02bb5289b78aab2158d56fd187ef1addd0c8de Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 22:24:07 +0100 Subject: libreplace: Escape asterisk. (This used to be commit df36c78549b40ee5e47d5cc79de2eb79f58c567a) --- source4/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 0ca6f7a34d..2aec698967 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -265,7 +265,7 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG], LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,--allow-shlib-undefined" ;; *osf*) - LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-expect_unresolved,*" + LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-expect_unresolved,\"*\"" ;; *darwin*) LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup" -- cgit From 50ba04f51258abed6405ff0c8a6e1ea324ab5892 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 10 Nov 2007 22:31:34 -0800 Subject: Always define PATH_MAX. Makes code simpler (removes a bunch of #defines). Remove pstring from msdfs.c. Jeremy. (lib/replace part from e203ba22275320808bc11b17361ad1f2d5b0b897 metze) (This used to be commit ebc08d23f76ecffc90b1fe84c67fc7e6a4c4a6a3) --- source4/lib/replace/replace.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index f8a89a7213..3557684071 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -546,4 +546,8 @@ typedef int bool; #define QSORT_CAST (int (*)(const void *, const void *)) #endif +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + #endif /* _LIBREPLACE_REPLACE_H */ -- cgit From 0aed6d4125a2c9b525e1119b72c36b651dd4ef3f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Nov 2007 18:27:26 -0800 Subject: Add MAX_DNS_NAME_LENGTH, remove more pstrings. Jeremy. (lib/replace part of a1725f4ff7ed375808c78ac661b539557748d0a5 metze) (This used to be commit db4eabf7cde1008a40a46e5c40a99e9a73cf3ff5) --- source4/lib/replace/replace.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 3557684071..3f91544e97 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -550,4 +550,8 @@ typedef int bool; #define PATH_MAX 1024 #endif +#ifndef MAX_DNS_NAME_LENGTH +#define MAX_DNS_NAME_LENGTH 256 /* Actually 255 but +1 for terminating null. */ +#endif + #endif /* _LIBREPLACE_REPLACE_H */ -- cgit From bab53c5e53bac25b7031838953de6083dbbfbc5d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 26 Nov 2007 15:28:13 +0100 Subject: Fix bug 5055 (lib/replace part of 8bcd2df841bae63e7d58c35d4728b7d853471697 metze) (This used to be commit 8db9e196506f530c780d93e16da590566d16a407) --- source4/lib/replace/replace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index cec158be31..b2a240e8ab 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -218,7 +218,7 @@ long nap(long milliseconds) { #ifndef HAVE_MEMMOVE /******************************************************************* safely copies memory, ensuring no overlap problems. -this is only used if the machine does not have it's own memmove(). +this is only used if the machine does not have its own memmove(). this is not the fastest algorithm in town, but it will do for our needs. ********************************************************************/ -- cgit From 645c6518d75c683865a29d1b8c49247a092399da Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Dec 2007 13:16:35 -0800 Subject: Add patches for bug #4866 from jiri sasek - Sun Microsystems - Prague Czech Republic - slightly modified - Jiri please check ! to allow Solaris to get passwords > 8 chars. Jeremy. (lib/replace part of 657bf8c3479d6192f269e3daef1517e77a9fa9cb metze) (This used to be commit 9f5c443972a09a70de7c8d6695b08c3730484c6c) --- source4/lib/replace/getpass.m4 | 10 ++++++++++ source4/lib/replace/system/passwd.h | 4 ++++ 2 files changed, 14 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.m4 b/source4/lib/replace/getpass.m4 index 17dfdf7bf5..c4da9aae59 100644 --- a/source4/lib/replace/getpass.m4 +++ b/source4/lib/replace/getpass.m4 @@ -1,3 +1,11 @@ +AC_CHECK_FUNC(getpass, samba_cv_HAVE_GETPASS=yes) +AC_CHECK_FUNC(getpassphrase, samba_cv_HAVE_GETPASSPHRASE=yes) +if test x"$samba_cv_HAVE_GETPASS" = x"yes" -a x"$samba_cv_HAVE_GETPASSPHRASE" = x"yes"; then + AC_DEFINE(REPLACE_GETPASS_BY_GETPASSPHRASE, 1, [getpass returns <9 chars where getpassphrase returns <265 chars]) + AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced]) + LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o" +else + AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[ SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$libreplacedir/" @@ -12,3 +20,5 @@ if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced]) LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o" fi + +fi diff --git a/source4/lib/replace/system/passwd.h b/source4/lib/replace/system/passwd.h index 36fca7b4f8..cad3197ccb 100644 --- a/source4/lib/replace/system/passwd.h +++ b/source4/lib/replace/system/passwd.h @@ -68,9 +68,13 @@ #endif #ifdef REPLACE_GETPASS +#if defined(REPLACE_GETPASS_BY_GETPASSPHRASE) +#define getpass(prompt) getpassphrase(prompt) +#else #define getpass(prompt) rep_getpass(prompt) char *rep_getpass(const char *prompt); #endif +#endif #ifndef NGROUPS_MAX #define NGROUPS_MAX 32 /* Guess... */ -- cgit From b1fcae724156c2b25f41264943cf4cec8fe68821 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 17 Dec 2007 10:44:09 -0800 Subject: Fix bug #5121 (unix passwd sync not working on a streams based system). Jeremy. (lib/replace part of 545cd2139cfc9484b733693814d4724d37125942 metze) (This used to be commit 9cff25cce1d39460dbcab006a309bb2984969eed) --- source4/lib/replace/libreplace.m4 | 1 + source4/lib/replace/system/network.h | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index a577285639..6d1d6b8afc 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -100,6 +100,7 @@ AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) AC_CHECK_HEADERS(sys/sockio.h sys/un.h) AC_CHECK_HEADERS(sys/mount.h mntent.h) +AC_CHECK_HEADERS(stropts.h) dnl we need to check that net/if.h really can be used, to cope with hpux dnl where including it always fails diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index e2fad5f686..53bef66d48 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -79,6 +79,10 @@ #include #endif +#ifdef HAVE_STROPTS_H +#include +#endif + #ifdef REPLACE_INET_NTOA /* define is in "replace.h" */ char *rep_inet_ntoa(struct in_addr ip); -- cgit From adbbc8dcc65997d4c2a555f188a980e6622a309d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 22 Jan 2008 12:21:55 +0100 Subject: libreplace: getpwent_r/getgrent_r on IRIX are similar to solaris but use size_t metze (cherry picked from commit 2f460915111066d79f5dc9b4ae4d003918d06852) (This used to be commit d2ac8be28d3aff59eddbdc6189a255a34c10d502) --- source4/lib/replace/system/config.m4 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 index 799187af7d..1c05733126 100644 --- a/source4/lib/replace/system/config.m4 +++ b/source4/lib/replace/system/config.m4 @@ -73,6 +73,18 @@ AC_VERIFY_C_PROTOTYPE([struct passwd *getpwent_r(struct passwd *src, char *buf, #include #include ]) +AC_VERIFY_C_PROTOTYPE([struct passwd *getpwent_r(struct passwd *src, char *buf, size_t buflen)], + [ + #ifndef HAVE_GETPWENT_R_DECL + #error missing getpwent_r prototype + #endif + return NULL; + ],[ + AC_DEFINE(SOLARIS_GETPWENT_R, 1, [getpwent_r irix (similar to solaris) function prototype]) + ],[],[ + #include + #include + ]) AC_CHECK_FUNCS(getgrnam_r getgrgid_r getgrent_r) AC_HAVE_DECL(getgrent_r, [ #include @@ -91,6 +103,19 @@ AC_VERIFY_C_PROTOTYPE([struct group *getgrent_r(struct group *src, char *buf, in #include ]) +AC_VERIFY_C_PROTOTYPE([struct group *getgrent_r(struct group *src, char *buf, size_t buflen)], + [ + #ifndef HAVE_GETGRENT_R_DECL + #error missing getgrent_r prototype + #endif + return NULL; + ],[ + AC_DEFINE(SOLARIS_GETGRENT_R, 1, [getgrent_r irix (similar to solaris) function prototype]) + ],[],[ + #include + #include + ]) + # locale AC_CHECK_HEADERS(ctype.h locale.h) -- cgit From 5233e43ec7e96afb905f026309b0894178c96499 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 19 Feb 2008 17:25:42 +0100 Subject: Remove relict SAMBA_CONFIGURE_CPPFLAGS from lib/replace. Michael (This used to be commit d10cbb533c18a6d74160477d34a81bbd4cd6c7c8) --- source4/lib/replace/getifaddrs.m4 | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 297a82d0c3..4259d1a7a3 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -43,8 +43,6 @@ iface=no; # look for a method of finding the list of network interfaces iface=no; AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[ -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}" AC_TRY_RUN([ #define NO_CONFIG_H 1 #define HAVE_IFACE_GETIFADDRS 1 @@ -52,7 +50,6 @@ AC_TRY_RUN([ #include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)]) -CPPFLAGS="$SAVE_CPPFLAGS" if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) else -- cgit From 62e849d918e76ac27096999792c46e3230b0663a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 1 Feb 2008 20:03:05 +0100 Subject: NetBSD needs LD_LIBRARY_PATH (cherry picked from commit d64b19e77aa499c1ee1aaf788ddf3d6fd36253e4) (This used to be commit 4c77550d80b0cfc80bc2cac500fc27e0c43dad64) --- source4/lib/replace/libreplace_ld.m4 | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 2aec698967..f0d10c1e3e 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -289,6 +289,9 @@ AC_DEFUN([AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR], *linux*) LIB_PATH_VAR=LD_LIBRARY_PATH ;; + *netbsd*) + LIB_PATH_VAR=LD_LIBRARY_PATH + ;; *solaris*) LIB_PATH_VAR=LD_LIBRARY_PATH ;; -- cgit From db2447a7a2b1d39a6849b53f7864e9283daacb6a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 1 Feb 2008 14:23:56 +0100 Subject: NetBSD does not support AI_ADDRCONFIG (cherry picked from commit fb3f7f4046fa195baf5116598772d9016238637f) (This used to be commit e8f3653414c12fb752c096d848dc962008d90439) --- source4/lib/replace/system/network.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 53bef66d48..d09e3f71f8 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -163,8 +163,15 @@ void rep_freeifaddrs(struct ifaddrs *); #endif #ifndef AI_ADDRCONFIG +/* + * logic copied from AI_NUMERICHOST + */ +#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO) +#define AI_ADDRCONFIG 0 +#else #define AI_ADDRCONFIG 0x0020 #endif +#endif #ifndef AI_NUMERICSERV /* -- cgit From 8f57595c18a51161db93cd05730be37bcb850a17 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 12:43:37 +0100 Subject: libreplace: change samba_cv_ to libreplace_cv_ in getifaddrs.m4 Michael (This used to be commit acab9def2a1e3460bef8baae6efc66d9dfad6eac) --- source4/lib/replace/getifaddrs.m4 | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 4259d1a7a3..4cf86d89cc 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -7,7 +7,7 @@ AC_CHECK_MEMBERS([struct sockaddr.sa_len], [#include ]) dnl test for getifaddrs and freeifaddrs -AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ +AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[ AC_TRY_COMPILE([ #include #if STDC_HEADERS @@ -24,8 +24,8 @@ struct ifaddrs *ifp = NULL; int ret = getifaddrs (&ifp); freeifaddrs(ifp); ], -samba_cv_HAVE_GETIFADDRS=yes,samba_cv_HAVE_GETIFADDRS=no)]) -if test x"$samba_cv_HAVE_GETIFADDRS" = x"yes"; then +libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)]) +if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs]) AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs]) AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available]) @@ -42,15 +42,15 @@ iface=no; ################## # look for a method of finding the list of network interfaces iface=no; -AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[ +AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[ AC_TRY_RUN([ #define NO_CONFIG_H 1 #define HAVE_IFACE_GETIFADDRS 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], - samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)]) -if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then + libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) else LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o" @@ -58,39 +58,39 @@ fi if test $iface = no; then -AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[ +AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ AC_TRY_RUN([ #define HAVE_IFACE_AIX 1 #define AUTOCONF_TEST 1 #undef _XOPEN_SOURCE_EXTENDED #include "$libreplacedir/getifaddrs.c"], - samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)]) -if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then + libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) fi fi if test $iface = no; then -AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[ +AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ AC_TRY_RUN([ #define HAVE_IFACE_IFCONF 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/getifaddrs.c"], - samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)]) -if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then + libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) fi fi if test $iface = no; then -AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[ +AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ AC_TRY_RUN([ #define HAVE_IFACE_IFREQ 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/getifaddrs.c"], - samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)]) -if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then + libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) fi fi -- cgit From 7f3913659f150ca7020177ab85f9c36b908807a9 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 12:46:20 +0100 Subject: libreplace: change samba_cv_ to libreplace_cv_ in getpass.m4. Michael (This used to be commit d3b3d3ec9ff64108b4cd5b7c912ab4ea207256cb) --- source4/lib/replace/getpass.m4 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.m4 b/source4/lib/replace/getpass.m4 index c4da9aae59..b93817f9d3 100644 --- a/source4/lib/replace/getpass.m4 +++ b/source4/lib/replace/getpass.m4 @@ -1,22 +1,22 @@ -AC_CHECK_FUNC(getpass, samba_cv_HAVE_GETPASS=yes) -AC_CHECK_FUNC(getpassphrase, samba_cv_HAVE_GETPASSPHRASE=yes) -if test x"$samba_cv_HAVE_GETPASS" = x"yes" -a x"$samba_cv_HAVE_GETPASSPHRASE" = x"yes"; then +AC_CHECK_FUNC(getpass, libreplace_cv_HAVE_GETPASS=yes) +AC_CHECK_FUNC(getpassphrase, libreplace_cv_HAVE_GETPASSPHRASE=yes) +if test x"$libreplace_cv_HAVE_GETPASS" = x"yes" -a x"$libreplace_cv_HAVE_GETPASSPHRASE" = x"yes"; then AC_DEFINE(REPLACE_GETPASS_BY_GETPASSPHRASE, 1, [getpass returns <9 chars where getpassphrase returns <265 chars]) AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced]) LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o" else -AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[ +AC_CACHE_CHECK([whether getpass should be replaced],libreplace_cv_REPLACE_GETPASS,[ SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$libreplacedir/" AC_TRY_COMPILE([ #include "confdefs.h" #define NO_CONFIG_H #include "$libreplacedir/getpass.c" -],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no) +],[],libreplace_cv_REPLACE_GETPASS=yes,libreplace_cv_REPLACE_GETPASS=no) CPPFLAGS="$SAVE_CPPFLAGS" ]) -if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then +if test x"$libreplace_cv_REPLACE_GETPASS" = x"yes"; then AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced]) LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o" fi -- cgit From ab665b0b0553f7909a217373d0690d99bd80d2db Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 12:49:30 +0100 Subject: libreplace: change samba_cv_ to libreplace_cv_ in system/config.m4. Michael (This used to be commit 00c173bfba9c659750bf231fbd9278dd38aa8bfc) --- source4/lib/replace/system/config.m4 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 index 1c05733126..66c2bd652a 100644 --- a/source4/lib/replace/system/config.m4 +++ b/source4/lib/replace/system/config.m4 @@ -18,7 +18,7 @@ AC_CHECK_HEADERS(sys/capability.h) case "$host_os" in *linux*) -AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[ +AC_CACHE_CHECK([for broken RedHat 7.2 system header files],libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[ AC_TRY_COMPILE([ #ifdef HAVE_SYS_VFS_H #include @@ -29,14 +29,14 @@ AC_TRY_COMPILE([ ],[ int i; ], - samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no, - samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes + libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no, + libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes )]) -if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then +if test x"$libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files]) fi -AC_CACHE_CHECK([for broken RHEL5 sys/capability.h],samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER,[ +AC_CACHE_CHECK([for broken RHEL5 sys/capability.h],libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER,[ AC_TRY_COMPILE([ #ifdef HAVE_SYS_CAPABILITY_H #include @@ -45,10 +45,10 @@ AC_TRY_COMPILE([ ],[ __s8 i; ], - samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER=no, - samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER=yes + libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER=no, + libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER=yes )]) -if test x"$samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER" = x"yes"; then +if test x"$libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER" = x"yes"; then AC_DEFINE(BROKEN_RHEL5_SYS_CAP_HEADER,1,[Broken RHEL5 sys/capability.h]) fi ;; -- cgit From 2c134f3cd5de1851c8cb5900b830cca25892d735 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 20 Feb 2008 12:53:07 +0100 Subject: libreplace: change samba_cv_ to libreplace_cv_ in libreplace.m4. Michael (This used to be commit 83387ecccfe95b80525bf53c5fc9e945ffee10ec) --- source4/lib/replace/libreplace.m4 | 72 +++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 6d1d6b8afc..2e0cd34f4a 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -85,10 +85,10 @@ AC_INCLUDES_DEFAULT #endif] ) -AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[ +AC_CACHE_CHECK([for working mmap],libreplace_cv_HAVE_MMAP,[ AC_TRY_RUN([#include "$libreplacedir/test/shared_mmap.c"], - samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)]) -if test x"$samba_cv_HAVE_MMAP" = x"yes"; then + libreplace_cv_HAVE_MMAP=yes,libreplace_cv_HAVE_MMAP=no,libreplace_cv_HAVE_MMAP=cross)]) +if test x"$libreplace_cv_HAVE_MMAP" = x"yes"; then AC_DEFINE(HAVE_MMAP,1,[Whether mmap works]) fi @@ -120,7 +120,7 @@ if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) fi -AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[ +AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ #include #include @@ -133,8 +133,8 @@ main() { struct in_addr ip; ip.s_addr = 0x12345678; if (strcmp(inet_ntoa(ip),"18.52.86.120") && strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } exit(1);}], - samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)]) -if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then + libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) +if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) fi @@ -182,7 +182,7 @@ AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) -AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[ +AC_CACHE_CHECK([for secure mkstemp],libreplace_cv_HAVE_SECURE_MKSTEMP,[ AC_TRY_RUN([#include #include #include @@ -197,10 +197,10 @@ main() { if ((st.st_mode & 0777) != 0600) exit(1); exit(0); }], -samba_cv_HAVE_SECURE_MKSTEMP=yes, -samba_cv_HAVE_SECURE_MKSTEMP=no, -samba_cv_HAVE_SECURE_MKSTEMP=cross)]) -if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then +libreplace_cv_HAVE_SECURE_MKSTEMP=yes, +libreplace_cv_HAVE_SECURE_MKSTEMP=no, +libreplace_cv_HAVE_SECURE_MKSTEMP=cross)]) +if test x"$libreplace_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure]) fi @@ -209,7 +209,7 @@ AC_CHECK_HEADERS(stdio.h strings.h) AC_CHECK_DECLS([snprintf, vsnprintf, asprintf, vasprintf]) AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf) -AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[ +AC_CACHE_CHECK([for C99 vsnprintf],libreplace_cv_HAVE_C99_VSNPRINTF,[ AC_TRY_RUN([ #include #include @@ -243,43 +243,43 @@ void foo(const char *format, ...) { } main() { foo("hello"); } ], -samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)]) -if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then +libreplace_cv_HAVE_C99_VSNPRINTF=yes,libreplace_cv_HAVE_C99_VSNPRINTF=no,libreplace_cv_HAVE_C99_VSNPRINTF=cross)]) +if test x"$libreplace_cv_HAVE_C99_VSNPRINTF" = x"yes"; then AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf]) fi dnl VA_COPY -AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[ +AC_CACHE_CHECK([for va_copy],libreplace_cv_HAVE_VA_COPY,[ AC_TRY_LINK([#include va_list ap1,ap2;], [va_copy(ap1,ap2);], -samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)]) -if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then +libreplace_cv_HAVE_VA_COPY=yes,libreplace_cv_HAVE_VA_COPY=no)]) +if test x"$libreplace_cv_HAVE_VA_COPY" = x"yes"; then AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) fi -if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then -AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[ +if test x"$libreplace_cv_HAVE_VA_COPY" != x"yes"; then +AC_CACHE_CHECK([for __va_copy],libreplace_cv_HAVE___VA_COPY,[ AC_TRY_LINK([#include va_list ap1,ap2;], [__va_copy(ap1,ap2);], -samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)]) -if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then +libreplace_cv_HAVE___VA_COPY=yes,libreplace_cv_HAVE___VA_COPY=no)]) +if test x"$libreplace_cv_HAVE___VA_COPY" = x"yes"; then AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available]) fi fi dnl __FUNCTION__ macro -AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[ +AC_CACHE_CHECK([for __FUNCTION__ macro],libreplace_cv_HAVE_FUNCTION_MACRO,[ AC_TRY_COMPILE([#include ], [printf("%s\n", __FUNCTION__);], -samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)]) -if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then +libreplace_cv_HAVE_FUNCTION_MACRO=yes,libreplace_cv_HAVE_FUNCTION_MACRO=no)]) +if test x"$libreplace_cv_HAVE_FUNCTION_MACRO" = x"yes"; then AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro]) else dnl __func__ macro - AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[ + AC_CACHE_CHECK([for __func__ macro],libreplace_cv_HAVE_func_MACRO,[ AC_TRY_COMPILE([#include ], [printf("%s\n", __func__);], - samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)]) - if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then + libreplace_cv_HAVE_func_MACRO=yes,libreplace_cv_HAVE_func_MACRO=no)]) + if test x"$libreplace_cv_HAVE_func_MACRO" = x"yes"; then AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro]) fi fi @@ -302,7 +302,7 @@ eprintf("bla", "bar"); ], AC_DEFINE(HAVE__VA_ARGS__MACRO, 1, [Whether the __VA_ARGS__ macro is available])) -AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ +AC_CACHE_CHECK([for sig_atomic_t type],libreplace_cv_sig_atomic_t, [ AC_TRY_COMPILE([ #include #if STDC_HEADERS @@ -310,30 +310,30 @@ AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [ #include #endif #include ],[sig_atomic_t i = 0], - samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)]) -if test x"$samba_cv_sig_atomic_t" = x"yes"; then + libreplace_cv_sig_atomic_t=yes,libreplace_cv_sig_atomic_t=no)]) +if test x"$libreplace_cv_sig_atomic_t" = x"yes"; then AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type]) fi -AC_CACHE_CHECK([for O_DIRECT flag to open(2)],samba_cv_HAVE_OPEN_O_DIRECT,[ +AC_CACHE_CHECK([for O_DIRECT flag to open(2)],libreplace_cv_HAVE_OPEN_O_DIRECT,[ AC_TRY_COMPILE([ #include #ifdef HAVE_FCNTL_H #include #endif], [int fd = open("/dev/null", O_DIRECT);], -samba_cv_HAVE_OPEN_O_DIRECT=yes,samba_cv_HAVE_OPEN_O_DIRECT=no)]) -if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then +libreplace_cv_HAVE_OPEN_O_DIRECT=yes,libreplace_cv_HAVE_OPEN_O_DIRECT=no)]) +if test x"$libreplace_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT]) fi dnl Check if the C compiler understands volatile (it should, being ANSI). -AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [ +AC_CACHE_CHECK([that the C compiler understands volatile],libreplace_cv_volatile, [ AC_TRY_COMPILE([#include ],[volatile int i = 0], - samba_cv_volatile=yes,samba_cv_volatile=no)]) -if test x"$samba_cv_volatile" = x"yes"; then + libreplace_cv_volatile=yes,libreplace_cv_volatile=no)]) +if test x"$libreplace_cv_volatile" = x"yes"; then AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile]) fi -- cgit From 910a1cafdf253255510d3aff7cc2385da43331dd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 20:05:51 +0100 Subject: Support dlopen(NULL, ...) on HPUX. (This used to be commit 53c70b5f77a3b9abaab783590e66278129173d5f) --- source4/lib/replace/dlfcn.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c index 42848848e8..3b109d7e40 100644 --- a/source4/lib/replace/dlfcn.c +++ b/source4/lib/replace/dlfcn.c @@ -35,6 +35,8 @@ void *rep_dlopen(const char *name, int flags) #endif { #ifdef HAVE_SHL_LOAD + if (name == NULL) + return PROG_HANDLE; return (void *)shl_load(name, flags, 0); #else return NULL; -- cgit From 840933cd4eaca75ebb4d63928023e7d1d24f4a8c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 21 Feb 2008 17:56:33 +0100 Subject: Try and fix getifaddrs check on irix: dont't try to include config.h The missing header file is judged "catastrophic" on irix. Michael (cherry picked from commit 5778c90819a5a5cee38be690f442c571f3a6a051) (This used to be commit 0d4522a06d4465f6eadbdf14381c9e08cf7e1dc9) --- source4/lib/replace/getifaddrs.m4 | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 4cf86d89cc..5d5edf1cbd 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -60,6 +60,7 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ AC_TRY_RUN([ +#define NO_CONFIG_H 1 #define HAVE_IFACE_AIX 1 #define AUTOCONF_TEST 1 #undef _XOPEN_SOURCE_EXTENDED @@ -74,6 +75,7 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ AC_TRY_RUN([ +#define NO_CONFIG_H 1 #define HAVE_IFACE_IFCONF 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/getifaddrs.c"], @@ -86,6 +88,7 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ AC_TRY_RUN([ +#define NO_CONFIG_H 1 #define HAVE_IFACE_IFREQ 1 #define AUTOCONF_TEST 1 #include "$libreplacedir/getifaddrs.c"], -- cgit From c513546cda3d453748c88589b83015489fc6f14f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 21 Feb 2008 18:16:10 +0100 Subject: libreplace: fix compile errors in getifaddrs.c Michael (cherry picked from commit 22cdd4cb507022d9c670b7d5cbc8d357b0b91637) (This used to be commit 4da2d999a28c8fd3e93480194a153cf6a10de986) --- source4/lib/replace/getifaddrs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index 4037d647d7..f12062bd8e 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -81,7 +81,6 @@ int rep_getifaddrs(struct ifaddrs **ifap) char buff[8192]; int fd, i, n; struct ifreq *ifr=NULL; - int total = 0; struct in_addr ipaddr; struct in_addr nmask; char *iname; @@ -106,7 +105,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) n = ifc.ifc_len / sizeof(struct ifreq); /* Loop through interfaces, looking for given IP address */ - for (i=n-1;i>=0 && total < max_interfaces;i--) { + for (i=n-1; i>=0; i--) { if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) { freeifaddrs(*ifap); } @@ -166,11 +165,10 @@ int rep_getifaddrs(struct ifaddrs **ifap) char buff[8192]; int fd, i, n; struct ifreq *ifr=NULL; - int total = 0; struct in_addr ipaddr; struct in_addr nmask; char *iname; - struct ifaddrs *curif; + struct ifaddrs *curif, *lastif; *ifap = NULL; @@ -201,7 +199,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) /* Loop through interfaces */ - for (i = 0; i Date: Fri, 22 Feb 2008 00:24:11 +0100 Subject: Add missing initalizations of lastif in rep_getifaddr implementations. Michael (cherry picked from commit 65710e752f72070cb911867ff9f31f91904ca5c0) (This used to be commit 5bd613a2cda5d287706f2ce72f4ee08a7fa45b72) --- source4/lib/replace/getifaddrs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index f12062bd8e..60049caa99 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -84,7 +84,8 @@ int rep_getifaddrs(struct ifaddrs **ifap) struct in_addr ipaddr; struct in_addr nmask; char *iname; - struct ifaddrs *curif, *lastif; + struct ifaddrs *curif; + struct ifaddrs *lastif = NULL; *ifap = NULL; @@ -168,7 +169,8 @@ int rep_getifaddrs(struct ifaddrs **ifap) struct in_addr ipaddr; struct in_addr nmask; char *iname; - struct ifaddrs *curif, *lastif; + struct ifaddrs *curif; + struct ifaddrs *lastif = NULL; *ifap = NULL; @@ -268,7 +270,8 @@ int rep_getifaddrs(struct ifaddrs **ifap) struct in_addr ipaddr; struct in_addr nmask; char *iname; - struct ifaddrs *curif, *lastif; + struct ifaddrs *curif; + struct ifaddrs *lastif = NULL; *ifap = NULL; -- cgit From c2f92013c3304bf49622f7e0d5658f768898a4f1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 00:27:00 +0100 Subject: Fix linked list of ifaddrs in implementations of rep_getifaddrs. Produce proper list instead of one-node-loop. Michael (cherry picked from commit ec9f4f5066ba7a8bf3af931fd4969590140c0b2b) (This used to be commit 744d5ba7adab65a9774a18eb42b7090f49e423f2) --- source4/lib/replace/getifaddrs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index 60049caa99..37cd950e09 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -115,7 +115,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) if (lastif == NULL) { *ifap = curif; } else { - lastif->ifa_next = (*ifap); + lastif->ifa_next = curif; } curif->ifa_name = strdup(ifr[i].ifr_name); @@ -208,7 +208,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) if (lastif == NULL) { *ifap = curif; } else { - lastif->ifa_next = (*ifap); + lastif->ifa_next = curif; } strioctl.ic_cmd = SIOCGIFFLAGS; @@ -306,7 +306,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) if (lastif == NULL) { *ifap = curif; } else { - lastif->ifa_next = (*ifap); + lastif->ifa_next = curif; } curif->ifa_name = strdup(ifr->ifr_name); -- cgit From 88c919c14af3b5e5cb9524ce3bb778b7c7bc6c72 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 00:34:41 +0100 Subject: libreplace: fix creation of conftest files for getifaddrs tests. Add missing includes of replace.c and defines of SOCKET_WRAPPER_NOT_REPLACE. Michael (cherry picked from commit 26e6ebc7090b5742deb67805d85d809cafb4543d) (This used to be commit e00c6513e05afe91d4c419287283b34e931a161c) --- source4/lib/replace/getifaddrs.m4 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 5d5edf1cbd..dd2a95cb81 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -44,9 +44,10 @@ iface=no; iface=no; AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[ AC_TRY_RUN([ -#define NO_CONFIG_H 1 #define HAVE_IFACE_GETIFADDRS 1 +#define NO_CONFIG_H 1 #define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)]) @@ -60,10 +61,12 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ AC_TRY_RUN([ -#define NO_CONFIG_H 1 #define HAVE_IFACE_AIX 1 +#define NO_CONFIG_H 1 #define AUTOCONF_TEST 1 #undef _XOPEN_SOURCE_EXTENDED +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then @@ -75,9 +78,11 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ AC_TRY_RUN([ -#define NO_CONFIG_H 1 #define HAVE_IFACE_IFCONF 1 +#define NO_CONFIG_H 1 #define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then @@ -88,9 +93,11 @@ fi if test $iface = no; then AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ AC_TRY_RUN([ -#define NO_CONFIG_H 1 #define HAVE_IFACE_IFREQ 1 +#define NO_CONFIG_H 1 #define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" #include "$libreplacedir/getifaddrs.c"], libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then -- cgit From bf7d3b6ef440d61a8d65001f99c7526bb830f5d3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 10:42:22 +0100 Subject: libreplace: Fix comment originating from old samba source. Michael (This used to be commit 0440bcfe6359ca4842f473b1ca799cad9f1c6c96) --- source4/lib/replace/getifaddrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index 37cd950e09..a6f06e545f 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -363,7 +363,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) #endif #ifdef AUTOCONF_TEST -/* this is the autoconf driver to test get_interfaces() */ +/* this is the autoconf driver to test getifaddrs() */ int main() { -- cgit From e9b0056586f6e57d4d1243c5622c568497e04d38 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 22 Feb 2008 13:53:05 +0100 Subject: libreplace: don't use socketwrapper for getifaddrs() implementations. Michael (cherry picked from commit 85eec1d1d6b674294c50eb912fbe7d5a1dd42909) (This used to be commit a83db886e50b6ceeb71d93bf86fb5e0964b8d45f) --- source4/lib/replace/getifaddrs.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index a6f06e545f..053657475d 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -19,6 +19,8 @@ along with this program. If not, see . */ +#define SOCKET_WRAPPER_NOT_REPLACE + #include "replace.h" #include "system/network.h" -- cgit From 901addd4a18a9a166fc3518a7bce70969f884e6f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 26 Feb 2008 11:18:51 +0100 Subject: Fix build on VOS: socklen_t is needed for rep_inet_ntop: move it up. Michael (This used to be commit 8a26a6e8f11aca5119b15e304213548ad608dc5b) --- source4/lib/replace/system/network.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index d09e3f71f8..a84b22e5d0 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -83,6 +83,11 @@ #include #endif +#ifndef HAVE_SOCKLEN_T +#define HAVE_SOCKLEN_T +typedef int socklen_t; +#endif + #ifdef REPLACE_INET_NTOA /* define is in "replace.h" */ char *rep_inet_ntoa(struct in_addr ip); @@ -245,11 +250,6 @@ void rep_freeifaddrs(struct ifaddrs *); #define HOST_NAME_MAX 256 #endif -#ifndef HAVE_SOCKLEN_T -#define HAVE_SOCKLEN_T -typedef int socklen_t; -#endif - #ifndef HAVE_SA_FAMILY_T #define HAVE_SA_FAMILY_T typedef unsigned short int sa_family_t; -- cgit From 28464179174d2c3d1c1bc124ba9c2519e08a5fc9 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 26 Feb 2008 13:24:54 +0100 Subject: libreplace: Add tests for connect and gethostbyname. Provide dummy replacements when a function isnt found. The functions are also searched for in certain libraries, and variables SOCKET_LIBS and NSL_LIBS are set accordingly. One purpose of this is to fix the getifaddrs tests on systems where e.g. the socket calls require special libs for linking. Michael (This used to be commit 900d17acb95f1becfc46656a12c107336c027ef7) --- source4/lib/replace/libreplace.m4 | 1 + source4/lib/replace/replace.h | 10 +++++++++ source4/lib/replace/socket.c | 35 +++++++++++++++++++++++++++++++ source4/lib/replace/socket.m4 | 40 ++++++++++++++++++++++++++++++++++++ source4/lib/replace/system/network.h | 10 +++++++++ 5 files changed, 96 insertions(+) create mode 100644 source4/lib/replace/socket.c create mode 100644 source4/lib/replace/socket.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 2e0cd34f4a..e0cc57f4c8 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -344,6 +344,7 @@ m4_include(getpass.m4) m4_include(strptime.m4) m4_include(win32.m4) m4_include(timegm.m4) +m4_include(socket.m4) m4_include(inet_ntop.m4) m4_include(inet_pton.m4) m4_include(getaddrinfo.m4) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 3f91544e97..0d16f4ffd0 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -340,6 +340,16 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) /* prototype is in "system/network.h" */ #endif +#ifndef HAVE_CONNECT +#define connect rep_connect +/* prototype is in "system/network.h" */ +#endif + +#ifndef HAVE_GETHOSTBYNAME +#define gethostbyname rep_gethostbyname +/* prototype is in "system/network.h" */ +#endif + #ifndef HAVE_GETIFADDRS #define getifaddrs rep_getifaddrs /* prototype is in "system/network.h" */ diff --git a/source4/lib/replace/socket.c b/source4/lib/replace/socket.c new file mode 100644 index 0000000000..35e975fce7 --- /dev/null +++ b/source4/lib/replace/socket.c @@ -0,0 +1,35 @@ +/* + * Unix SMB/CIFS implementation. + * + * Dummy replacements for socket functions. + * + * Copyright (C) Michael Adam 2008 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "replace.h" +#include "system/network.h" + +int rep_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) +{ + errno = ENOSYS; + return -1; +} + +struct hostent *rep_gethostbyname(const char *name) +{ + errno = ENOSYS; + return NULL; +} diff --git a/source4/lib/replace/socket.m4 b/source4/lib/replace/socket.m4 new file mode 100644 index 0000000000..c0c8f93e81 --- /dev/null +++ b/source4/lib/replace/socket.m4 @@ -0,0 +1,40 @@ +dnl The following test is roughl taken from the cvs sources. +dnl +dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet. +dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has +dnl libsocket.so which has a bad implementation of gethostbyname (it +dnl only looks in /etc/hosts), so we only look for -lsocket if we need +dnl it. +AC_CHECK_FUNCS(connect) +if test x"$ac_cv_func_connect" = x"no"; then + AC_CHECK_LIB_EXT(nsl_s, SOCKET_LIBS, connect) + AC_CHECK_LIB_EXT(nsl, SOCKET_LIBS, connect) + AC_CHECK_LIB_EXT(socket, SOCKET_LIBS, connect) + AC_CHECK_LIB_EXT(inet, SOCKET_LIBS, connect) + dnl We can't just call AC_CHECK_FUNCS(connect) here, + dnl because the value has been cached. + if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" || + test x"$ac_cv_lib_ext_nsl_connect" = x"yes" || + test x"$ac_cv_lib_ext_socket_connect" = x"yes" || + test x"$ac_cv_lib_ext_inet_connect" = x"yes" + then + AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()]) + fi +fi + +AC_CHECK_FUNCS(gethostbyname) +if test x"$ac_cv_func_gethostbyname" = x"no"; then + AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(nsl, NSL_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(socket, NSL_LIBS, gethostbyname) + dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, + dnl because the value has been cached. + if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" || + test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" || + test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes" + then + AC_DEFINE(HAVE_GETHOSTBYNAME,1, + [Whether the system has gethostbyname()]) + fi +fi + diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index a84b22e5d0..410c6d7cca 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -103,6 +103,16 @@ int rep_inet_pton(int af, const char *src, void *dst); const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #endif +#ifndef HAVE_CONNECT +/* define is in "replace.h" */ +int rep_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); +#endif + +#ifndef HAVE_GETHOSTBYNAME +/* define is in "replace.h" */ +struct hostent *rep_gethostbyname(const char *name); +#endif + #ifdef HAVE_IFADDRS_H #include #endif -- cgit From 3a90bed29f6ddb2566f73f02a59eef1b0f1b7554 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 27 Feb 2008 01:29:12 +0100 Subject: libreplace: fix standalone build on some systems. getifaddr tests include system/network.h, which does not find getaddrinfo.h without "-I.". Michael (This used to be commit cd95c702ed90128f659e27709c61d4c6abc969ef) --- source4/lib/replace/configure.ac | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index beeb77e152..72d788ddcc 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -3,6 +3,8 @@ AC_INIT(replace.c) AC_CONFIG_SRCDIR([replace.c]) AC_CONFIG_HEADER(config.h) +CFLAGS="$CFLAGS -I." + AC_LIBREPLACE_ALL_CHECKS if test "$ac_cv_prog_gcc" = yes; then -- cgit From b6f8132e928509e751f0dc35c93fb024105709ee Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 27 Feb 2008 01:41:30 +0100 Subject: libreplace: fix standalone build - add necessary libs. The libs needed for getifaddrs replacements have to be added to LIBS and used for the testsuite target. Michael (This used to be commit e7c1d6513b945b205abe84b18a251d06e737e659) --- source4/lib/replace/Makefile.in | 4 +++- source4/lib/replace/getifaddrs.m4 | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index 30f39ac6cb..af9522f3a6 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -10,6 +10,7 @@ VPATH = @libreplacedir@ srcdir = @srcdir@ builddir = @builddir@ INSTALL = @INSTALL@ +LIBS = @LIBS@ .PHONY: test all showflags install installcheck clean distclean realdistclean @@ -25,6 +26,7 @@ showflags: @echo ' CC = $(CC)' @echo ' CFLAGS = $(CFLAGS)' @echo ' LDFLAGS= $(LDFLAGS)' + @echo ' LIBS = $(LIBS)' install: all mkdir -p $(libdir) @@ -41,7 +43,7 @@ installcheck: install test TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o testsuite: libreplace.a $(TEST_OBJS) - $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) + $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) $(LIBS) .c.o: @echo Compiling $*.c diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index dd2a95cb81..767797e8d2 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -71,6 +71,7 @@ AC_TRY_RUN([ libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) + old_LIBS="$old_LIBS $LIBS" fi fi @@ -87,6 +88,7 @@ AC_TRY_RUN([ libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) + old_LIBS="$old_LIBS $LIBS" fi fi @@ -102,6 +104,7 @@ AC_TRY_RUN([ libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) + old_LIBS="$old_LIBS $LIBS" fi fi -- cgit From c9009b9876e14ce9bd9e6941a8344e1f5e47dd21 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 27 Feb 2008 10:33:32 +0100 Subject: libreplace: standalone build: use -I$srcdir instead of -I. Michael (This used to be commit ff311e613226e660998824b887cb9595ffbe0275) --- source4/lib/replace/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index 72d788ddcc..f5e054f476 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -3,7 +3,7 @@ AC_INIT(replace.c) AC_CONFIG_SRCDIR([replace.c]) AC_CONFIG_HEADER(config.h) -CFLAGS="$CFLAGS -I." +CFLAGS="$CFLAGS -I$srcdir" AC_LIBREPLACE_ALL_CHECKS -- cgit From dfc84928d722191dad264a7206e20919c140e3ea Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 28 Feb 2008 21:43:06 +0100 Subject: libreplace: add extended getifaddrs test that prints out the interfaces. Michael (This used to be commit 9d2bab09aac22c00fe23f1e1265a2dbd0901e9ce) --- source4/lib/replace/Makefile.in | 2 +- source4/lib/replace/test/getifaddrs.c | 96 +++++++++++++++++++++++++++++++++++ source4/lib/replace/test/testsuite.c | 9 ++-- 3 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 source4/lib/replace/test/getifaddrs.c (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/Makefile.in b/source4/lib/replace/Makefile.in index af9522f3a6..c989835a8d 100644 --- a/source4/lib/replace/Makefile.in +++ b/source4/lib/replace/Makefile.in @@ -40,7 +40,7 @@ test: all installcheck: install test -TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o +TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o test/getifaddrs.o testsuite: libreplace.a $(TEST_OBJS) $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) $(LIBS) diff --git a/source4/lib/replace/test/getifaddrs.c b/source4/lib/replace/test/getifaddrs.c new file mode 100644 index 0000000000..66eed70268 --- /dev/null +++ b/source4/lib/replace/test/getifaddrs.c @@ -0,0 +1,96 @@ +/* + * Unix SMB/CIFS implementation. + * + * libreplace getifaddrs test + * + * Copyright (C) Michael Adam 2008 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef AUTOCONF_TEST +#include "replace.h" +#include "system/network.h" +#endif + +#ifdef HAVE_INET_NTOP +#define rep_inet_ntop inet_ntop +#endif + +static const char *format_sockaddr(struct sockaddr *addr, + char *addrstring, + socklen_t addrlen) +{ + const char *result = NULL; + + if (addr->sa_family == AF_INET) { + result = rep_inet_ntop(AF_INET, + &((struct sockaddr_in *)addr)->sin_addr, + addrstring, + addrlen); + } else if (addr->sa_family == AF_INET6) { + result = rep_inet_ntop(AF_INET6, + &((struct sockaddr_in6 *)addr)->sin6_addr, + addrstring, + addrlen); + } + return result; +} + +int getifaddrs_test(void) +{ + struct ifaddrs *ifs = NULL; + int ret; + + ret = getifaddrs(&ifs); + if (ret != 0) { + fprintf(stderr, "getifaddrs() failed: %s", strerror(errno)); + return 1; + } + + while (ifs) { + printf("%-10s ", ifs->ifa_name); + if (ifs->ifa_addr != NULL) { + char addrstring[INET6_ADDRSTRLEN]; + const char *result; + + result = format_sockaddr(ifs->ifa_addr, + addrstring, + sizeof(addrstring)); + if (result != NULL) { + printf("IP=%s ", addrstring); + } + + if (ifs->ifa_netmask != NULL) { + result = format_sockaddr(ifs->ifa_netmask, + addrstring, + sizeof(addrstring)); + if (result != NULL) { + printf("NETMASK=%s", addrstring); + } + } else { + printf("AF=%d ", ifs->ifa_addr->sa_family); + } + } else { + printf(""); + } + + printf("\n"); + ifs = ifs->ifa_next; + } + + freeifaddrs(ifs); + + return 0; +} diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index c9f3301005..b538360365 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -856,21 +856,18 @@ static int test_strptime(void) return libreplace_test_strptime(); } +extern int getifaddrs_test(void); + static int test_getifaddrs(void) { - struct ifaddrs *ifa; - int ret; printf("test: getifaddrs\n"); - ret = getifaddrs(&ifa); - if (ret != 0) { + if (getifaddrs_test() != 0) { printf("failure: getifaddrs\n"); return false; } - freeifaddrs(ifa); - printf("success: getifaddrs\n"); return true; } -- cgit From c9fb4f05f42209ed383e4e84954b549687fe6d6d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 28 Feb 2008 21:44:31 +0100 Subject: libreplace: use the new getifaddrs test also for autoconf. Michael (This used to be commit a2a506ff0eae2a64ebe2ddbb81a6c2a5fa7fe3da) --- source4/lib/replace/getifaddrs.c | 29 ----------------------------- source4/lib/replace/getifaddrs.m4 | 20 ++++++++++++++++---- 2 files changed, 16 insertions(+), 33 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index 053657475d..551ff863df 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -363,32 +363,3 @@ int rep_getifaddrs(struct ifaddrs **ifap) return -1; } #endif - -#ifdef AUTOCONF_TEST -/* this is the autoconf driver to test getifaddrs() */ - - int main() -{ - struct ifaddrs *ifs = NULL; - int ret; - - ret = getifaddrs(&ifs); - if (ret != 0) { - perror("getifaddrs() failed"); - return 1; - } - - while (ifs) { - printf("%-10s ", ifs->ifa_name); - if (ifs->ifa_addr != NULL && - ifs->ifa_addr->sa_family == AF_INET) { - printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifa_addr)->sin_addr)); - if (ifs->ifa_netmask != NULL) - printf("NETMASK=%s", inet_ntoa(((struct sockaddr_in *)ifs->ifa_netmask)->sin_addr)); - } - printf("\n"); - ifs = ifs->ifa_next; - } - return 0; -} -#endif diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 767797e8d2..1fa168b59e 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -49,7 +49,10 @@ AC_TRY_RUN([ #define AUTOCONF_TEST 1 #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" -#include "$libreplacedir/getifaddrs.c"], +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)]) if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) @@ -67,7 +70,10 @@ AC_TRY_RUN([ #undef _XOPEN_SOURCE_EXTENDED #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" -#include "$libreplacedir/getifaddrs.c"], +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) @@ -84,7 +90,10 @@ AC_TRY_RUN([ #define AUTOCONF_TEST 1 #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" -#include "$libreplacedir/getifaddrs.c"], +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) @@ -100,7 +109,10 @@ AC_TRY_RUN([ #define AUTOCONF_TEST 1 #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" -#include "$libreplacedir/getifaddrs.c"], +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) -- cgit From 53654f5caf701a32b615bed784d78765f351cb73 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 00:06:55 +0100 Subject: libreplace: try and fix rep_getifaddrs() for Tru64. Don't fail when there is no address assigned to the interface. Put NULL into the ifaddrs structure instead. Michael (This used to be commit ee170c85e0e76411bd752de5fe51db6940dab929) --- source4/lib/replace/getifaddrs.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index 551ff863df..f66bf800eb 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -109,38 +109,33 @@ int rep_getifaddrs(struct ifaddrs **ifap) /* Loop through interfaces, looking for given IP address */ for (i=n-1; i>=0; i--) { - if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) { + if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) == -1) { freeifaddrs(*ifap); + return -1; } curif = calloc(1, sizeof(struct ifaddrs)); - if (lastif == NULL) { - *ifap = curif; - } else { - lastif->ifa_next = curif; - } - curif->ifa_name = strdup(ifr[i].ifr_name); - curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr); + curif->ifa_flags = ifr[i].ifr_flags; curif->ifa_dstaddr = NULL; curif->ifa_data = NULL; curif->ifa_next = NULL; - curif->ifa_netmask = NULL; - - if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) != 0) { - freeifaddrs(*ifap); - return -1; - } - curif->ifa_flags = ifr[i].ifr_flags; - - if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) { - freeifaddrs(*ifap); - return -1; - } + curif->ifa_addr = NULL + if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != -1) { + curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr); + } - curif->ifa_netmask = sockaddr_dup(&ifr[i].ifr_addr); + curif->ifa_netmask = NULL; + if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != -1) { + curif->ifa_netmask = sockaddr_dup(&ifr[i].ifr_addr); + } + if (lastif == NULL) { + *ifap = curif; + } else { + lastif->ifa_next = curif; + } lastif = curif; } -- cgit From 42f389823d972e855936c022b95d224b0232d737 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 01:25:54 +0100 Subject: libreplace: add missing semicolon to getifaddrs. Michael (This used to be commit 29818a07de826fd687003ff25865d77939ecaa9a) --- source4/lib/replace/getifaddrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index f66bf800eb..adc2517e5c 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -121,7 +121,7 @@ int rep_getifaddrs(struct ifaddrs **ifap) curif->ifa_data = NULL; curif->ifa_next = NULL; - curif->ifa_addr = NULL + curif->ifa_addr = NULL; if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != -1) { curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr); } -- cgit From a9706ba3c1e08243a761cb9c32b605e9f41535de Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 01:49:30 +0100 Subject: libreplace: add missing newline in output of getifaddrs test. Michael (This used to be commit f8243cfc47c7414bab7f249d0e5d1c85e8ca7d64) --- source4/lib/replace/test/getifaddrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/getifaddrs.c b/source4/lib/replace/test/getifaddrs.c index 66eed70268..4455462193 100644 --- a/source4/lib/replace/test/getifaddrs.c +++ b/source4/lib/replace/test/getifaddrs.c @@ -55,7 +55,7 @@ int getifaddrs_test(void) ret = getifaddrs(&ifs); if (ret != 0) { - fprintf(stderr, "getifaddrs() failed: %s", strerror(errno)); + fprintf(stderr, "getifaddrs() failed: %s\n", strerror(errno)); return 1; } -- cgit From daab914cafba742ff9fcb3aab55cc812cf415058 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 02:22:02 +0100 Subject: libreplace: fix silly crashbug in getifaddrs_test(). Michael (This used to be commit 523626908d25f974fd1ae6d7306b1d4bc8414162) --- source4/lib/replace/test/getifaddrs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/getifaddrs.c b/source4/lib/replace/test/getifaddrs.c index 4455462193..c78c9b545e 100644 --- a/source4/lib/replace/test/getifaddrs.c +++ b/source4/lib/replace/test/getifaddrs.c @@ -51,9 +51,11 @@ static const char *format_sockaddr(struct sockaddr *addr, int getifaddrs_test(void) { struct ifaddrs *ifs = NULL; + struct ifaddrs *ifs_head = NULL; int ret; ret = getifaddrs(&ifs); + ifs_head = ifs; if (ret != 0) { fprintf(stderr, "getifaddrs() failed: %s\n", strerror(errno)); return 1; @@ -90,7 +92,7 @@ int getifaddrs_test(void) ifs = ifs->ifa_next; } - freeifaddrs(ifs); + freeifaddrs(ifs_head); return 0; } -- cgit From f21aac60d9937d11f3019251f1960b51b68c5e54 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 02:23:29 +0100 Subject: libreplace: fix rep_freeifaddrs to not segfault on NULL input. Michael (This used to be commit 0cbb87453beb52c6b0bc3a48791f49678f4030c5) --- source4/lib/replace/getifaddrs.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index adc2517e5c..f6f0ec080c 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -44,13 +44,14 @@ void rep_freeifaddrs(struct ifaddrs *ifp) { - free(ifp->ifa_name); - free(ifp->ifa_addr); - free(ifp->ifa_netmask); - free(ifp->ifa_dstaddr); - if (ifp->ifa_next != NULL) + if (ifp != NULL) { + free(ifp->ifa_name); + free(ifp->ifa_addr); + free(ifp->ifa_netmask); + free(ifp->ifa_dstaddr); freeifaddrs(ifp->ifa_next); - free(ifp); + free(ifp); + } } static struct sockaddr *sockaddr_dup(struct sockaddr *sa) -- cgit From abb9356b4f78bcd64de6c53f6ce6b1fda05b42e2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 02:43:24 +0100 Subject: libreplace: ifdef out ip6 code if unsupported. Michael (This used to be commit 54cc0df4dbf6d63a9b94e1ac6af4ec7f7803bc30) --- source4/lib/replace/test/getifaddrs.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/getifaddrs.c b/source4/lib/replace/test/getifaddrs.c index c78c9b545e..8b00ac2f40 100644 --- a/source4/lib/replace/test/getifaddrs.c +++ b/source4/lib/replace/test/getifaddrs.c @@ -39,11 +39,13 @@ static const char *format_sockaddr(struct sockaddr *addr, &((struct sockaddr_in *)addr)->sin_addr, addrstring, addrlen); +#ifdef HAVE_STRUCT_SOCKADDR_IN6 } else if (addr->sa_family == AF_INET6) { result = rep_inet_ntop(AF_INET6, &((struct sockaddr_in6 *)addr)->sin6_addr, addrstring, addrlen); +#endif } return result; } -- cgit From de4a2214efb3fcc1aa04664371983dbc768eaf79 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 29 Feb 2008 02:46:14 +0100 Subject: libreplace: add snprintf.c to test code for getifaddrs - needed on some systems. Michael (This used to be commit 0aff54a12e20d5e91fcdec7aaec103fb9a371a23) --- source4/lib/replace/getifaddrs.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 1fa168b59e..6cca155de3 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -50,6 +50,7 @@ AC_TRY_RUN([ #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" #include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" #include "$libreplacedir/getifaddrs.c" #define getifaddrs_test main #include "$libreplacedir/test/getifaddrs.c"], @@ -71,6 +72,7 @@ AC_TRY_RUN([ #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" #include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" #include "$libreplacedir/getifaddrs.c" #define getifaddrs_test main #include "$libreplacedir/test/getifaddrs.c"], @@ -91,6 +93,7 @@ AC_TRY_RUN([ #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" #include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" #include "$libreplacedir/getifaddrs.c" #define getifaddrs_test main #include "$libreplacedir/test/getifaddrs.c"], @@ -110,6 +113,7 @@ AC_TRY_RUN([ #define SOCKET_WRAPPER_NOT_REPLACE #include "$libreplacedir/replace.c" #include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" #include "$libreplacedir/getifaddrs.c" #define getifaddrs_test main #include "$libreplacedir/test/getifaddrs.c"], -- cgit From fe096dd31336639a478a9f05cb3d790c2c31af47 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 14 Mar 2008 08:49:34 +0100 Subject: libreplace: add an inet_aton() function that calls inet_pton(). inet_aton() is even needed inside libreplace, in the implementation of rep_getaddrinfo(). Michael (This used to be commit bcb2f3a880f8da8f9bedb7a8e61d7d7b533f1919) --- source4/lib/replace/README | 1 + source4/lib/replace/inet_aton.c | 29 +++++++++++++++++++++++++++++ source4/lib/replace/inet_aton.m4 | 1 + source4/lib/replace/libreplace.m4 | 1 + source4/lib/replace/replace.h | 5 +++++ source4/lib/replace/system/network.h | 5 +++++ 6 files changed, 42 insertions(+) create mode 100644 source4/lib/replace/inet_aton.c create mode 100644 source4/lib/replace/inet_aton.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 268a1b15cf..aae1ccb56f 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -52,6 +52,7 @@ readline (the library) inet_ntoa inet_ntop inet_pton +inet_aton strtoll strtoull socketpair diff --git a/source4/lib/replace/inet_aton.c b/source4/lib/replace/inet_aton.c new file mode 100644 index 0000000000..3eb58f000c --- /dev/null +++ b/source4/lib/replace/inet_aton.c @@ -0,0 +1,29 @@ +/* + * Unix SMB/CIFS implementation. + * replacement functions + * Copyright (C) Michael Adam 2008 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "replace.h" +#include "system/network.h" + +/** + * We know that we have inet_pton from earlier libreplace checks. + */ +int rep_inet_aton(const char *src, struct in_addr *dst) +{ + return (inet_pton(AF_INET, src, dst) > 0) ? 1 : 0; +} diff --git a/source4/lib/replace/inet_aton.m4 b/source4/lib/replace/inet_aton.m4 new file mode 100644 index 0000000000..853688ef6b --- /dev/null +++ b/source4/lib/replace/inet_aton.m4 @@ -0,0 +1 @@ +AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"]) diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index e0cc57f4c8..e6e7198abf 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -347,6 +347,7 @@ m4_include(timegm.m4) m4_include(socket.m4) m4_include(inet_ntop.m4) m4_include(inet_pton.m4) +m4_include(inet_aton.m4) m4_include(getaddrinfo.m4) m4_include(repdir.m4) m4_include(getifaddrs.m4) diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 0d16f4ffd0..00c8230e6b 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -340,6 +340,11 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) /* prototype is in "system/network.h" */ #endif +#ifndef HAVE_INET_ATON +#define inet_aton rep_inet_aton +/* prototype is in "system/network.h" */ +#endif + #ifndef HAVE_CONNECT #define connect rep_connect /* prototype is in "system/network.h" */ diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 410c6d7cca..8c606c8f2d 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -103,6 +103,11 @@ int rep_inet_pton(int af, const char *src, void *dst); const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); #endif +#ifndef HAVE_INET_ATON +/* define is in "replace.h" */ +int rep_inet_aton(const char *src, struct in_addr *dst); +#endif + #ifndef HAVE_CONNECT /* define is in "replace.h" */ int rep_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); -- cgit From 9d0b13bfcc44b7f886b42b25dd65d10c46fddb40 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 14 Mar 2008 08:52:16 +0100 Subject: libreplace: add -I$libreplacedir to CPPFLAGS for getifaddrs tests. This is needed, otherwise $libreplacedir/system/network.h does not find $libreplacedir/getaddrinfo.h on some systems (solaris, e.g.). Michael (This used to be commit 297c3bece094ddb5f268b02e61e33f512ccfe6f5) --- source4/lib/replace/getifaddrs.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 6cca155de3..c79367fe4f 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -38,6 +38,8 @@ fi # old_LIBS=$LIBS LIBS="$NSL_LIBS $SOCKET_LIBS" +SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -I$libreplacedir" iface=no; ################## # look for a method of finding the list of network interfaces @@ -125,3 +127,5 @@ fi fi LIBS=$old_LIBS +CPPFLAGS="$SAVE_CPPFLAGS" + -- cgit From 4b2aee2cd6fd38b2eecf6a3102d001dc8a1e860e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 14 Mar 2008 09:39:58 +0100 Subject: libreplace: fix samba4 build (by not setting global LIBS). This corrects the earlier fix of the standalone build, by setting LIBS to the desired value only in configure.ac but not in getifaddrs.m4. Not that this changes the standalone build in that it adds these libs undconditionally and not only if they are needed by the getifaddrs replacement functions. Michael (This used to be commit ff3af1703ddc9e5383f32156bc5be8351f795e76) --- source4/lib/replace/configure.ac | 3 +++ source4/lib/replace/getifaddrs.m4 | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index f5e054f476..298f5a67f9 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -21,6 +21,9 @@ if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wno-format-y2k" fi +LIBS="$SOCKET_LIBS $NSL_LIBS" +AC_SUBST(LIBS) + AC_SUBST(LDFLAGS) AC_OUTPUT(Makefile) diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index c79367fe4f..f4cf4e48a2 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -81,7 +81,6 @@ AC_TRY_RUN([ libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) - old_LIBS="$old_LIBS $LIBS" fi fi @@ -102,7 +101,6 @@ AC_TRY_RUN([ libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) - old_LIBS="$old_LIBS $LIBS" fi fi @@ -122,7 +120,6 @@ AC_TRY_RUN([ libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) - old_LIBS="$old_LIBS $LIBS" fi fi -- cgit From 3b63333cf272fae301e22e9a021f0bbf60d1c413 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Mar 2008 21:47:22 +0100 Subject: Allocate one 0-byte in asprintf replacement when len==0 Some S3 code depends on this. (cherry picked from commit dc3d5e16452bf30055638ba3cfe99097fb557156) (This used to be commit 842d144b4fb0981250157f72956e732709663107) --- source4/lib/replace/snprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 9f8a7657e5..a174dcffed 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -1264,7 +1264,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, VA_COPY(ap2, ap); ret = vsnprintf(NULL, 0, format, ap2); va_end(ap2); - if (ret <= 0) return ret; + if (ret < 0) return ret; (*ptr) = (char *)malloc(ret+1); if (!*ptr) return -1; -- cgit From cbc5e58b8f8d6a7ec34f17e263b88a3e7e39b095 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:52:36 +0100 Subject: libreplace: combine SOCKET_LIBS and NSL_LIBS to LIBREPLACE_NETWORK_LIBS But keep the old ones untill the callers are fixed. metze (This used to be commit e7115dcc8a0a4f420de7a901e3a21d4f35a6fcf9) --- source4/lib/replace/socket.m4 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/socket.m4 b/source4/lib/replace/socket.m4 index c0c8f93e81..ab948c1445 100644 --- a/source4/lib/replace/socket.m4 +++ b/source4/lib/replace/socket.m4 @@ -7,10 +7,10 @@ dnl only looks in /etc/hosts), so we only look for -lsocket if we need dnl it. AC_CHECK_FUNCS(connect) if test x"$ac_cv_func_connect" = x"no"; then - AC_CHECK_LIB_EXT(nsl_s, SOCKET_LIBS, connect) - AC_CHECK_LIB_EXT(nsl, SOCKET_LIBS, connect) - AC_CHECK_LIB_EXT(socket, SOCKET_LIBS, connect) - AC_CHECK_LIB_EXT(inet, SOCKET_LIBS, connect) + AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect) dnl We can't just call AC_CHECK_FUNCS(connect) here, dnl because the value has been cached. if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" || @@ -24,9 +24,9 @@ fi AC_CHECK_FUNCS(gethostbyname) if test x"$ac_cv_func_gethostbyname" = x"no"; then - AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, gethostbyname) - AC_CHECK_LIB_EXT(nsl, NSL_LIBS, gethostbyname) - AC_CHECK_LIB_EXT(socket, NSL_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname) dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, dnl because the value has been cached. if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" || @@ -38,3 +38,5 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then fi fi +SOCKET_LIBS="${LIBREPLACE_NETWORK_LIBS}" +NSL_LIBS="" -- cgit From 1ef171f6e00470276b65289878d0006dc9b7f97f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:53:59 +0100 Subject: libreplace: use LIBREPLACE_NETWORK_LIBS within some configure checks ...instead of using SOCKET_LIBS and NSL_LIBS. metze (This used to be commit cef2e8d748756f61c248ad6660e85dd1ac36308a) --- source4/lib/replace/configure.ac | 2 +- source4/lib/replace/getifaddrs.m4 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index 298f5a67f9..02dc08bf72 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -21,7 +21,7 @@ if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wno-format-y2k" fi -LIBS="$SOCKET_LIBS $NSL_LIBS" +LIBS="${LIBREPLACE_NETWORK_LIBS}" AC_SUBST(LIBS) AC_SUBST(LDFLAGS) diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index f4cf4e48a2..927bc677db 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -34,10 +34,10 @@ fi ################## # look for a method of finding the list of network interfaces # -# This tests need LIBS="$NSL_LIBS $SOCKET_LIBS" +# This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" # old_LIBS=$LIBS -LIBS="$NSL_LIBS $SOCKET_LIBS" +LIBS="${LIBREPLACE_NETWORK_LIBS}" SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$libreplacedir" iface=no; -- cgit From 23c35481fa0e0168d89c91c8bc3cb8d3cf82c213 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:55:05 +0100 Subject: libreplace: for samba4 create LIBREPLACE_NETWORK as EXT_LIB metze (This used to be commit 79037c31334e271a718fcac234148038814b591e) --- source4/lib/replace/samba.m4 | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4 index a2e04f53b1..e62c3d3cd1 100644 --- a/source4/lib/replace/samba.m4 +++ b/source4/lib/replace/samba.m4 @@ -3,6 +3,9 @@ AC_LIBREPLACE_BROKEN_CHECKS SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}]) SMB_ENABLE(LIBREPLACE_EXT) +SMB_EXT_LIB(LIBREPLACE_NETWORK, [${LIBREPLACE_NETWORK_LIBS}]) +SMB_ENABLE(LIBREPLACE_NETWORK) + # remove leading ./ LIBREPLACE_DIR=`echo ${libreplacedir} |sed -e 's/^\.\///g'` -- cgit From 7a5438ae111416ce33ffd8f0468fd031ae58577a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 15:01:34 +0100 Subject: libreplace: remove unused SOCKET_LIBS and NSL_LIBS metze (This used to be commit 62bb177a6e4a3e1f949b78c7cd7583f2e1271739) --- source4/lib/replace/socket.m4 | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/socket.m4 b/source4/lib/replace/socket.m4 index ab948c1445..984f81f15f 100644 --- a/source4/lib/replace/socket.m4 +++ b/source4/lib/replace/socket.m4 @@ -37,6 +37,3 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then [Whether the system has gethostbyname()]) fi fi - -SOCKET_LIBS="${LIBREPLACE_NETWORK_LIBS}" -NSL_LIBS="" -- cgit From 58dfb0ff3cb9a75e8caad89819f586b64df05f8a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 14 Mar 2008 15:53:38 +0100 Subject: libreplace: put inet_aton.c under LGPL instead of GPL. Michael (This used to be commit cca5d6626fe395f08fd4c8b2344e4e43646cb987) --- source4/lib/replace/inet_aton.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/inet_aton.c b/source4/lib/replace/inet_aton.c index 3eb58f000c..c6b3bb11a7 100644 --- a/source4/lib/replace/inet_aton.c +++ b/source4/lib/replace/inet_aton.c @@ -3,18 +3,22 @@ * replacement functions * Copyright (C) Michael Adam 2008 * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. + * ** NOTE! The following LGPL license applies to the replace + * ** library. This does NOT imply that all of Samba is released + * ** under the LGPL * - * This program is distributed in the hope that it will be useful, + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . */ #include "replace.h" -- cgit From 87b48a812683794935db950446e9fb1db8e3da48 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 12:16:47 +0100 Subject: libreplace: replace inet_ntoa() when it is missing ...not only replace it when it is broken. This moves the defintion of rep_inet_ntoa from replace.c to inet_ntoa.c and adds configure checks for existence of inet_ntoa(). Checks are moved to an include file of its own. NOTE: The original rep_inet_ntoa in replace.c was wrapped into a "#ifndef WITH_PTHREADS" but the prototype in replace.h and the define in system/network.h were not. I removed that ifndef since the inet_ntoa() function is usually not thread safe anyways, since it returns a pointer to a static buffer. So whoever calls inet_ntoa() should be aware that it is not thread safe anyways. Michael (This used to be commit 974c0c45ad42644348e0b55454715b12158f1028) --- source4/lib/replace/inet_ntoa.c | 39 ++++++++++++++++++++++++++++++++++++ source4/lib/replace/inet_ntoa.m4 | 19 ++++++++++++++++++ source4/lib/replace/libreplace.m4 | 19 +----------------- source4/lib/replace/replace.c | 14 ------------- source4/lib/replace/replace.h | 2 +- source4/lib/replace/system/network.h | 2 +- 6 files changed, 61 insertions(+), 34 deletions(-) create mode 100644 source4/lib/replace/inet_ntoa.c create mode 100644 source4/lib/replace/inet_ntoa.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/inet_ntoa.c b/source4/lib/replace/inet_ntoa.c new file mode 100644 index 0000000000..f3e733fa61 --- /dev/null +++ b/source4/lib/replace/inet_ntoa.c @@ -0,0 +1,39 @@ +/* + * Unix SMB/CIFS implementation. + * replacement routines for broken systems + * Copyright (C) Andrew Tridgell 2003 + * Copyright (C) Michael Adam 2008 + * + * ** NOTE! The following LGPL license applies to the replace + * ** library. This does NOT imply that all of Samba is released + * ** under the LGPL + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "replace.h" +#include "system/network.h" + +/** + * NOTE: this is not thread safe, but it can't be, either + * since it returns a pointer to static memory. + */ +char *rep_inet_ntoa(struct in_addr ip) +{ + uint8_t *p = (uint8_t *)&ip.s_addr; + static char buf[18]; + slprintf(buf, 17, "%d.%d.%d.%d", + (int)p[0], (int)p[1], (int)p[2], (int)p[3]); + return buf; +} diff --git a/source4/lib/replace/inet_ntoa.m4 b/source4/lib/replace/inet_ntoa.m4 new file mode 100644 index 0000000000..c1de4134d9 --- /dev/null +++ b/source4/lib/replace/inet_ntoa.m4 @@ -0,0 +1,19 @@ +AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"]) + +AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ +AC_TRY_RUN([ +#include +#include +#include +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +main() { struct in_addr ip; ip.s_addr = 0x12345678; +if (strcmp(inet_ntoa(ip),"18.52.86.120") && + strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } +exit(1);}], + libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) +if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then + AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) +fi diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index e6e7198abf..3da2a90a99 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -120,24 +120,6 @@ if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) fi -AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ -AC_TRY_RUN([ -#include -#include -#include -#include -#ifdef HAVE_ARPA_INET_H -#include -#endif -main() { struct in_addr ip; ip.s_addr = 0x12345678; -if (strcmp(inet_ntoa(ip),"18.52.86.120") && - strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } -exit(1);}], - libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) -if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then - AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) -fi - AC_HAVE_TYPE([socklen_t],[#include ]) AC_HAVE_TYPE([sa_family_t],[#include ]) AC_HAVE_TYPE([struct addrinfo], [#include ]) @@ -348,6 +330,7 @@ m4_include(socket.m4) m4_include(inet_ntop.m4) m4_include(inet_pton.m4) m4_include(inet_aton.m4) +m4_include(inet_ntoa.m4) m4_include(getaddrinfo.m4) m4_include(repdir.m4) m4_include(getifaddrs.m4) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b2a240e8ab..c16bded963 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -295,20 +295,6 @@ char *rep_strdup(const char *s) } #endif /* HAVE_STRDUP */ -#ifndef WITH_PTHREADS -/* REWRITE: not thread safe */ -#ifdef REPLACE_INET_NTOA -char *rep_inet_ntoa(struct in_addr ip) -{ - uint8_t *p = (uint8_t *)&ip.s_addr; - static char buf[18]; - slprintf(buf, 17, "%d.%d.%d.%d", - (int)p[0], (int)p[1], (int)p[2], (int)p[3]); - return buf; -} -#endif /* REPLACE_INET_NTOA */ -#endif - #ifndef HAVE_SETLINEBUF void rep_setlinebuf(FILE *stream) { diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 00c8230e6b..383536da65 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -325,7 +325,7 @@ ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset); ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset); #endif -#ifdef REPLACE_INET_NTOA +#if !defined(HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA) #define inet_ntoa rep_inet_ntoa /* prototype is in "system/network.h" */ #endif diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 8c606c8f2d..7c2377301b 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -88,7 +88,7 @@ typedef int socklen_t; #endif -#ifdef REPLACE_INET_NTOA +#if !defined (HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA) /* define is in "replace.h" */ char *rep_inet_ntoa(struct in_addr ip); #endif -- cgit From 4500b95c89b6b692bd2842e902367663ac2351ba Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 13:10:22 +0100 Subject: libreplace: remove trailing white spaces. Michael (This used to be commit 1f9ca7eed965904f67cf78fbac007432b8a057fd) --- source4/lib/replace/inet_ntoa.c | 2 +- source4/lib/replace/inet_ntoa.m4 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/inet_ntoa.c b/source4/lib/replace/inet_ntoa.c index f3e733fa61..e3b80ebef8 100644 --- a/source4/lib/replace/inet_ntoa.c +++ b/source4/lib/replace/inet_ntoa.c @@ -33,7 +33,7 @@ char *rep_inet_ntoa(struct in_addr ip) { uint8_t *p = (uint8_t *)&ip.s_addr; static char buf[18]; - slprintf(buf, 17, "%d.%d.%d.%d", + slprintf(buf, 17, "%d.%d.%d.%d", (int)p[0], (int)p[1], (int)p[2], (int)p[3]); return buf; } diff --git a/source4/lib/replace/inet_ntoa.m4 b/source4/lib/replace/inet_ntoa.m4 index c1de4134d9..5aaa9350c5 100644 --- a/source4/lib/replace/inet_ntoa.m4 +++ b/source4/lib/replace/inet_ntoa.m4 @@ -11,7 +11,7 @@ AC_TRY_RUN([ #endif main() { struct in_addr ip; ip.s_addr = 0x12345678; if (strcmp(inet_ntoa(ip),"18.52.86.120") && - strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } + strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } exit(1);}], libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then -- cgit From 4d16e17e04c6fd62ebfa36085bcf38d2507737e6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 16:31:15 +0100 Subject: libreplace: remove duplicate entry of inet_ntoa from README. Michael (This used to be commit 98ee8c84300757d778733a458c6ca3e6022b40ea) --- source4/lib/replace/README | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index aae1ccb56f..43f7b08572 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -15,7 +15,6 @@ rename initgroups memmove strdup -inet_ntoa setlinebuf vsyslog timegm -- cgit From 7fb3963032ce8f6b7f5c652dd69d3315cae897ea Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 10:42:43 +0100 Subject: Check the return value of fgets (cherry picked from commit b8aaa9a69fd6217ce0387ef8e84f316706186d70) (This used to be commit 8f58d39c0c621e9da85308d721a146352cc4939e) --- source4/lib/replace/getpass.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index d91d029f6a..57e28eb981 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -185,7 +185,10 @@ char *rep_getpass(const char *prompt) buf[0] = 0; if (!gotintr) { in_fd = fileno(in); - fgets(buf, bufsize, in); + if (fgets(buf, bufsize, in) == NULL) { + buf[0] = 0; + return buf; + } } nread = strlen(buf); if (nread) { -- cgit From 6f6d38d24a69aec614e443c6a5cd0d6ed6b1b70e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Mar 2008 22:27:05 +0100 Subject: Fix Coverity ID 554 (cherry picked from commit 471b1b0c58bc2def5d2fe9d98401def34724d447) (This used to be commit effda48a2670325fed56e158539417c6f95381b8) --- source4/lib/replace/getpass.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 57e28eb981..73333b9021 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -187,6 +187,9 @@ char *rep_getpass(const char *prompt) in_fd = fileno(in); if (fgets(buf, bufsize, in) == NULL) { buf[0] = 0; + if (in && in != stdin) { + fclose(in); + } return buf; } } -- cgit From 1268be9f88a1716c9b01b10fef0de5428ef65b3c Mon Sep 17 00:00:00 2001 From: "Gerald W. Carter" Date: Thu, 28 Feb 2008 11:58:05 -0600 Subject: Fix macro name (no 's' in ifr_addr). Interface detection on Solaris still failing due to items pointed out here: http://lists.samba.org/archive/samba-technical/2007-November/056701.html (cherry picked from commit 37c87acc9d48c1fb5d4806374ca8e992300db1ff) (This used to be commit 5757d8dfe9e6cf7b662acdf5c3d825f0021822c0) --- source4/lib/replace/system/network.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 7c2377301b..f943a7fd87 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -310,7 +310,7 @@ struct addrinfo { /* Needed for some systems that don't define it (Solaris). */ #ifndef ifr_netmask -#define ifr_netmask ifr_addrs +#define ifr_netmask ifr_addr #endif #ifdef SOCKET_WRAPPER -- cgit From 124f82efe13a453a3f5857c1e25584536147c3dc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 17:20:47 +0100 Subject: libreplace: move rep_socketpair() to its own module. Prototype is now in system/network.h, implementation in socketpair.c, and check in socketpair.m4. Now the last networking function has vanished from replace.c. Michael (This used to be commit 94ac8a25be15b55f66eff96fdddc2fdc71a43b1e) --- source4/lib/replace/libreplace.m4 | 3 ++- source4/lib/replace/replace.c | 22 ----------------- source4/lib/replace/replace.h | 2 +- source4/lib/replace/socketpair.c | 46 ++++++++++++++++++++++++++++++++++++ source4/lib/replace/socketpair.m4 | 1 + source4/lib/replace/system/network.h | 5 ++++ 6 files changed, 55 insertions(+), 24 deletions(-) create mode 100644 source4/lib/replace/socketpair.c create mode 100644 source4/lib/replace/socketpair.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 3da2a90a99..8e17258918 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -158,7 +158,7 @@ fi AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp socketpair) +AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) AC_CHECK_FUNCS(isatty) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) @@ -334,6 +334,7 @@ m4_include(inet_ntoa.m4) m4_include(getaddrinfo.m4) m4_include(repdir.m4) m4_include(getifaddrs.m4) +m4_include(socketpair.m4) AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index c16bded963..a6a8c0b6ed 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -585,25 +585,3 @@ int rep_unsetenv(const char *name) return 0; } #endif - -#ifndef HAVE_SOCKETPAIR -int rep_socketpair(int d, int type, int protocol, int sv[2]) -{ - if (d != AF_UNIX) { - errno = EAFNOSUPPORT; - return -1; - } - - if (protocol != 0) { - errno = EPROTONOSUPPORT; - return -1; - } - - if (type != SOCK_STREAM) { - errno = EOPNOTSUPP; - return -1; - } - - return pipe(sv); -} -#endif diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 383536da65..5fe79394eb 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -212,7 +212,7 @@ int rep_dlclose(void *handle); #ifndef HAVE_SOCKETPAIR #define socketpair rep_socketpair -int rep_socketpair(int d, int type, int protocol, int sv[2]); +/* prototype is in system/network.h */ #endif #ifndef PRINTF_ATTRIBUTE diff --git a/source4/lib/replace/socketpair.c b/source4/lib/replace/socketpair.c new file mode 100644 index 0000000000..c775730952 --- /dev/null +++ b/source4/lib/replace/socketpair.c @@ -0,0 +1,46 @@ +/* + * Unix SMB/CIFS implementation. + * replacement routines for broken systems + * Copyright (C) Jelmer Vernooij 2006 + * Copyright (C) Michael Adam 2008 + * + * ** NOTE! The following LGPL license applies to the replace + * ** library. This does NOT imply that all of Samba is released + * ** under the LGPL + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "replace.h" +#include "system/network.h" + +int rep_socketpair(int d, int type, int protocol, int sv[2]) +{ + if (d != AF_UNIX) { + errno = EAFNOSUPPORT; + return -1; + } + + if (protocol != 0) { + errno = EPROTONOSUPPORT; + return -1; + } + + if (type != SOCK_STREAM) { + errno = EOPNOTSUPP; + return -1; + } + + return pipe(sv); +} diff --git a/source4/lib/replace/socketpair.m4 b/source4/lib/replace/socketpair.m4 new file mode 100644 index 0000000000..7088334cda --- /dev/null +++ b/source4/lib/replace/socketpair.m4 @@ -0,0 +1 @@ +AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"]) diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index f943a7fd87..a5fb813aa1 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -143,6 +143,11 @@ int rep_getifaddrs(struct ifaddrs **); void rep_freeifaddrs(struct ifaddrs *); #endif +#ifndef HAVE_SOCKETPAIR +/* define is in "replace.h" */ +int rep_socketpair(int d, int type, int protocol, int sv[2]); +#endif + /* * Some systems have getaddrinfo but not the * defines needed to use it. -- cgit From a310b0b84369da95c059ddb6ae90a524062eadd5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 17:50:23 +0100 Subject: libreplace: replace.c does not need system/network.h anymore. Michael (This used to be commit 2d3c2f34f33338ff422047dae9cc262522689328) --- source4/lib/replace/replace.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index a6a8c0b6ed..6930f9b079 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -27,7 +27,6 @@ #include "system/time.h" #include "system/passwd.h" #include "system/syslog.h" -#include "system/network.h" #include "system/locale.h" #include "system/wait.h" -- cgit From 35f33a26404866c676285356a17e42b56523008a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 27 Mar 2008 11:26:33 +0100 Subject: libreplace: fix coverity ID 517 - untangle close from open in test/os2_delete.c This is not a proper bug but the code is clearer now and we are tracking failure of open separate from that of close. Michael (This used to be commit 4ae4692bc6c6da15483a6f4a3363cdc23121efc7) --- source4/lib/replace/test/os2_delete.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index c6ef180017..b45c135355 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -39,8 +39,15 @@ static void create_files(void) int i; for (i=0;i Date: Fri, 28 Mar 2008 07:56:20 +0100 Subject: libreplace(samba4): let LIBREPLACE depend on LIBREPLACE_NETWORK for now This should fix the build on solaris. Later this needs better fixing... metze (This used to be commit 89b7955733c34e9699a3b43ee54de92cb9469b90) --- source4/lib/replace/samba.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4 index e62c3d3cd1..7984ef31db 100644 --- a/source4/lib/replace/samba.m4 +++ b/source4/lib/replace/samba.m4 @@ -23,7 +23,7 @@ done SMB_SUBSYSTEM(LIBREPLACE, [${LIBREPLACE_OBJS}], - [LIBREPLACE_EXT], + [LIBREPLACE_EXT LIBREPLACE_NETWORK], [-Ilib/replace]) LIBREPLACE_HOSTCC_OBJS=`echo ${LIBREPLACE_OBJS} |sed -e 's/\.o/\.ho/g'` -- cgit From 107ab090e23dfc517bc74bb553315cd3528e1f7d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 Apr 2008 14:47:07 +0200 Subject: use uintptr_t instead of intptr_t where appropriate (This used to be commit d62f2bcc85c13605c133db250e0a86d2d6ccc481) --- source4/lib/replace/libreplace_cc.m4 | 3 ++- source4/lib/replace/replace.c | 2 +- source4/lib/replace/replace.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index bf5056838d..0ce0958a96 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -132,7 +132,8 @@ AC_CHECK_SIZEOF(off_t) AC_CHECK_SIZEOF(size_t) AC_CHECK_SIZEOF(ssize_t) -AC_CHECK_TYPE(intptr_t, unsigned long long) +AC_CHECK_TYPE(intptr_t, long long) +AC_CHECK_TYPE(uintptr_t, unsigned long long) AC_CHECK_TYPE(ptrdiff_t, unsigned long long) if test x"$ac_cv_type_long_long" != x"yes";then diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 6930f9b079..443da2ab24 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -458,7 +458,7 @@ char *rep_strcasestr(const char *haystack, const char *needle) for (s=haystack;*s;s++) { if (toupper(*needle) == toupper(*s) && strncasecmp(s, needle, nlen) == 0) { - return (char *)((intptr_t)s); + return (char *)((uintptr_t)s); } } return NULL; diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 5fe79394eb..bf95169352 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -499,7 +499,7 @@ typedef int bool; Also, please call this via the discard_const_p() macro interface, as that makes the return type safe. */ -#define discard_const(ptr) ((void *)((intptr_t)(ptr))) +#define discard_const(ptr) ((void *)((uintptr_t)(ptr))) /** Type-safe version of discard_const */ #define discard_const_p(type, ptr) ((type *)discard_const(ptr)) -- cgit From f51a79889c769f0a30eef5bd8a486e08c6bbdad2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 6 May 2008 12:38:55 +0200 Subject: libreplace: check how portable utimes() and futimes() are metze (This used to be commit 8798ce3c744025b94973784dcb44d099427ef190) --- source4/lib/replace/system/config.m4 | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 index 66c2bd652a..ae26bb5590 100644 --- a/source4/lib/replace/system/config.m4 +++ b/source4/lib/replace/system/config.m4 @@ -9,6 +9,7 @@ AC_CHECK_HEADERS(sys/select.h) # time AC_CHECK_HEADERS(sys/time.h utime.h) AC_HEADER_TIME +AC_CHECK_FUNCS(utime utimes futimes) # wait AC_HEADER_SYS_WAIT -- cgit From bbf4ce91462598cee1eebfb94a773194e56a7ff8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 May 2008 13:10:31 +0200 Subject: libreplace: always provide utime() and utimes() I'd like to also provide futimes(), but it seems that some systems doesn't support a it at kernel level. If someone knows how to write a portable replacement for futimes() please tell me... metze (This used to be commit a9604fe4a323dccb537cf02ea7594437b4995803) --- source4/lib/replace/README | 2 + source4/lib/replace/replace.c | 27 +++++++ source4/lib/replace/replace.h | 10 +++ source4/lib/replace/system/config.m4 | 2 +- source4/lib/replace/system/time.h | 15 ++++ source4/lib/replace/test/testsuite.c | 145 +++++++++++++++++++++++++++++++++++ 6 files changed, 200 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 43f7b08572..4d94317c4b 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -62,6 +62,8 @@ getnameinfo gai_strerror getifaddrs freeifaddrs +utime +utimes Types: bool diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 443da2ab24..2c3f14c2df 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -584,3 +584,30 @@ int rep_unsetenv(const char *name) return 0; } #endif + +#ifndef HAVE_UTIME +int rep_utime(const char *filename, const struct utimbuf *buf) +{ + errno = ENOSYS; + return -1; +} +#endif + +#ifndef HAVE_UTIMES +int rep_utimes(const char *filename, const struct timeval tv[2]) +{ + struct utimbuf u; + + u.actime = tv[0].tv_sec; + if (tv[0].tv_usec > 500000) { + u.actime += 1; + } + + u.modtime = tv[1].tv_sec; + if (tv[1].tv_usec > 500000) { + u.modtime += 1; + } + + return utime(filename, &u); +} +#endif diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index bf95169352..c69ea6cdac 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -101,6 +101,16 @@ void *rep_memmove(void *dest,const void *src,int size); /* prototype is in "system/time.h" */ #endif +#ifndef HAVE_UTIME +#define utime rep_utime +/* prototype is in "system/time.h" */ +#endif + +#ifndef HAVE_UTIMES +#define utimes rep_utimes +/* prototype is in "system/time.h" */ +#endif + #ifndef HAVE_STRLCPY #define strlcpy rep_strlcpy size_t rep_strlcpy(char *d, const char *s, size_t bufsize); diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 index ae26bb5590..5c9b53d5c5 100644 --- a/source4/lib/replace/system/config.m4 +++ b/source4/lib/replace/system/config.m4 @@ -9,7 +9,7 @@ AC_CHECK_HEADERS(sys/select.h) # time AC_CHECK_HEADERS(sys/time.h utime.h) AC_HEADER_TIME -AC_CHECK_FUNCS(utime utimes futimes) +AC_CHECK_FUNCS(utime utimes) # wait AC_HEADER_SYS_WAIT diff --git a/source4/lib/replace/system/time.h b/source4/lib/replace/system/time.h index 036812ab8f..4abf295d1a 100644 --- a/source4/lib/replace/system/time.h +++ b/source4/lib/replace/system/time.h @@ -39,6 +39,11 @@ #ifdef HAVE_UTIME_H #include +#else +struct utimbuf { + time_t actime; /* access time */ + time_t modtime; /* modification time */ +}; #endif #ifndef HAVE_MKTIME @@ -51,4 +56,14 @@ time_t rep_mktime(struct tm *t); time_t rep_timegm(struct tm *tm); #endif +#ifndef HAVE_UTIME +/* define is in "replace.h" */ +int rep_utime(const char *filename, const struct utimbuf *buf); +#endif + +#ifndef HAVE_UTIMES +/* define is in "replace.h" */ +int rep_utimes(const char *filename, const struct timeval tv[2]); +#endif + #endif diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index b538360365..1e8290906e 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -872,6 +872,149 @@ static int test_getifaddrs(void) return true; } +static int test_utime(void) +{ + struct utimbuf u; + struct stat st1, st2, st3; + int fd; + + printf("test: utime\n"); + unlink(TESTFILE); + + fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); + if (fd == -1) { + printf("failure: utime [\n" + "creating '%s' failed - %s\n]\n", + TESTFILE, strerror(errno)); + return false; + } + + if (fstat(fd, &st1) != 0) { + printf("failure: utime [\n" + "fstat (1) failed - %s\n]\n", + strerror(errno)); + return false; + } + + u.actime = st1.st_atime + 300; + u.modtime = st1.st_mtime - 300; + if (utime(TESTFILE, &u) != 0) { + printf("failure: utime [\n" + "utime(&u) failed - %s\n]\n", + strerror(errno)); + return false; + } + + if (fstat(fd, &st2) != 0) { + printf("failure: utime [\n" + "fstat (2) failed - %s\n]\n", + strerror(errno)); + return false; + } + + if (utime(TESTFILE, NULL) != 0) { + printf("failure: utime [\n" + "utime(NULL) failed - %s\n]\n", + strerror(errno)); + return false; + } + + if (fstat(fd, &st3) != 0) { + printf("failure: utime [\n" + "fstat (3) failed - %s\n]\n", + strerror(errno)); + return false; + } + +#define CMP_VAL(a,c,b) do { \ + if (a c b) { \ + printf("failure: utime [\n" \ + "%s: %s(%d) %s %s(%d)\n]\n", \ + __location__, \ + #a, (int)a, #c, #b, (int)b); \ + return false; \ + } \ +} while(0) +#define EQUAL_VAL(a,b) CMP_VAL(a,!=,b) +#define GREATER_VAL(a,b) CMP_VAL(a,<=,b) +#define LESSER_VAL(a,b) CMP_VAL(a,>=,b) + + EQUAL_VAL(st2.st_atime, st1.st_atime + 300); + EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300); + LESSER_VAL(st3.st_atime, st2.st_atime); + GREATER_VAL(st3.st_mtime, st2.st_mtime); + +#undef CMP_VAL +#undef EQUAL_VAL +#undef GREATER_VAL +#undef LESSER_VAL + + unlink(TESTFILE); + printf("success: utime\n"); + return true; +} + +static int test_utimes(void) +{ + struct timeval tv[2]; + struct stat st1, st2; + int fd; + + printf("test: utimes\n"); + unlink(TESTFILE); + + fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); + if (fd == -1) { + printf("failure: utimes [\n" + "creating '%s' failed - %s\n]\n", + TESTFILE, strerror(errno)); + return false; + } + + if (fstat(fd, &st1) != 0) { + printf("failure: utimes [\n" + "fstat (1) failed - %s\n]\n", + strerror(errno)); + return false; + } + + ZERO_STRUCT(tv); + tv[0].tv_sec = st1.st_atime + 300; + tv[1].tv_sec = st1.st_mtime - 300; + if (utimes(TESTFILE, tv) != 0) { + printf("failure: utimes [\n" + "utimes(tv) failed - %s\n]\n", + strerror(errno)); + return false; + } + + if (fstat(fd, &st2) != 0) { + printf("failure: utimes [\n" + "fstat (2) failed - %s\n]\n", + strerror(errno)); + return false; + } + +#define EQUAL_VAL(a,b) do { \ + if (a != b) { \ + printf("failure: utimes [\n" \ + "%s: %s(%d) != %s(%d)\n]\n", \ + __location__, \ + #a, (int)a, #b, (int)b); \ + return false; \ + } \ +} while(0) + + EQUAL_VAL(st2.st_atime, st1.st_atime + 300); + EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300); + +#undef EQUAL_VAL + + unlink(TESTFILE); + printf("success: utimes\n"); + return true; +} + struct torture_context; bool torture_local_replace(struct torture_context *ctx) { @@ -920,6 +1063,8 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_socketpair(); ret &= test_strptime(); ret &= test_getifaddrs(); + ret &= test_utime(); + ret &= test_utimes(); return ret; } -- cgit From a0c6043c34abe5451e5de55791fc274e113504af Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 May 2008 16:50:19 +0200 Subject: libreplace: split out network checks into a AC_LIBREPLACE_NETWORK_CHECKS macro Note: moving it out of AC_LIBREPLACE_BROKEN_CHECKS will be the next step metze (This used to be commit 55a904b1d7aeca849d450e371b18afca5b0c6218) --- source4/lib/replace/libreplace.m4 | 65 +--------------------------- source4/lib/replace/libreplace_network.m4 | 71 +++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 63 deletions(-) create mode 100644 source4/lib/replace/libreplace_network.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 8e17258918..1eba93792b 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -96,65 +96,10 @@ fi AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_HEADERS(sys/time.h time.h) AC_CHECK_HEADERS(stdarg.h vararg.h) -AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) -AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) AC_CHECK_HEADERS(sys/sockio.h sys/un.h) AC_CHECK_HEADERS(sys/mount.h mntent.h) AC_CHECK_HEADERS(stropts.h) -dnl we need to check that net/if.h really can be used, to cope with hpux -dnl where including it always fails -AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[ - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - AC_INCLUDES_DEFAULT - #if HAVE_SYS_SOCKET_H - # include - #endif - #include - int main(void) {return 0;}])], - [libreplace_cv_USABLE_NET_IF_H=yes], - [libreplace_cv_USABLE_NET_IF_H=no] - ) -]) -if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then - AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) -fi - -AC_HAVE_TYPE([socklen_t],[#include ]) -AC_HAVE_TYPE([sa_family_t],[#include ]) -AC_HAVE_TYPE([struct addrinfo], [#include ]) -AC_HAVE_TYPE([struct sockaddr], [#include ]) -AC_HAVE_TYPE([struct sockaddr_storage], [ -#include -#include -#include -]) -AC_HAVE_TYPE([struct sockaddr_in6], [ -#include -#include -#include -]) - -if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then -AC_CHECK_MEMBER(struct sockaddr_storage.ss_family, - AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),, - [ -#include -#include -#include - ]) - -if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then -AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family, - AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),, - [ -#include -#include -#include - ]) -fi -fi - AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) @@ -326,19 +271,12 @@ m4_include(getpass.m4) m4_include(strptime.m4) m4_include(win32.m4) m4_include(timegm.m4) -m4_include(socket.m4) -m4_include(inet_ntop.m4) -m4_include(inet_pton.m4) -m4_include(inet_aton.m4) -m4_include(inet_ntoa.m4) -m4_include(getaddrinfo.m4) m4_include(repdir.m4) -m4_include(getifaddrs.m4) -m4_include(socketpair.m4) AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])]) echo "LIBREPLACE_BROKEN_CHECKS: END" +AC_LIBREPLACE_NETWORK_CHECKS ]) dnl end AC_LIBREPLACE_BROKEN_CHECKS AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_START, @@ -361,5 +299,6 @@ CFLAGS="$CFLAGS -I$libreplacedir" m4_include(libreplace_cc.m4) m4_include(libreplace_ld.m4) +m4_include(libreplace_network.m4) m4_include(libreplace_macros.m4) m4_include(autoconf-2.60.m4) diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 new file mode 100644 index 0000000000..7702702799 --- /dev/null +++ b/source4/lib/replace/libreplace_network.m4 @@ -0,0 +1,71 @@ +AC_DEFUN_ONCE(AC_LIBREPLACE_NETWORK_CHECKS, +[ +echo "LIBREPLACE_NETWORK_CHECKS: START" + +AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) +AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) + +dnl we need to check that net/if.h really can be used, to cope with hpux +dnl where including it always fails +AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + AC_INCLUDES_DEFAULT + #if HAVE_SYS_SOCKET_H + # include + #endif + #include + int main(void) {return 0;}])], + [libreplace_cv_USABLE_NET_IF_H=yes], + [libreplace_cv_USABLE_NET_IF_H=no] + ) +]) +if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then + AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) +fi + +AC_HAVE_TYPE([socklen_t],[#include ]) +AC_HAVE_TYPE([sa_family_t],[#include ]) +AC_HAVE_TYPE([struct addrinfo], [#include ]) +AC_HAVE_TYPE([struct sockaddr], [#include ]) +AC_HAVE_TYPE([struct sockaddr_storage], [ +#include +#include +#include +]) +AC_HAVE_TYPE([struct sockaddr_in6], [ +#include +#include +#include +]) + +if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then +AC_CHECK_MEMBER(struct sockaddr_storage.ss_family, + AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),, + [ +#include +#include +#include + ]) + +if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then +AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family, + AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),, + [ +#include +#include +#include + ]) +fi +fi + +m4_include(socket.m4) +m4_include(inet_ntop.m4) +m4_include(inet_pton.m4) +m4_include(inet_aton.m4) +m4_include(inet_ntoa.m4) +m4_include(getaddrinfo.m4) +m4_include(getifaddrs.m4) +m4_include(socketpair.m4) + +echo "LIBREPLACE_NETWORK_CHECKS: END" +]) dnl end AC_LIBREPLACE_NETWORK_CHECKS -- cgit From 63da424e8124a9def5d46f769804be661b059aab Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 May 2008 17:15:36 +0200 Subject: libreplace: use AC_LIBREPLACE_NETWORK_CHECKS only for samba metze (This used to be commit 3451b54bf7f5e37a589ec261d28c2a8b6f9788ed) --- source4/lib/replace/libreplace.m4 | 1 - source4/lib/replace/samba.m4 | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 1eba93792b..2b33d97989 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -276,7 +276,6 @@ m4_include(repdir.m4) AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])]) echo "LIBREPLACE_BROKEN_CHECKS: END" -AC_LIBREPLACE_NETWORK_CHECKS ]) dnl end AC_LIBREPLACE_BROKEN_CHECKS AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_START, diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4 index 7984ef31db..07c4d38887 100644 --- a/source4/lib/replace/samba.m4 +++ b/source4/lib/replace/samba.m4 @@ -1,4 +1,5 @@ AC_LIBREPLACE_BROKEN_CHECKS +AC_LIBREPLACE_NETWORK_CHECKS SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}]) SMB_ENABLE(LIBREPLACE_EXT) -- cgit From 10a208fc4f8de6fdd20e5906f9fc6915124f6f83 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 May 2008 17:38:41 +0200 Subject: libreplace: also use AC_LIBREPLACE_NETWORK_CHECKS for the standalone build metze (This used to be commit 04f4523ed032946b8f0e74ac6f7458010159e3bb) --- source4/lib/replace/configure.ac | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index 02dc08bf72..81997e09b7 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -6,6 +6,7 @@ AC_CONFIG_HEADER(config.h) CFLAGS="$CFLAGS -I$srcdir" AC_LIBREPLACE_ALL_CHECKS +AC_LIBREPLACE_NETWORK_CHECKS if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wall" -- cgit From b3e1d69dcd58a72851b2efefd83ade377c9d2e85 Mon Sep 17 00:00:00 2001 From: William Jojo Date: Thu, 8 May 2008 12:41:57 +0200 Subject: Add undefined symbol flag for AIX. (This used to be commit dabdf24e86f038e3afc67532fa5bf60a37992161) --- source4/lib/replace/libreplace_ld.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index f0d10c1e3e..0d0356055c 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -270,6 +270,10 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG], *darwin*) LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup" ;; + *aix*) + LD_SHLIB_ALLOW_UNDEF_FLAG="--Wl,-bnoentry" + ;; + ; esac AC_SUBST(LD_SHLIB_ALLOW_UNDEF_FLAG) -- cgit From ca6ac11b46a75bf02cf873c6aedb4f85af227168 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 8 May 2008 13:43:45 +0200 Subject: Fix typo. (This used to be commit bd089818a3182698dfe85039c1b2e22d8c2835bb) --- source4/lib/replace/libreplace_ld.m4 | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 0d0356055c..9995d69bbc 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -273,7 +273,6 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG], *aix*) LD_SHLIB_ALLOW_UNDEF_FLAG="--Wl,-bnoentry" ;; - ; esac AC_SUBST(LD_SHLIB_ALLOW_UNDEF_FLAG) -- cgit From 88533f35dd21345143216d420a8972a5421969a4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 09:56:10 +0200 Subject: libreplace: merge socket.m4 into libreplace_network.m4 metze (This used to be commit c70eba87dbbac6c2c1e68c343cdd410577c1686f) --- source4/lib/replace/libreplace_network.m4 | 41 ++++++++++++++++++++++++++++++- source4/lib/replace/socket.m4 | 39 ----------------------------- 2 files changed, 40 insertions(+), 40 deletions(-) delete mode 100644 source4/lib/replace/socket.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index 7702702799..209d418be6 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -58,7 +58,46 @@ AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family, fi fi -m4_include(socket.m4) +dnl The following test is roughl taken from the cvs sources. +dnl +dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet. +dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has +dnl libsocket.so which has a bad implementation of gethostbyname (it +dnl only looks in /etc/hosts), so we only look for -lsocket if we need +dnl it. +AC_CHECK_FUNCS(connect) +if test x"$ac_cv_func_connect" = x"no"; then + AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect) + dnl We can't just call AC_CHECK_FUNCS(connect) here, + dnl because the value has been cached. + if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" || + test x"$ac_cv_lib_ext_nsl_connect" = x"yes" || + test x"$ac_cv_lib_ext_socket_connect" = x"yes" || + test x"$ac_cv_lib_ext_inet_connect" = x"yes" + then + AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()]) + fi +fi + +AC_CHECK_FUNCS(gethostbyname) +if test x"$ac_cv_func_gethostbyname" = x"no"; then + AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname) + dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, + dnl because the value has been cached. + if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" || + test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" || + test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes" + then + AC_DEFINE(HAVE_GETHOSTBYNAME,1, + [Whether the system has gethostbyname()]) + fi +fi + m4_include(inet_ntop.m4) m4_include(inet_pton.m4) m4_include(inet_aton.m4) diff --git a/source4/lib/replace/socket.m4 b/source4/lib/replace/socket.m4 deleted file mode 100644 index 984f81f15f..0000000000 --- a/source4/lib/replace/socket.m4 +++ /dev/null @@ -1,39 +0,0 @@ -dnl The following test is roughl taken from the cvs sources. -dnl -dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet. -dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has -dnl libsocket.so which has a bad implementation of gethostbyname (it -dnl only looks in /etc/hosts), so we only look for -lsocket if we need -dnl it. -AC_CHECK_FUNCS(connect) -if test x"$ac_cv_func_connect" = x"no"; then - AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect) - AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect) - AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect) - AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect) - dnl We can't just call AC_CHECK_FUNCS(connect) here, - dnl because the value has been cached. - if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" || - test x"$ac_cv_lib_ext_nsl_connect" = x"yes" || - test x"$ac_cv_lib_ext_socket_connect" = x"yes" || - test x"$ac_cv_lib_ext_inet_connect" = x"yes" - then - AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()]) - fi -fi - -AC_CHECK_FUNCS(gethostbyname) -if test x"$ac_cv_func_gethostbyname" = x"no"; then - AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname) - AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname) - AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname) - dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, - dnl because the value has been cached. - if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" || - test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" || - test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes" - then - AC_DEFINE(HAVE_GETHOSTBYNAME,1, - [Whether the system has gethostbyname()]) - fi -fi -- cgit From 41eaffe653b244e0fb66d16bad0899c5f51aa9e4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 09:58:07 +0200 Subject: libreplace: merge inet_ntoa.m4 into libreplace_network.m4 metze (This used to be commit 82e826253b6d18832931dbb5c1dda009889bf9e0) --- source4/lib/replace/inet_ntoa.m4 | 19 ------------------- source4/lib/replace/libreplace_network.m4 | 21 ++++++++++++++++++++- 2 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 source4/lib/replace/inet_ntoa.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/inet_ntoa.m4 b/source4/lib/replace/inet_ntoa.m4 deleted file mode 100644 index 5aaa9350c5..0000000000 --- a/source4/lib/replace/inet_ntoa.m4 +++ /dev/null @@ -1,19 +0,0 @@ -AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"]) - -AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ -AC_TRY_RUN([ -#include -#include -#include -#include -#ifdef HAVE_ARPA_INET_H -#include -#endif -main() { struct in_addr ip; ip.s_addr = 0x12345678; -if (strcmp(inet_ntoa(ip),"18.52.86.120") && - strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } -exit(1);}], - libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) -if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then - AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) -fi diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index 209d418be6..35aa3ede7c 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -98,10 +98,29 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then fi fi +AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"]) + +AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ +AC_TRY_RUN([ +#include +#include +#include +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +main() { struct in_addr ip; ip.s_addr = 0x12345678; +if (strcmp(inet_ntoa(ip),"18.52.86.120") && + strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } +exit(1);}], + libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) +if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then + AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) +fi + m4_include(inet_ntop.m4) m4_include(inet_pton.m4) m4_include(inet_aton.m4) -m4_include(inet_ntoa.m4) m4_include(getaddrinfo.m4) m4_include(getifaddrs.m4) m4_include(socketpair.m4) -- cgit From b6b96be0c21a0efc19962b2a0b6610835aa3f93d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 09:59:16 +0200 Subject: libreplace: merge inet_aton.m4 into libreplace_network.m4 metze (This used to be commit fba00736c870f449c0eee32fe0d7b0d539dca51f) --- source4/lib/replace/inet_aton.m4 | 1 - source4/lib/replace/libreplace_network.m4 | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 source4/lib/replace/inet_aton.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/inet_aton.m4 b/source4/lib/replace/inet_aton.m4 deleted file mode 100644 index 853688ef6b..0000000000 --- a/source4/lib/replace/inet_aton.m4 +++ /dev/null @@ -1 +0,0 @@ -AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"]) diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index 35aa3ede7c..66c8192a1e 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -118,9 +118,10 @@ if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) fi +AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"]) + m4_include(inet_ntop.m4) m4_include(inet_pton.m4) -m4_include(inet_aton.m4) m4_include(getaddrinfo.m4) m4_include(getifaddrs.m4) m4_include(socketpair.m4) -- cgit From 8408101e248587f9f3614fb4f9a644bfdf7abd49 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:00:58 +0200 Subject: libreplace: merge inet_ntop.m4 into libreplace_network.m4 metze (This used to be commit 223ef6c08efb52251d0a772bb0c481b2803cf0ce) --- source4/lib/replace/inet_ntop.m4 | 1 - source4/lib/replace/libreplace_network.m4 | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 source4/lib/replace/inet_ntop.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/inet_ntop.m4 b/source4/lib/replace/inet_ntop.m4 deleted file mode 100644 index 6f39056f1d..0000000000 --- a/source4/lib/replace/inet_ntop.m4 +++ /dev/null @@ -1 +0,0 @@ -AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"]) diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index 66c8192a1e..7ee7519e7e 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -120,7 +120,8 @@ fi AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"]) -m4_include(inet_ntop.m4) +AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"]) + m4_include(inet_pton.m4) m4_include(getaddrinfo.m4) m4_include(getifaddrs.m4) -- cgit From 1155c2f457bfc807abf4f798bb5940fc84994dca Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:02:21 +0200 Subject: libreplace: merge inet_pton.m4 into libreplace_network.m4 metze (This used to be commit 3a70274c908e31453942b442351eab8423c1a53d) --- source4/lib/replace/inet_pton.m4 | 1 - source4/lib/replace/libreplace_network.m4 | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 source4/lib/replace/inet_pton.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/inet_pton.m4 b/source4/lib/replace/inet_pton.m4 deleted file mode 100644 index 51de9275d0..0000000000 --- a/source4/lib/replace/inet_pton.m4 +++ /dev/null @@ -1 +0,0 @@ -AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"]) diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index 7ee7519e7e..25ededb027 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -122,7 +122,8 @@ AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"]) AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"]) -m4_include(inet_pton.m4) +AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"]) + m4_include(getaddrinfo.m4) m4_include(getifaddrs.m4) m4_include(socketpair.m4) -- cgit From 254641d3f21d54927e46304c3fb091909f2c5ba3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:04:51 +0200 Subject: libreplace: merge socketpair.m4 into libreplace_network.m4 metze (This used to be commit f9f8f93adcc7161ebb18f5a0bf28c73d951a15ad) --- source4/lib/replace/libreplace_network.m4 | 3 ++- source4/lib/replace/socketpair.m4 | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 source4/lib/replace/socketpair.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index 25ededb027..87f6153e90 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -98,6 +98,8 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then fi fi +AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"]) + AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"]) AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ @@ -126,7 +128,6 @@ AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"]) m4_include(getaddrinfo.m4) m4_include(getifaddrs.m4) -m4_include(socketpair.m4) echo "LIBREPLACE_NETWORK_CHECKS: END" ]) dnl end AC_LIBREPLACE_NETWORK_CHECKS diff --git a/source4/lib/replace/socketpair.m4 b/source4/lib/replace/socketpair.m4 deleted file mode 100644 index 7088334cda..0000000000 --- a/source4/lib/replace/socketpair.m4 +++ /dev/null @@ -1 +0,0 @@ -AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"]) -- cgit From 108443ace5ca4198a319c0b3619b530afd337594 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:06:39 +0200 Subject: libreplace: merge getaddrinfo.m4 into libreplace_network.m4 metze (This used to be commit 64591d064dc3da6074f0f7539911a6e433d9cc43) --- source4/lib/replace/getaddrinfo.m4 | 32 ----------------------------- source4/lib/replace/libreplace_network.m4 | 34 ++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 33 deletions(-) delete mode 100644 source4/lib/replace/getaddrinfo.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getaddrinfo.m4 b/source4/lib/replace/getaddrinfo.m4 deleted file mode 100644 index bc6e69ea56..0000000000 --- a/source4/lib/replace/getaddrinfo.m4 +++ /dev/null @@ -1,32 +0,0 @@ -dnl test for getaddrinfo/getnameinfo -AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[ -AC_TRY_LINK([ -#include -#if STDC_HEADERS -#include -#include -#endif -#include -#include ], -[ -struct sockaddr sa; -struct addrinfo *ai = NULL; -int ret = getaddrinfo(NULL, NULL, NULL, &ai); -if (ret != 0) { - const char *es = gai_strerror(ret); -} -freeaddrinfo(ai); -ret = getnameinfo(&sa, sizeof(sa), - NULL, 0, - NULL, 0, 0); - -], -libreplace_cv_HAVE_GETADDRINFO=yes,libreplace_cv_HAVE_GETADDRINFO=no)]) -if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then - AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo]) - AC_DEFINE(HAVE_GETNAMEINFO,1,[Whether the system has getnameinfo]) - AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo]) - AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror]) -else - LIBREPLACEOBJ="${LIBREPLACEOBJ} getaddrinfo.o" -fi diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index 87f6153e90..ff41056891 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -126,7 +126,39 @@ AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"]) AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"]) -m4_include(getaddrinfo.m4) +dnl test for getaddrinfo/getnameinfo +AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[ +AC_TRY_LINK([ +#include +#if STDC_HEADERS +#include +#include +#endif +#include +#include ], +[ +struct sockaddr sa; +struct addrinfo *ai = NULL; +int ret = getaddrinfo(NULL, NULL, NULL, &ai); +if (ret != 0) { + const char *es = gai_strerror(ret); +} +freeaddrinfo(ai); +ret = getnameinfo(&sa, sizeof(sa), + NULL, 0, + NULL, 0, 0); + +], +libreplace_cv_HAVE_GETADDRINFO=yes,libreplace_cv_HAVE_GETADDRINFO=no)]) +if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then + AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo]) + AC_DEFINE(HAVE_GETNAMEINFO,1,[Whether the system has getnameinfo]) + AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo]) + AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror]) +else + LIBREPLACEOBJ="${LIBREPLACEOBJ} getaddrinfo.o" +fi + m4_include(getifaddrs.m4) echo "LIBREPLACE_NETWORK_CHECKS: END" -- cgit From 0301064c6576af0ba5e8acd051758086cc45f082 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:08:42 +0200 Subject: libreplace: merge getifaddrs.m4 into libreplace_network.m4 metze (This used to be commit 0234d397fefee8e1d0dcd3402f748c2251021c90) --- source4/lib/replace/getifaddrs.m4 | 128 ------------------------------ source4/lib/replace/libreplace_network.m4 | 128 +++++++++++++++++++++++++++++- 2 files changed, 127 insertions(+), 129 deletions(-) delete mode 100644 source4/lib/replace/getifaddrs.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 deleted file mode 100644 index 927bc677db..0000000000 --- a/source4/lib/replace/getifaddrs.m4 +++ /dev/null @@ -1,128 +0,0 @@ -AC_CHECK_HEADERS([ifaddrs.h]) - -dnl Used when getifaddrs is not available -AC_CHECK_MEMBERS([struct sockaddr.sa_len], - [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])], - [], - [#include ]) - -dnl test for getifaddrs and freeifaddrs -AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[ -AC_TRY_COMPILE([ -#include -#if STDC_HEADERS -#include -#include -#endif -#include -#include -#include -#include -#include ], -[ -struct ifaddrs *ifp = NULL; -int ret = getifaddrs (&ifp); -freeifaddrs(ifp); -], -libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)]) -if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then - AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs]) - AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs]) - AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available]) -fi - -################## -# look for a method of finding the list of network interfaces -# -# This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" -# -old_LIBS=$LIBS -LIBS="${LIBREPLACE_NETWORK_LIBS}" -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS -I$libreplacedir" -iface=no; -################## -# look for a method of finding the list of network interfaces -iface=no; -AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[ -AC_TRY_RUN([ -#define HAVE_IFACE_GETIFADDRS 1 -#define NO_CONFIG_H 1 -#define AUTOCONF_TEST 1 -#define SOCKET_WRAPPER_NOT_REPLACE -#include "$libreplacedir/replace.c" -#include "$libreplacedir/inet_ntop.c" -#include "$libreplacedir/snprintf.c" -#include "$libreplacedir/getifaddrs.c" -#define getifaddrs_test main -#include "$libreplacedir/test/getifaddrs.c"], - libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)]) -if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) -else - LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o" -fi - - -if test $iface = no; then -AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ -AC_TRY_RUN([ -#define HAVE_IFACE_AIX 1 -#define NO_CONFIG_H 1 -#define AUTOCONF_TEST 1 -#undef _XOPEN_SOURCE_EXTENDED -#define SOCKET_WRAPPER_NOT_REPLACE -#include "$libreplacedir/replace.c" -#include "$libreplacedir/inet_ntop.c" -#include "$libreplacedir/snprintf.c" -#include "$libreplacedir/getifaddrs.c" -#define getifaddrs_test main -#include "$libreplacedir/test/getifaddrs.c"], - libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) -if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) -fi -fi - - -if test $iface = no; then -AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ -AC_TRY_RUN([ -#define HAVE_IFACE_IFCONF 1 -#define NO_CONFIG_H 1 -#define AUTOCONF_TEST 1 -#define SOCKET_WRAPPER_NOT_REPLACE -#include "$libreplacedir/replace.c" -#include "$libreplacedir/inet_ntop.c" -#include "$libreplacedir/snprintf.c" -#include "$libreplacedir/getifaddrs.c" -#define getifaddrs_test main -#include "$libreplacedir/test/getifaddrs.c"], - libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) -if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) -fi -fi - -if test $iface = no; then -AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ -AC_TRY_RUN([ -#define HAVE_IFACE_IFREQ 1 -#define NO_CONFIG_H 1 -#define AUTOCONF_TEST 1 -#define SOCKET_WRAPPER_NOT_REPLACE -#include "$libreplacedir/replace.c" -#include "$libreplacedir/inet_ntop.c" -#include "$libreplacedir/snprintf.c" -#include "$libreplacedir/getifaddrs.c" -#define getifaddrs_test main -#include "$libreplacedir/test/getifaddrs.c"], - libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) -if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) -fi -fi - -LIBS=$old_LIBS -CPPFLAGS="$SAVE_CPPFLAGS" - diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index ff41056891..5ff699b36a 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -159,7 +159,133 @@ else LIBREPLACEOBJ="${LIBREPLACEOBJ} getaddrinfo.o" fi -m4_include(getifaddrs.m4) +AC_CHECK_HEADERS([ifaddrs.h]) + +dnl Used when getifaddrs is not available +AC_CHECK_MEMBERS([struct sockaddr.sa_len], + [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])], + [], + [#include ]) + +dnl test for getifaddrs and freeifaddrs +AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[ +AC_TRY_COMPILE([ +#include +#if STDC_HEADERS +#include +#include +#endif +#include +#include +#include +#include +#include ], +[ +struct ifaddrs *ifp = NULL; +int ret = getifaddrs (&ifp); +freeifaddrs(ifp); +], +libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)]) +if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then + AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs]) + AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs]) + AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available]) +fi + +################## +# look for a method of finding the list of network interfaces +# +# This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" +# +old_LIBS=$LIBS +LIBS="${LIBREPLACE_NETWORK_LIBS}" +SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -I$libreplacedir" +iface=no; +################## +# look for a method of finding the list of network interfaces +iface=no; +AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[ +AC_TRY_RUN([ +#define HAVE_IFACE_GETIFADDRS 1 +#define NO_CONFIG_H 1 +#define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], + libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) +else + LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o" +fi + + +if test $iface = no; then +AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ +AC_TRY_RUN([ +#define HAVE_IFACE_AIX 1 +#define NO_CONFIG_H 1 +#define AUTOCONF_TEST 1 +#undef _XOPEN_SOURCE_EXTENDED +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], + libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) +fi +fi + + +if test $iface = no; then +AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ +AC_TRY_RUN([ +#define HAVE_IFACE_IFCONF 1 +#define NO_CONFIG_H 1 +#define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], + libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) +fi +fi + +if test $iface = no; then +AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ +AC_TRY_RUN([ +#define HAVE_IFACE_IFREQ 1 +#define NO_CONFIG_H 1 +#define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], + libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) +fi +fi + +LIBS=$old_LIBS +CPPFLAGS="$SAVE_CPPFLAGS" echo "LIBREPLACE_NETWORK_CHECKS: END" ]) dnl end AC_LIBREPLACE_NETWORK_CHECKS -- cgit From c9b617ce3a4f17497273b90a021209d3eb466a60 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:27:23 +0200 Subject: libreplace: include inet_ntoa.o when the system one is broken metze (This used to be commit 67845d3471711d24069636d0d4032f9d53748334) --- source4/lib/replace/libreplace_network.m4 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index 5ff699b36a..6d10313e47 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -100,8 +100,6 @@ fi AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"]) -AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"]) - AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ #include @@ -116,8 +114,11 @@ if (strcmp(inet_ntoa(ip),"18.52.86.120") && strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } exit(1);}], libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) + +AC_CHECK_FUNCS(inet_ntoa,[],[libreplace_cv_REPLACE_INET_NTOA=yes]) if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) + LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o" fi AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"]) -- cgit From 6353e83dc27132a47966302a68b8e4934bce442c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:32:19 +0200 Subject: libreplace: export LIBREPLACE_NETWORK_OBJS and LIBREPLACE_NETWORK_LIBS vars metze (This used to be commit aa7ef1af746319a3d771decd0ec03dabe8b8ad28) --- source4/lib/replace/libreplace_network.m4 | 35 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index 6d10313e47..f1657d9f79 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -2,6 +2,9 @@ AC_DEFUN_ONCE(AC_LIBREPLACE_NETWORK_CHECKS, [ echo "LIBREPLACE_NETWORK_CHECKS: START" +LIBREPLACE_NETWORK_OBJS="" +LIBREPLACE_NETWORK_LIBS="" + AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) @@ -98,7 +101,13 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then fi fi -AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"]) +# The following tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" +old_LIBS=$LIBS +LIBS="${LIBREPLACE_NETWORK_LIBS}" +SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -I$libreplacedir" + +AC_CHECK_FUNCS(socketpair,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} socketpair.o"]) AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ @@ -118,14 +127,14 @@ exit(1);}], AC_CHECK_FUNCS(inet_ntoa,[],[libreplace_cv_REPLACE_INET_NTOA=yes]) if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) - LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o" + LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_ntoa.o" fi -AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"]) +AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_aton.o"]) -AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"]) +AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_ntop.o"]) -AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"]) +AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_pton.o"]) dnl test for getaddrinfo/getnameinfo AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[ @@ -157,7 +166,7 @@ if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo]) AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror]) else - LIBREPLACEOBJ="${LIBREPLACEOBJ} getaddrinfo.o" + LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} getaddrinfo.o" fi AC_CHECK_HEADERS([ifaddrs.h]) @@ -193,16 +202,6 @@ if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available]) fi -################## -# look for a method of finding the list of network interfaces -# -# This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" -# -old_LIBS=$LIBS -LIBS="${LIBREPLACE_NETWORK_LIBS}" -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS -I$libreplacedir" -iface=no; ################## # look for a method of finding the list of network interfaces iface=no; @@ -222,7 +221,7 @@ AC_TRY_RUN([ if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) else - LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o" + LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} getifaddrs.o" fi @@ -288,5 +287,7 @@ fi LIBS=$old_LIBS CPPFLAGS="$SAVE_CPPFLAGS" +LIBREPLACEOBJ="${LIBREPLACEOBJ} ${LIBREPLACE_NETWORK_OBJS}" + echo "LIBREPLACE_NETWORK_CHECKS: END" ]) dnl end AC_LIBREPLACE_NETWORK_CHECKS -- cgit From dd01174d092eec9bb3bb6b680786f8b9f3b4668f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:39:41 +0200 Subject: libreplace: make sure system/network.h is only used when AC_LIBREPLACE_NETWORK_CHECKS was used metze (This used to be commit 3fddd36e119f73a5021370450f9687ef9d252bab) --- source4/lib/replace/libreplace_network.m4 | 1 + source4/lib/replace/system/network.h | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index f1657d9f79..56c603a155 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -2,6 +2,7 @@ AC_DEFUN_ONCE(AC_LIBREPLACE_NETWORK_CHECKS, [ echo "LIBREPLACE_NETWORK_CHECKS: START" +AC_DEFINE(LIBREPLACE_NETWORK_CHECKS, 1, [LIBREPLACE_NETWORK_CHECKS were used]) LIBREPLACE_NETWORK_OBJS="" LIBREPLACE_NETWORK_LIBS="" diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index a5fb813aa1..077892a54e 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -27,6 +27,10 @@ */ +#ifndef LIBREPLACE_NETWORK_CHECKS +#error "AC_LIBREPLACE_NETWORK_CHECKS missing in configure" +#endif + #ifdef HAVE_SYS_SOCKET_H #include #endif -- cgit From 0e4ae88d3856869a5bb327ed26e155f22bdffc09 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 11:01:09 +0200 Subject: libreplace: try to fix the build on HP-UX which has if_nametoindex() in -lipv6 metze (This used to be commit da2179ee5d5b6094ab63a9d9d6a8d59893937087) --- source4/lib/replace/libreplace_network.m4 | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index 56c603a155..5ab71f160a 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -102,6 +102,19 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then fi fi +dnl HP-UX has if_nametoindex in -lipv6 +AC_CHECK_FUNCS(if_nametoindex) +if test x"$ac_cv_func_if_nametoindex" = x"no"; then + AC_CHECK_LIB_EXT(ipv6, LIBREPLACE_NETWORK_LIBS, if_nametoindex) + dnl We can't just call AC_CHECK_FUNCS(if_nametoindex) here, + dnl because the value has been cached. + if test x"$ac_cv_lib_ext_ipv6_if_nametoindex" = x"yes" + then + AC_DEFINE(HAVE_IF_NAMETOINDEX, 1, + [Whether the system has if_nametoindex()]) + fi +fi + # The following tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" old_LIBS=$LIBS LIBS="${LIBREPLACE_NETWORK_LIBS}" -- cgit From a65e5994ad9ecc2a70f24a5080a1c311d22ed2be Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 May 2008 12:29:21 +0200 Subject: lib/replace: add checks for HAVE_SOCK_SIN_LEN and HAVE_UNIXSOCKET Moved from the samba specific locations metze (This used to be commit e674128ee2f11596f358ed46104c9d25eb2f754f) --- source4/lib/replace/libreplace_network.m4 | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index 5ab71f160a..d29c13196d 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -62,6 +62,46 @@ AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family, fi fi +AC_CACHE_CHECK([for sin_len in sock],libreplace_cv_HAVE_SOCK_SIN_LEN,[ + AC_TRY_COMPILE( + [ +#include +#include +#include + ],[ +struct sockaddr_in sock; sock.sin_len = sizeof(sock); + ],[ + libreplace_cv_HAVE_SOCK_SIN_LEN=yes + ],[ + libreplace_cv_HAVE_SOCK_SIN_LEN=no + ]) +]) +if test x"$libreplace_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then + AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property]) +fi + +############################################ +# check for unix domain sockets +AC_CACHE_CHECK([for unix domain sockets],libreplace_cv_HAVE_UNIXSOCKET,[ + AC_TRY_COMPILE([ +#include +#include +#include +#include +#include + ],[ +struct sockaddr_un sunaddr; +sunaddr.sun_family = AF_UNIX; + ],[ + libreplace_cv_HAVE_UNIXSOCKET=yes + ],[ + libreplace_cv_HAVE_UNIXSOCKET=no + ]) +]) +if test x"$libreplace_cv_HAVE_UNIXSOCKET" = x"yes"; then + AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support]) +fi + dnl The following test is roughl taken from the cvs sources. dnl dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet. -- cgit From 097b5ae7633d2f89abe9f89202a8af1438b590cd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 May 2008 12:46:10 +0200 Subject: lib/replace: move sys/sockio.h and sys/un.h checks into AC_LIBREPLACE_NETWORK_CHECKS metze (This used to be commit 7f26a5425e706a97cc07c5139b3fea4fde9e4020) --- source4/lib/replace/libreplace.m4 | 1 - source4/lib/replace/libreplace_network.m4 | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 2b33d97989..6a85ff5a82 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -96,7 +96,6 @@ fi AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_HEADERS(sys/time.h time.h) AC_CHECK_HEADERS(stdarg.h vararg.h) -AC_CHECK_HEADERS(sys/sockio.h sys/un.h) AC_CHECK_HEADERS(sys/mount.h mntent.h) AC_CHECK_HEADERS(stropts.h) diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index d29c13196d..f2d177b165 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -8,6 +8,7 @@ LIBREPLACE_NETWORK_LIBS="" AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) +AC_CHECK_HEADERS(sys/sockio.h sys/un.h) dnl we need to check that net/if.h really can be used, to cope with hpux dnl where including it always fails -- cgit From e029dfe9eac32c35ed34eb12927aa6a0b5af31f1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 21 May 2008 21:27:45 +0200 Subject: libreplace: add test for HAVE_IPV6 Samba can later just check libreplace_cv_HAVE_IPV6 = yes. metze (This used to be commit e835e7eebcc064ce0813814796828f15ad112fbd) --- source4/lib/replace/libreplace_network.m4 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index f2d177b165..6cde6b9e0c 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -339,6 +339,35 @@ if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then fi fi +dnl test for ipv6 +AC_CACHE_CHECK([for ipv6 support],libreplace_cv_HAVE_IPV6,[ + AC_TRY_COMPILE([ +#include /* for NULL */ +#include +#include +#include + ], + [ +struct sockaddr_storage sa_store; +struct addrinfo *ai = NULL; +struct in6_addr in6addr; +int idx = if_nametoindex("iface1"); +int s = socket(AF_INET6, SOCK_STREAM, 0); +int ret = getaddrinfo(NULL, NULL, NULL, &ai); +if (ret != 0) { + const char *es = gai_strerror(ret); +} +freeaddrinfo(ai); + ],[ + libreplace_cv_HAVE_IPV6=yes + ],[ + libreplace_cv_HAVE_IPV6=no + ]) +]) +if test x"$libreplace_cv_HAVE_IPV6" = x"yes"; then + AC_DEFINE(HAVE_IPV6,1,[Whether the system has IPv6 support]) +fi + LIBS=$old_LIBS CPPFLAGS="$SAVE_CPPFLAGS" -- cgit From 5ab27ba7f0facbad4ba14b4246bc47e05b5da347 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 May 2008 15:00:19 +0200 Subject: libreplace: we need to use AC_TRY_LINK() to make sure HAVE_IPV6 is correctly detected metze (This used to be commit 84b5652d3e5766521436e4c7d59615b08b2bb198) --- source4/lib/replace/libreplace_network.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 index 6cde6b9e0c..4edb55c03a 100644 --- a/source4/lib/replace/libreplace_network.m4 +++ b/source4/lib/replace/libreplace_network.m4 @@ -341,7 +341,7 @@ fi dnl test for ipv6 AC_CACHE_CHECK([for ipv6 support],libreplace_cv_HAVE_IPV6,[ - AC_TRY_COMPILE([ + AC_TRY_LINK([ #include /* for NULL */ #include #include -- cgit From 1e7dc5675280d567db1b6a243d48c5617dba5872 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 May 2008 15:50:52 +0200 Subject: Fix extra dash in command line flag. (This used to be commit c823cfadb0b20a0782fc4a8a0b63dcb9116f82be) --- source4/lib/replace/libreplace_ld.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 9995d69bbc..81bde46219 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -271,7 +271,7 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG], LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup" ;; *aix*) - LD_SHLIB_ALLOW_UNDEF_FLAG="--Wl,-bnoentry" + LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-bnoentry" ;; esac -- cgit From 1b955253ff34f6a8a431899051dd784ace32a9ba Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 9 Jun 2008 10:38:09 +0200 Subject: libreplace: fix warnings with autoconf-2.62 rename ac_ => libreplace_cv_ AC_CACHE_VAL() variables must contain _cv_ to be cached. metze (This used to be commit 67e43860b4973a458676b36785570bb4a66e046a) --- source4/lib/replace/win32.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/win32.m4 b/source4/lib/replace/win32.m4 index 9ac84cdf2a..eb364e2cb9 100644 --- a/source4/lib/replace/win32.m4 +++ b/source4/lib/replace/win32.m4 @@ -2,7 +2,7 @@ AC_CHECK_HEADERS(direct.h windows.h winsock2.h ws2tcpip.h) ####################################### # Check for mkdir mode -AC_CACHE_CHECK( [whether mkdir supports mode], ac_mkdir_has_mode, +AC_CACHE_CHECK( [whether mkdir supports mode], libreplace_cv_mkdir_has_mode, AC_TRY_COMPILE([ #include #ifdef HAVE_DIRECT_H @@ -11,10 +11,10 @@ AC_CACHE_CHECK( [whether mkdir supports mode], ac_mkdir_has_mode, mkdir("foo",0777); return 0; ], - ac_mkdir_has_mode="yes", - ac_mkdir_has_mode="no") ) + libreplace_cv_mkdir_has_mode="yes", + libreplace_cv_mkdir_has_mode="no") ) -if test "$ac_mkdir_has_mode" = "yes" +if test "$libreplace_cv_mkdir_has_mode" = "yes" then AC_DEFINE(HAVE_MKDIR_MODE, 1, [Define if target mkdir supports mode option]) fi -- cgit From d54c171a1a120980f075d05823f2c112e80dd097 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 9 Jun 2008 10:39:48 +0200 Subject: libreplace: only include AC_USE_SYSTEM_EXTENSIONS fallback if required This fixes ./autogen.sh with autoconf-2.62 metze (This used to be commit 72bb01dda4d425528e28cd96e249595dc6c1952f) --- source4/lib/replace/libreplace.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 6a85ff5a82..71fa041672 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -299,4 +299,5 @@ m4_include(libreplace_cc.m4) m4_include(libreplace_ld.m4) m4_include(libreplace_network.m4) m4_include(libreplace_macros.m4) -m4_include(autoconf-2.60.m4) + +m4_ifndef([AC_USE_SYSTEM_EXTENSIONS],[m4_include(autoconf-2.60.m4)]) -- cgit From d8ac9bde86f349fecb997a2c8c4d0e2cbfe22542 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 Jul 2008 12:01:15 -0700 Subject: Fix bug #5578, reported by sendel2000@hotbox.ru. Bad (non-Samba) use of strlcat gives error. Jeremy. (This used to be commit e633dc4ec2d72c3d34b5e096e0460e07e07ab514) --- source4/lib/replace/replace.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 2c3f14c2df..106c9dfe62 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -82,6 +82,9 @@ size_t rep_strlcat(char *d, const char *s, size_t bufsize) size_t ret = len1 + len2; if (len1+len2 >= bufsize) { + if (bufsize < (len1+1)) { + return ret; + } len2 = bufsize - (len1+1); } if (len2 > 0) { -- cgit From 5fd1c5445b16cbe4927aaae60a099dde597ef7b4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Aug 2008 19:30:16 +0200 Subject: libreplace: include and and no heimdal specific headers metze (This used to be commit cffed8e19e22a1fa7b7a322b153df5d54e4c3be2) --- source4/lib/replace/system/kerberos.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/kerberos.h b/source4/lib/replace/system/kerberos.h index 78aa7b943f..2981024bee 100644 --- a/source4/lib/replace/system/kerberos.h +++ b/source4/lib/replace/system/kerberos.h @@ -129,8 +129,9 @@ /* Whether krb5_princ_realm returns krb5_realm or krb5_data */ #define KRB5_PRINC_REALM_RETURNS_REALM 1 -#include "heimdal/lib/krb5/krb5.h" -#include "heimdal/lib/com_err/com_err.h" +#include +#include + #endif #endif -- cgit From b2c4838543fc2e42771a34cc9aa05f03793b88fc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 9 May 2008 14:51:45 -0700 Subject: Fix replacement getpass. If we ^C at the prompt echo was left off. Jeremy. (cherry picked from commit e54c71954ae484fe4a4e195db33440490e78e256) (This used to be commit d61a86b8cdb4dd474611baadc61a0c37db0f8e62) --- source4/lib/replace/getpass.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 73333b9021..0be618fc91 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -187,10 +187,6 @@ char *rep_getpass(const char *prompt) in_fd = fileno(in); if (fgets(buf, bufsize, in) == NULL) { buf[0] = 0; - if (in && in != stdin) { - fclose(in); - } - return buf; } } nread = strlen(buf); @@ -201,8 +197,9 @@ char *rep_getpass(const char *prompt) /* Restore echoing. */ if (echo_off) { - if (gotintr && in_fd == -1) + if (gotintr && in_fd == -1) { in = fopen ("/dev/tty", "w+"); + } if (in != NULL) tcsetattr (fileno (in), TCSANOW, &t); } -- cgit From 277e095f78ec4d222a6a71ee92d1d83efd08a5e0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 10 Jun 2008 16:14:30 +0200 Subject: Correctly find a [u]int32_t replacement (cherry picked from commit 346375cda557a675f8f882ca2ae8edffec725a72) (cherry picked from commit 15a53945c9563b4517bd8b69a9bb0554eef5edff) (This used to be commit 46c3fc67e91bbdb820e4bddd085933a8570e504c) --- source4/lib/replace/libreplace_cc.m4 | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index 0ce0958a96..bed05582d8 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -109,25 +109,34 @@ AC_CHECK_HEADERS([standards.h]) # Solaris needs HAVE_LONG_LONG defined AC_CHECK_TYPES(long long) +AC_CHECK_SIZEOF(int) +AC_CHECK_SIZEOF(char) +AC_CHECK_SIZEOF(short) +AC_CHECK_SIZEOF(long) +AC_CHECK_SIZEOF(long long) + AC_CHECK_TYPE(uint_t, unsigned int) AC_CHECK_TYPE(int8_t, char) AC_CHECK_TYPE(uint8_t, unsigned char) AC_CHECK_TYPE(int16_t, short) AC_CHECK_TYPE(uint16_t, unsigned short) + +if test $ac_cv_sizeof_int -eq 4 ; then +AC_CHECK_TYPE(int32_t, int) +AC_CHECK_TYPE(uint32_t, unsigned int) +elif test $ac_cv_size_long -eq 4 ; then AC_CHECK_TYPE(int32_t, long) AC_CHECK_TYPE(uint32_t, unsigned long) +else +AC_MSG_ERROR([LIBREPLACE no 32-bit type found]) +fi + AC_CHECK_TYPE(int64_t, long long) AC_CHECK_TYPE(uint64_t, unsigned long long) AC_CHECK_TYPE(size_t, unsigned int) AC_CHECK_TYPE(ssize_t, int) -AC_CHECK_SIZEOF(int) -AC_CHECK_SIZEOF(char) -AC_CHECK_SIZEOF(short) -AC_CHECK_SIZEOF(long) -AC_CHECK_SIZEOF(long long) - AC_CHECK_SIZEOF(off_t) AC_CHECK_SIZEOF(size_t) AC_CHECK_SIZEOF(ssize_t) -- cgit From 2bb8ef091c7ea0e77d221d3bef467ed4dfb3d441 Mon Sep 17 00:00:00 2001 From: Karolin Seeger Date: Mon, 14 Jul 2008 16:40:36 +0200 Subject: Fix typo. retieve -> retrieve Karolin (partialy cherry-picked from 37c64130701ab13b6f34998ac17fec2d128c2e08) metze (This used to be commit 4d92e6d582a5b2094b2aaa9008a54b37ccfcc2d7) --- source4/lib/replace/snprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index a174dcffed..c54d721ce5 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -526,7 +526,7 @@ static int dopr(char *buffer, size_t maxlen, const char *format, va_list args_in } } - /* retieve the format arguments */ + /* retrieve the format arguments */ for (pnum = 0; pnum < max_pos; pnum++) { int i; -- cgit From b3b28162b66117421996008dce29ca25b342e20a Mon Sep 17 00:00:00 2001 From: Yannick Bergeron Date: Wed, 6 Aug 2008 13:23:00 -0400 Subject: Solve an IBM XL C/C++ compiler error encountered in get_exit_code() auth_errors array initialization in client/smbspool.c (cherry picked from commit b45e7fabc64e699e4fa013ef15f98a004dae3f32) (This used to be commit 661f8e166118d257ab32a30392cd616db097bc4c) --- source4/lib/replace/libreplace_cc.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4 index bed05582d8..30c63f2f05 100644 --- a/source4/lib/replace/libreplace_cc.m4 +++ b/source4/lib/replace/libreplace_cc.m4 @@ -167,7 +167,8 @@ AC_CACHE_CHECK([for immediate structures],libreplace_cv_immediate_structures,[ FOOBAR y; } f2[] = { {FOO_ONE} - }; + }; + static const FOOBAR f3[] = {FOO_ONE}; ], libreplace_cv_immediate_structures=yes, libreplace_cv_immediate_structures=no, -- cgit From 6b7c4413fec1337b843d40c4192ccc7f28df83d5 Mon Sep 17 00:00:00 2001 From: Yannick Bergeron Date: Fri, 8 Aug 2008 13:32:15 -0400 Subject: using NGROUPS_MAX instead of 32 for the max group value in rep_initgroups() subroutine in lib/replace/replace.c (cherry picked from commit 13b1a232d2fe05ae3e924ea2503d05ff5084146e) (This used to be commit 0d2fb0e280e497094a4c95f8dca1383ee1cfa982) --- source4/lib/replace/replace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 106c9dfe62..98d799b07e 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -170,7 +170,7 @@ int rep_initgroups(char *name, gid_t id) #include gid_t *grouplst = NULL; - int max_gr = 32; + int max_gr = NGROUPS_MAX; int ret; int i,j; struct group *g; -- cgit