Commit 734eac29 734eac29073067b1d4b23bae168b795f4361d3f0 by Sergey Poznyakoff

* include/mailutils/mutil.h, mailbox/mutil.c (mu_normalize_path):

Remove useless second argument.  All callers changed.
1 parent 0255df9a
2008-08-21 Sergey Poznyakoff <gray@gnu.org.ua>
* include/mailutils/mutil.h, mailbox/mutil.c (mu_normalize_path):
Remove useless second argument. All uses changed.
Rewrite IMAP namespace support.
* imap4d/imap4d.c (imap4d_cfg_param): other-namespace and
shared-namespace take proper lists as arguments.
......
......@@ -480,7 +480,7 @@ find_user (const char *name, char *tty)
sizeof (ftty) - sizeof (PATH_DEV) - 2);
ftty[sizeof (ftty) - 1] = 0;
mu_normalize_path (ftty, "/");
mu_normalize_path (ftty);
if (strncmp (ftty, PATH_TTY_PFX, strlen (PATH_TTY_PFX)))
{
/* An attempt to break security... */
......
......@@ -322,7 +322,7 @@ static struct mu_cfg_param imap4d_cfg_param[] = {
int
imap4d_session_setup0 ()
{
homedir = mu_normalize_path (strdup (auth_data->dir), "/");
homedir = mu_normalize_path (mu_strdup (auth_data->dir));
if (imap4d_check_home_dir (homedir, auth_data->uid, auth_data->gid))
return 1;
......
......@@ -79,7 +79,6 @@ _enum_fun (void *item, void *data)
static int
namespace_enumerate (int id, nsfp_t f, void *closure)
{
int i, rc;
struct ns_closure nsc;
nsc.id = id;
......@@ -238,7 +237,7 @@ namespace_init_session (char *path)
{
mu_list_create (&namespace[NS_PRIVATE]);
mu_list_append (namespace[NS_PRIVATE],
mu_strdup (mu_normalize_path (path, "/")));
mu_strdup (mu_normalize_path (path)));
return 0;
}
......@@ -248,7 +247,7 @@ normalize_fun (void *item, void *data)
char *name = item;
mu_list_t list = data;
return mu_list_append (list,
mu_strdup (mu_normalize_path (name, "/")));
mu_strdup (mu_normalize_path (name)));
}
static void
......
......@@ -47,7 +47,7 @@ util_getfullpath (char *name, const char *delim)
free (p);
p = s;
}
return mu_normalize_path (p, delim);
return mu_normalize_path (p);
}
static int
......
......@@ -96,7 +96,7 @@ extern int mu_get_user_email_domain (const char** domain);
*/
extern char *mu_get_user_email (const char *name);
extern char *mu_normalize_path (char *path, const char *delim);
extern char *mu_normalize_path (char *path);
extern int mu_tempfile (const char *tmpdir, char **namep);
extern char *mu_tempname (const char *tmpdir);
......
......@@ -495,10 +495,9 @@ mu_get_user_email (const char *name)
/home/user/../smith --> /home/smith
/home/user/../.. --> /
FIXME: delim is superfluous. The function deals with unix filesystem
paths, so delim should be always "/" */
*/
char *
mu_normalize_path (char *path, const char *delim)
mu_normalize_path (char *path)
{
int len;
char *p;
......@@ -513,21 +512,21 @@ mu_normalize_path (char *path, const char *delim)
return path;
/* delete trailing delimiter if any */
if (len && path[len-1] == delim[0])
if (len && path[len-1] == '/')
path[len-1] = 0;
/* Eliminate any /../ */
for (p = strchr (path, '.'); p; p = strchr (p, '.'))
{
if (p > path && p[-1] == delim[0])
if (p > path && p[-1] == '/')
{
if (p[1] == '.' && (p[2] == 0 || p[2] == delim[0]))
if (p[1] == '.' && (p[2] == 0 || p[2] == '/'))
/* found */
{
char *q, *s;
/* Find previous delimiter */
for (q = p-2; *q != delim[0] && q >= path; q--)
for (q = p-2; *q != '/' && q >= path; q--)
;
if (q < path)
......@@ -546,7 +545,7 @@ mu_normalize_path (char *path, const char *delim)
if (path[0] == 0)
{
path[0] = delim[0];
path[0] = '/';
path[1] = 0;
}
......