[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cmu-sieve: starting to work, patch about paths.
From: |
Sergey Poznyakoff |
Subject: |
Re: cmu-sieve: starting to work, patch about paths. |
Date: |
Thu, 10 May 2001 17:54:43 +0300 |
> url_path.c: Expand ~/box to /home/user/box, ~foo/box to /home/foo/box,
> and +box or =box to /home/user/Mail/box. It tries to be smart about
> finding where /home is, or at least not too dumb, and it just assumes
> that your mailboxes are in ~/Mail, I don't know if there's some kind
> of standard environment variable for that.
You can use password database for that. The home_dir() would look like:
static char* home_dir(const char* name)
{
char* home = strdup(getenv("HOME") ? getenv("HOME") : "/home");
if(!home)
{
struct passwd *pw = getpwnam(name);
if (!pw)
return NULL;
home = pw->pw_dir;
}
/* strip trailing '/' */
if(home[strlen(home) - 1] == '/')
home[strlen(home) - 1] = 0;
if(name[1] != '/')
{
/* it's not our home, pull home back to the parent dir. */
char* p = strrchr(home, '/');
if(p == home)
{
/* home was "/dir", so use /home */
free(home);
return strdup("/home/");
}
p[1] = 0;
return home;
}
/* else it is our home */
return home;
}
Regards,
Sergey
- cmu-sieve: starting to work, patch about paths., Sam Roberts, 2001/05/10
- Re: cmu-sieve: starting to work, patch about paths., Alain Magloire, 2001/05/10
- Re: cmu-sieve: starting to work, patch about paths., Sergey Poznyakoff, 2001/05/10
- Re: cmu-sieve: starting to work, patch about paths.,
Sergey Poznyakoff <=
- Re: cmu-sieve: starting to work, patch about paths., Sam Roberts, 2001/05/11
- Re: cmu-sieve: starting to work, patch about paths., Alain Magloire, 2001/05/19
- sys_siglist compatibility., Sergey Poznyakoff, 2001/05/21
- Re: sys_siglist compatibility., Alain Magloire, 2001/05/22
- Re: sys_siglist compatibility., Jeff Bailey, 2001/05/22
- Re: sys_siglist compatibility., Alain Magloire, 2001/05/22
- Message not available
- Re: sys_siglist compatibility., Jeff Bailey, 2001/05/22
- Message not available
- Re: cmu-sieve: starting to work, patch about paths., Sam Roberts, 2001/05/27
- Re: cmu-sieve: starting to work, patch about paths., Alain Magloire, 2001/05/28
- Re: cmu-sieve: starting to work, patch about paths., Sam Roberts, 2001/05/29