From f3c738f8193665a80835471f6754a66b20725afa Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 5 Mar 2010 22:45:27 +1100 Subject: replace: added get_current_dir_name() --- lib/replace/libreplace.m4 | 1 + lib/replace/replace.c | 12 ++++++++++++ lib/replace/replace.h | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4 index c8cd213b83..8b7a56ecb7 100644 --- a/lib/replace/libreplace.m4 +++ b/lib/replace/libreplace.m4 @@ -109,6 +109,7 @@ AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid wait4 strlcpy strlcat initgroups memmove strdup) AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp dup2 dprintf vdprintf) AC_CHECK_FUNCS(isatty chown lchown link readlink symlink realpath fdatasync) +AC_CHECK_FUNCS(get_current_dir_name) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) diff --git a/lib/replace/replace.c b/lib/replace/replace.c index 8eba98acf4..f2dcb10ddc 100644 --- a/lib/replace/replace.c +++ b/lib/replace/replace.c @@ -735,3 +735,15 @@ int dprintf(int fd, const char *format, ...) } #endif +#ifndef HAVE_GET_CURRENT_DIR_NAME +char *rep_get_current_dir_name(void) +{ + char buf[PATH_MAX+1]; + char *p; + p = getcwd(buf, sizeof(buf)); + if (p == NULL) { + return NULL; + } + return strdup(p); +} +#endif diff --git a/lib/replace/replace.h b/lib/replace/replace.h index a4ef231385..e7578cd60f 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -497,6 +497,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_GET_CURRENT_DIR_NAME +#define get_current_dir_name rep_get_current_dir_name +char *rep_get_current_dir_name(void); +#endif + #ifdef HAVE_LIMITS_H #include #endif -- cgit