diff options
-rw-r--r-- | common/compat.c | 62 | ||||
-rw-r--r-- | common/compat.h | 6 | ||||
-rw-r--r-- | configure.ac | 5 |
3 files changed, 71 insertions, 2 deletions
diff --git a/common/compat.c b/common/compat.c index 59aaa00..33e608f 100644 --- a/common/compat.c +++ b/common/compat.c @@ -41,6 +41,42 @@ #include <stdlib.h> #include <string.h> +/*- + * Portions of this file are covered by the following copyright: + * + * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org> + * Copyright (c) 1990, 1993 + * Copyright (c) 1987, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * 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. + * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. + */ + #ifndef HAVE_GETPROGNAME #ifdef OS_UNIX @@ -112,6 +148,32 @@ getprogname (void) #endif /* HAVE_GETPROGNAME */ +#ifndef HAVE_BASENAME + +char * +basename (const char *name) +{ + char *p; +#ifdef OS_WIN32 + char *p2; +#endif + + if (!name || name[0] == '\0') + return "."; + + p = strrchr (name, '/'); +#ifdef OS_WIN32 + p2 = strrchr (name, '\\'); + if (p2 > p) + p = p2; +#endif + if (p != NULL) + return p + 1; + return (char *)name; +} + +#endif /* HAVE_BASENAME */ + #ifdef OS_UNIX void diff --git a/common/compat.h b/common/compat.h index 48d97b3..1b74a35 100644 --- a/common/compat.h +++ b/common/compat.h @@ -68,6 +68,12 @@ const char * getprogname (void); #endif +#ifndef HAVE_BASENAME + +char * basename (const char *name); + +#endif /* HAVE_BASENAME */ + /* ----------------------------------------------------------------------------- * WIN32 */ diff --git a/configure.ac b/configure.ac index e843dfa..ef6f06f 100644 --- a/configure.ac +++ b/configure.ac @@ -72,9 +72,10 @@ if test "$os_unix" = "yes"; then [AC_MSG_ERROR([could not find dlopen])]) AC_SEARCH_LIBS([nanosleep], [rt], [], [AC_MSG_ERROR([could not find nanosleep])]) + + # These are thngs we can work around AC_CHECK_MEMBERS([struct dirent.d_type],,,[#include <dirent.h>]) - AC_CHECK_FUNCS([getprogname getexecname memdup]) - AC_CHECK_FUNCS([getprogname getexecname strnstr memdup]) + AC_CHECK_FUNCS([getprogname getexecname basename mkstemp mkdtemp]) # Check if these are declared and/or available to link against AC_CHECK_DECLS([program_invocation_short_name]) |