]> granicus.if.org Git - pgbouncer/commitdiff
detect basename() function, include small compat func if missing
authorMarko Kreen <markokr@gmail.com>
Tue, 4 Mar 2008 11:55:55 +0000 (11:55 +0000)
committerMarko Kreen <markokr@gmail.com>
Tue, 4 Mar 2008 11:55:55 +0000 (11:55 +0000)
configure.ac
include/system.h
src/system.c

index 6036a8f2d9b794a9dc84d8ebba07013770639f85..f7478603e73e91985813e0fd98f573caee054856 100644 (file)
@@ -66,7 +66,7 @@ if test x"$GCC" = xyes; then
 fi
 
 dnl Checks for header files.
-AC_CHECK_HEADERS([crypt.h sys/param.h sys/socket.h])
+AC_CHECK_HEADERS([crypt.h sys/param.h sys/socket.h libgen.h])
 dnl ucred.h may have prereqs
 AC_CHECK_HEADERS([sys/ucred.h], [], [], [
 #ifdef HAVE_SYS_TYPES_H
@@ -92,7 +92,7 @@ AC_TYPE_UINT64_T
 ])
 
 dnl Checks for library functions.
-AC_CHECK_FUNCS(strlcpy strlcat getpeereid getpeerucred)
+AC_CHECK_FUNCS(strlcpy strlcat getpeereid getpeerucred basename)
 AC_SEARCH_LIBS(crypt, crypt, [], AC_MSG_ERROR([crypt not found]))
 AC_SEARCH_LIBS(clock_gettime, rt)
 
index 256430236cbb1615a0e992b9cd4b8266623b1e4b..48e45e7f8699800e9139df404db3cc97c848b3fb 100644 (file)
@@ -53,6 +53,9 @@
 #ifdef HAVE_CRYPT_H
 #include <crypt.h>
 #endif
+#ifdef HAVE_LIBGEN_H
+#include <libgen.h>
+#endif
 
 /* how to specify array with unknown length */
 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
@@ -137,6 +140,9 @@ size_t strlcat(char *dst, const char *src, size_t n) _MUSTCHECK;
 #ifndef HAVE_GETPEEREID
 int getpeereid(int fd, uid_t *uid_p, gid_t *gid_p) _MUSTCHECK;
 #endif
+#ifndef HAVE_BASENAME
+const char *basename(const char *path);
+#endif
 
 /*
  * memcpy() optimization - improves hash.c.
index 4dc1868ce53793718295e62da6d26a609e407ec4..51070019744d5564f230b850bf9717c6afd16c27 100644 (file)
@@ -89,3 +89,15 @@ int getpeereid(int fd, uid_t *uid_p, gid_t *gid_p)
 }
 #endif /* !HAVE_GETPEEREID */
 
+#ifndef HAVE_BASENAME
+const char *basename(const char *path)
+{
+       const char *p;
+       if (path == NULL || path[0] == 0)
+               return ".";
+       if ((p = strrchr(path, '/')) != NULL)
+               return p[1] ? p + 1 : p;
+       return path;
+}
+#endif
+