full support for absolute paths in Mailboxes
This commit is contained in:
parent
7ff8eef06c
commit
789d5864ca
|
@ -29,6 +29,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static int local_home, local_root;
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
my_strndup( const char *s, size_t nchars )
|
my_strndup( const char *s, size_t nchars )
|
||||||
{
|
{
|
||||||
|
@ -119,13 +121,16 @@ load_config( const char *path, config_t ***stor )
|
||||||
cfg = **stor = nfmalloc( sizeof(config_t) );
|
cfg = **stor = nfmalloc( sizeof(config_t) );
|
||||||
*stor = &cfg->next;
|
*stor = &cfg->next;
|
||||||
memcpy( cfg, &global, sizeof(config_t) );
|
memcpy( cfg, &global, sizeof(config_t) );
|
||||||
if (val[0] == '~' && val[1] == '/')
|
if (val[0] == '~' && val[1] == '/') {
|
||||||
val += 2;
|
val += 2;
|
||||||
else {
|
local_home = 1;
|
||||||
int l = strlen( Home );
|
} else if (!memcmp( val, Home, HomeLen ) && val[HomeLen] == '/') {
|
||||||
if (!memcmp( val, Home, l ) && val[l] == '/')
|
val += HomeLen + 1;
|
||||||
val += l + 1;
|
local_home = 1;
|
||||||
}
|
} else if (val[0] == '/')
|
||||||
|
local_root = 1;
|
||||||
|
else
|
||||||
|
local_home = 1;
|
||||||
/* not expanded at this point */
|
/* not expanded at this point */
|
||||||
cfg->path = nfstrdup( val );
|
cfg->path = nfstrdup( val );
|
||||||
} else if (!strcasecmp( "OneToOne", cmd )) {
|
} else if (!strcasecmp( "OneToOne", cmd )) {
|
||||||
|
@ -343,7 +348,11 @@ write_config( int fd )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( fp, "SyncState *\n\nMaildirStore local\nPath \"%s/\"\nAltMap %s\n\n", maildir, tb( altmap > 0 ) );
|
fprintf( fp, "SyncState *\n\n" );
|
||||||
|
if (local_home || o2o)
|
||||||
|
fprintf( fp, "MaildirStore local\nPath \"%s/\"\nAltMap %s\n\n", maildir, tb( altmap > 0 ) );
|
||||||
|
if (local_root)
|
||||||
|
fprintf( fp, "MaildirStore local_root\nPath /\nAltMap %s\n\n", tb( altmap > 0 ) );
|
||||||
if (o2o) {
|
if (o2o) {
|
||||||
write_imap_server( fp, &global );
|
write_imap_server( fp, &global );
|
||||||
write_imap_store( fp, &global );
|
write_imap_store( fp, &global );
|
||||||
|
@ -417,6 +426,10 @@ write_config( int fd )
|
||||||
box->channels = 1;
|
box->channels = 1;
|
||||||
box->channel_name = cn;
|
box->channel_name = cn;
|
||||||
gotchan:
|
gotchan:
|
||||||
|
if (box->path[0] == '/')
|
||||||
|
fprintf( fp, "Channel %s\nMaster :%s:%s\nSlave :local_root:%s\n",
|
||||||
|
box->channel_name, box->store_name, box->box, box->path + 1 );
|
||||||
|
else
|
||||||
fprintf( fp, "Channel %s\nMaster :%s:%s\nSlave :local:%s\n",
|
fprintf( fp, "Channel %s\nMaster :%s:%s\nSlave :local:%s\n",
|
||||||
box->channel_name, box->store_name, box->box, box->path );
|
box->channel_name, box->store_name, box->box, box->path );
|
||||||
write_channel_parm( fp, box );
|
write_channel_parm( fp, box );
|
||||||
|
@ -433,6 +446,8 @@ find_box( const char *s )
|
||||||
config_t *p;
|
config_t *p;
|
||||||
char *t;
|
char *t;
|
||||||
|
|
||||||
|
if (!memcmp( s, Home, HomeLen ) && s[HomeLen] == '/')
|
||||||
|
s += HomeLen + 1;
|
||||||
for (p = boxes; p; p = p->next) {
|
for (p = boxes; p; p = p->next) {
|
||||||
if (!strcmp( s, p->path ) || (p->alias && !strcmp( s, p->alias )))
|
if (!strcmp( s, p->path ) || (p->alias && !strcmp( s, p->alias )))
|
||||||
return p;
|
return p;
|
||||||
|
|
|
@ -74,6 +74,7 @@ typedef struct config {
|
||||||
extern int Quiet, Verbose, Debug;
|
extern int Quiet, Verbose, Debug;
|
||||||
|
|
||||||
extern const char *Home;
|
extern const char *Home;
|
||||||
|
extern int HomeLen;
|
||||||
|
|
||||||
extern config_t global, *boxes;
|
extern config_t global, *boxes;
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,7 @@ const char *maildir, *xmaildir, *folder, *inbox;
|
||||||
int o2o, altmap, delete, expunge;
|
int o2o, altmap, delete, expunge;
|
||||||
|
|
||||||
const char *Home;
|
const char *Home;
|
||||||
|
int HomeLen;
|
||||||
|
|
||||||
int
|
int
|
||||||
main( int argc, char **argv )
|
main( int argc, char **argv )
|
||||||
|
@ -162,6 +163,7 @@ main( int argc, char **argv )
|
||||||
fputs( "Fatal: $HOME not set\n", stderr );
|
fputs( "Fatal: $HOME not set\n", stderr );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
HomeLen = strlen( Home );
|
||||||
|
|
||||||
/* defaults */
|
/* defaults */
|
||||||
/* XXX the precedence is borked:
|
/* XXX the precedence is borked:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user