dovecot-2.0: Added t_abspath*().
dovecot at dovecot.org
dovecot at dovecot.org
Sat Dec 12 01:38:38 EET 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/395b53cebaac
changeset: 10458:395b53cebaac
user: Timo Sirainen <tss at iki.fi>
date: Fri Dec 11 18:36:19 2009 -0500
description:
Added t_abspath*().
diffstat:
3 files changed, 38 insertions(+)
src/lib/Makefile.am | 2 ++
src/lib/abspath.c | 26 ++++++++++++++++++++++++++
src/lib/abspath.h | 10 ++++++++++
diffs (63 lines):
diff -r c2386c4594d5 -r 395b53cebaac src/lib/Makefile.am
--- a/src/lib/Makefile.am Fri Dec 11 18:36:04 2009 -0500
+++ b/src/lib/Makefile.am Fri Dec 11 18:36:19 2009 -0500
@@ -9,6 +9,7 @@ EXTRA_DIST = unicodemap.c unicodemap.pl
perl $(srcdir)/unicodemap.pl < UnicodeData.txt > $@
liblib_la_SOURCES = \
+ abspath.c \
array.c \
aqueue.c \
askpass.c \
@@ -113,6 +114,7 @@ liblib_la_SOURCES = \
write-full.c
headers = \
+ abspath.h \
aqueue.h \
array.h \
array-decl.h \
diff -r c2386c4594d5 -r 395b53cebaac src/lib/abspath.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib/abspath.c Fri Dec 11 18:36:19 2009 -0500
@@ -0,0 +1,26 @@
+/* Copyright (c) 2009 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "abspath.h"
+
+#include <unistd.h>
+
+const char *t_abspath(const char *path)
+{
+ char dir[PATH_MAX];
+
+ if (*path == '/')
+ return path;
+
+ if (getcwd(dir, sizeof(dir)) == NULL)
+ i_fatal("getcwd() failed: %m");
+ return t_strconcat(dir, "/", path, NULL);
+}
+
+const char *t_abspath_to(const char *path, const char *root)
+{
+ if (*path == '/')
+ return path;
+
+ return t_strconcat(root, "/", path, NULL);
+}
diff -r c2386c4594d5 -r 395b53cebaac src/lib/abspath.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib/abspath.h Fri Dec 11 18:36:19 2009 -0500
@@ -0,0 +1,10 @@
+#ifndef ABSPATH_H
+#define ABSPATH_H
+
+/* Returns path as absolute path. If it's not already absolute path,
+ it's assumed to be relative to current working directory. */
+const char *t_abspath(const char *path);
+/* Like t_abspath(), but path is relative to given root. */
+const char *t_abspath_to(const char *path, const char *root);
+
+#endif
More information about the dovecot-cvs
mailing list