[dovecot-cvs] dovecot/src/lib home-expand.c, 1.3, 1.4 home-expand.h, 1.2, 1.3
tss at dovecot.org
tss at dovecot.org
Fri Mar 23 02:06:45 EET 2007
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv21419
Modified Files:
home-expand.c home-expand.h
Log Message:
Added home_expand_tilde()
Index: home-expand.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/home-expand.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- home-expand.c 3 Jan 2007 22:38:27 -0000 1.3
+++ home-expand.c 23 Mar 2007 00:06:42 -0000 1.4
@@ -47,3 +47,17 @@
(void)home_try_expand(&path);
return path;
}
+
+const char *home_expand_tilde(const char *path, const char *home)
+{
+ if (path == NULL || *path != '~')
+ return path;
+
+ if (path[1] == '\0')
+ return home;
+ if (path[1] != '/')
+ return path;
+
+ /* ~/ used */
+ return t_strconcat(home, path + 1, NULL);
+}
Index: home-expand.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/home-expand.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- home-expand.h 3 Jan 2007 22:38:27 -0000 1.2
+++ home-expand.h 23 Mar 2007 00:06:42 -0000 1.3
@@ -6,5 +6,7 @@
const char *home_expand(const char *path);
/* Returns 0 if ok, -1 if user wasn't found. */
int home_try_expand(const char **path);
+/* Expand ~/ in the beginning of the path with the give home directory. */
+const char *home_expand_tilde(const char *path, const char *home);
#endif
More information about the dovecot-cvs
mailing list