isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 789d5864ca66578c1021be3f4854bf38528e1989
parent 7ff8eef06c0796fb0b9ac2f9d9720683640e0191
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Mon, 26 Apr 2004 14:48:48 +0000

full support for absolute paths in Mailboxes

Diffstat:
Msrc/compat/config.c | 33++++++++++++++++++++++++---------
Msrc/compat/isync.h | 1+
Msrc/compat/main.c | 2++
3 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/src/compat/config.c b/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,8 +426,12 @@ write_config( int fd ) box->channels = 1; box->channel_name = cn; gotchan: - fprintf( fp, "Channel %s\nMaster :%s:%s\nSlave :local:%s\n", - box->channel_name, box->store_name, box->box, box->path ); + 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; diff --git a/src/compat/isync.h b/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; diff --git a/src/compat/main.c b/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: