diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-03-05 22:45:27 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-03-05 23:07:32 +1100 |
commit | f3c738f8193665a80835471f6754a66b20725afa (patch) | |
tree | 75342ddb7379f317a72d46a4e9f19894ff89f0d6 /lib/replace | |
parent | ace6d75ae6f953b76fa9709857af4744020cd6fb (diff) | |
download | samba-f3c738f8193665a80835471f6754a66b20725afa.tar.gz samba-f3c738f8193665a80835471f6754a66b20725afa.tar.bz2 samba-f3c738f8193665a80835471f6754a66b20725afa.zip |
replace: added get_current_dir_name()
Diffstat (limited to 'lib/replace')
-rw-r--r-- | lib/replace/libreplace.m4 | 1 | ||||
-rw-r--r-- | lib/replace/replace.c | 12 | ||||
-rw-r--r-- | lib/replace/replace.h | 5 |
3 files changed, 18 insertions, 0 deletions
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 <unistd.h>]) AC_HAVE_DECL(setresgid, [#include <unistd.h>]) AC_HAVE_DECL(errno, [#include <errno.h>]) 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 <limits.h> #endif |