Browse Source

full support for absolute paths in Mailboxes

wip/ssl-fprint
Oswald Buddenhagen 21 years ago
parent
commit
789d5864ca
  1. 29
      src/compat/config.c
  2. 1
      src/compat/isync.h
  3. 2
      src/compat/main.c

29
src/compat/config.c

@ -29,6 +29,8 @@
#include <stdlib.h>
#include <stdio.h>
static int local_home, local_root;
static char *
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) );
*stor = &cfg->next;
memcpy( cfg, &global, sizeof(config_t) );
if (val[0] == '~' && val[1] == '/')
if (val[0] == '~' && val[1] == '/') {
val += 2;
else {
int l = strlen( Home );
if (!memcmp( val, Home, l ) && val[l] == '/')
val += l + 1;
}
local_home = 1;
} else if (!memcmp( val, Home, HomeLen ) && val[HomeLen] == '/') {
val += HomeLen + 1;
local_home = 1;
} else if (val[0] == '/')
local_root = 1;
else
local_home = 1;
/* not expanded at this point */
cfg->path = nfstrdup( val );
} else if (!strcasecmp( "OneToOne", cmd )) {
@ -343,7 +348,11 @@ write_config( int fd )
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) {
write_imap_server( fp, &global );
write_imap_store( fp, &global );
@ -417,6 +426,10 @@ write_config( int fd )
box->channels = 1;
box->channel_name = cn;
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",
box->channel_name, box->store_name, box->box, box->path );
write_channel_parm( fp, box );
@ -433,6 +446,8 @@ find_box( const char *s )
config_t *p;
char *t;
if (!memcmp( s, Home, HomeLen ) && s[HomeLen] == '/')
s += HomeLen + 1;
for (p = boxes; p; p = p->next) {
if (!strcmp( s, p->path ) || (p->alias && !strcmp( s, p->alias )))
return p;

1
src/compat/isync.h

@ -74,6 +74,7 @@ typedef struct config {
extern int Quiet, Verbose, Debug;
extern const char *Home;
extern int HomeLen;
extern config_t global, *boxes;

2
src/compat/main.c

@ -148,6 +148,7 @@ const char *maildir, *xmaildir, *folder, *inbox;
int o2o, altmap, delete, expunge;
const char *Home;
int HomeLen;
int
main( int argc, char **argv )
@ -162,6 +163,7 @@ main( int argc, char **argv )
fputs( "Fatal: $HOME not set\n", stderr );
return 1;
}
HomeLen = strlen( Home );
/* defaults */
/* XXX the precedence is borked:

Loading…
Cancel
Save