[dovecot-cvs] dovecot/src/lib home-expand.c, 1.2.2.1, 1.2.2.2 home-expand.h, 1.1.2.1, 1.1.2.2

tss at dovecot.org tss at dovecot.org
Fri Mar 23 02:06:41 EET 2007


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv21424

Modified Files:
      Tag: branch_1_0
	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.2.2.1
retrieving revision 1.2.2.2
diff -u -d -r1.2.2.1 -r1.2.2.2
--- home-expand.c	3 Jan 2007 22:38:25 -0000	1.2.2.1
+++ home-expand.c	23 Mar 2007 00:06:39 -0000	1.2.2.2
@@ -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.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- home-expand.h	3 Jan 2007 22:38:25 -0000	1.1.2.1
+++ home-expand.h	23 Mar 2007 00:06:39 -0000	1.1.2.2
@@ -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