diff --git a/src/utils/os.c b/src/utils/os.c
index e975f96e743b6510102426d6450dbe9270690e1c..8ab52c75bc023c2bc5b68ca61d2cc0f13ce0f916 100644 (file)
--- a/src/utils/os.c
+++ b/src/utils/os.c
#include <errno.h>
#include <sys/types.h>
+#include <sys/select.h>
#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
#include <dirent.h>
#include <libgen.h>
#include <netdb.h>
#include <pwd.h>
+#include <time.h>
/*
* public API
return strdup(result->pw_dir);
} /* sdb_get_homedir */
+char *
+sdb_realpath(const char *path)
+{
+ if (! path)
+ return NULL;
+
+ if ((strlen(path) >= 2) && (path[0] == '~') && (path[1] == '/')) {
+ char *homedir = sdb_get_homedir();
+ char tmp[(homedir ? strlen(homedir) : 0) + strlen(path)];
+ char *ret;
+
+ if (! homedir)
+ return NULL;
+
+ snprintf(tmp, sizeof(tmp), "%s/%s", homedir, path + 2);
+ ret = realpath(tmp, NULL);
+ free(homedir);
+ return ret;
+ }
+
+ return realpath(path, NULL);
+} /* sdb_realpath */
+
int
sdb_mkdir_all(const char *pathname, mode_t mode)
{
if (address) {
host = address;
- port = strchr(host, ':');
+ port = strrchr(host, ':');
if (port) {
*port = '\0';
++port;