Commit 8b40ce89 8b40ce8956e22a135ffb3336f2cb6b60dd8fd111 by Sergey Poznyakoff

(make_progfile_name): moved to mailbox/mutil.c:mu_expand_path_pattern

1 parent 96a185d6
......@@ -240,80 +240,6 @@ main (int argc, char *argv[])
return exit_code;
}
char *
make_progfile_name (char *pattern, char *username)
{
char *homedir = NULL;
char *p, *q, *startp;
char *progfile;
int len = 0;
for (p = pattern; *p; p++)
{
if (*p == '%')
switch (*++p)
{
case 'u':
len += strlen (username);
break;
case 'h':
if (!homedir)
{
struct passwd *pwd = mu_getpwnam (username);
if (!pwd)
return NULL;
homedir = pwd->pw_dir;
}
len += strlen (homedir);
break;
case '%':
len++;
break;
default:
len += 2;
}
else
len++;
}
progfile = malloc (len + 1);
if (!progfile)
return NULL;
startp = pattern;
q = progfile;
while (*startp && (p = strchr (startp, '%')) != NULL)
{
memcpy (q, startp, p - startp);
q += p - startp;
switch (*++p)
{
case 'u':
strcpy (q, username);
q += strlen (username);
break;
case 'h':
strcpy (q, homedir);
q += strlen (homedir);
break;
case '%':
*q++ = '%';
break;
default:
*q++ = '%';
*q++ = *p;
}
startp = p + 1;
}
if (*startp)
{
strcpy (q, startp);
q += strlen (startp);
}
*q = 0;
return progfile;
}
int
mda (FILE *fp, char *username)
{
......