2004-03-27 16:07:20 +00:00
|
|
|
/*
|
|
|
|
* mbsync - mailbox synchronizer
|
2002-12-28 15:31:20 +00:00
|
|
|
* Copyright (C) 2000-2002 Michael R. Elkins <me@mutt.org>
|
2017-03-19 17:08:55 +00:00
|
|
|
* Copyright (C) 2002-2006,2010-2017 Oswald Buddenhagen <ossi@users.sf.net>
|
2000-12-20 21:41:21 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2011-04-10 17:34:36 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2002-10-30 02:31:20 +00:00
|
|
|
*
|
2004-03-27 16:07:20 +00:00
|
|
|
* As a special exception, mbsync may be linked with the OpenSSL library,
|
2002-10-30 02:31:20 +00:00
|
|
|
* despite that library's more restrictive license.
|
2000-12-20 21:41:21 +00:00
|
|
|
*/
|
|
|
|
|
2013-12-08 19:46:40 +00:00
|
|
|
#include "sync.h"
|
2003-05-07 00:06:37 +00:00
|
|
|
|
2000-12-20 21:41:21 +00:00
|
|
|
#include <stdlib.h>
|
2006-03-21 20:03:21 +00:00
|
|
|
#include <stddef.h>
|
2000-12-20 21:41:21 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
2006-02-02 13:48:02 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <signal.h>
|
2013-11-09 13:35:07 +00:00
|
|
|
#include <time.h>
|
2006-02-02 13:48:02 +00:00
|
|
|
#include <sys/wait.h>
|
2019-12-03 12:00:19 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
# include <sys/prctl.h>
|
|
|
|
#endif
|
Bunch 'o patches from Oswald Buddenhagen:
i implemented some cool stuff (tm).
first, the long missing "create server-side missing mailboxes". -C now
creates both local and remote boxes; -L and -R create only local/remote.
second, i implemented a 1:1 remote:local folder mapping (-1) with an
optional INBOX exception (inbox/-I). the remote folder is specified with
the folder keyword (or -F switch) and takes precedence over the
namespace setting. the local directory with the mailboxes can now be
specified on the command line, too (-M).
another patch:
- made the -1 switch settable permanently (OneToOne). after all, you
usually define your mailbox layout once forever. removed -A, as it is
semantically -a modified by -1.
- cleaned up message output a bit. still, the quiet variable should be
used throughout the program. at best, create some generic output
function, which obeys a global verbosity level variable.
- optimized + cleaned up configuration parser slightly
- minor cleanups
add an (almost) unique id to every uploaded message and search for it
right after. i thought about using the message-id, but a) it is not
guaranteed to be unique in a mailbox (imagine you edit a mail and store
the dupe in the same box) and b) some mails (e.g., postponed) don't even
have one. a downside of the current implementation is, that this
id-header remains in the mailbox, but given that it wastes only 27 bytes
per mail and removing it would mean several roundtrips more, this seems
acceptable.
i changed the line-counting loop to use a mmapped file instead of
reading it in chunks, as it makes things simpler and is probably even
faster for big mails.
the amount of goto statements in my code may be scary, but c is simply
lacking a multi-level break statement. :)
this is the "shut up" patch. :) it makes the -q option consequent, so to
say.
additionally it adds an -l option which gathers all defined/found
mailboxes and just outputs the list. don't ask what i need it for. ;)
2002-10-30 02:23:05 +00:00
|
|
|
|
2013-12-08 19:46:40 +00:00
|
|
|
int DFlags;
|
2017-03-19 10:53:16 +00:00
|
|
|
int JLimit;
|
2013-12-08 19:46:40 +00:00
|
|
|
int UseFSync = 1;
|
2014-10-25 15:30:57 +00:00
|
|
|
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__CYGWIN__)
|
|
|
|
char FieldDelimiter = ';';
|
|
|
|
#else
|
|
|
|
char FieldDelimiter = ':';
|
|
|
|
#endif
|
2013-12-08 19:46:40 +00:00
|
|
|
|
2004-03-27 16:07:20 +00:00
|
|
|
int Pid; /* for maildir and imap */
|
|
|
|
char Hostname[256]; /* for maildir */
|
|
|
|
const char *Home; /* for config */
|
2000-12-20 21:41:21 +00:00
|
|
|
|
2020-07-08 15:27:37 +00:00
|
|
|
uint BufferLimit = 10 * 1024 * 1024;
|
2015-02-15 17:13:05 +00:00
|
|
|
|
2019-07-28 18:54:01 +00:00
|
|
|
static int chans_total, chans_done;
|
|
|
|
static int boxes_total, boxes_done;
|
2015-03-28 16:26:08 +00:00
|
|
|
int new_total[2], new_done[2];
|
|
|
|
int flags_total[2], flags_done[2];
|
|
|
|
int trash_total[2], trash_done[2];
|
|
|
|
|
2017-10-01 08:04:00 +00:00
|
|
|
static void ATTR_NORETURN
|
2004-03-27 16:07:20 +00:00
|
|
|
version( void )
|
2000-12-20 21:41:21 +00:00
|
|
|
{
|
2004-03-27 16:07:20 +00:00
|
|
|
puts( PACKAGE " " VERSION );
|
|
|
|
exit( 0 );
|
2000-12-20 21:41:21 +00:00
|
|
|
}
|
|
|
|
|
2017-10-01 08:04:00 +00:00
|
|
|
static void ATTR_NORETURN
|
2004-03-27 16:07:20 +00:00
|
|
|
usage( int code )
|
2000-12-20 21:41:21 +00:00
|
|
|
{
|
2004-03-27 16:07:20 +00:00
|
|
|
fputs(
|
|
|
|
PACKAGE " " VERSION " - mailbox synchronizer\n"
|
2003-05-05 13:24:03 +00:00
|
|
|
"Copyright (C) 2000-2002 Michael R. Elkins <me@mutt.org>\n"
|
2017-03-19 17:08:55 +00:00
|
|
|
"Copyright (C) 2002-2006,2008,2010-2017 Oswald Buddenhagen <ossi@users.sf.net>\n"
|
2004-03-27 16:07:20 +00:00
|
|
|
"Copyright (C) 2004 Theodore Ts'o <tytso@mit.edu>\n"
|
Bunch 'o patches from Oswald Buddenhagen:
i implemented some cool stuff (tm).
first, the long missing "create server-side missing mailboxes". -C now
creates both local and remote boxes; -L and -R create only local/remote.
second, i implemented a 1:1 remote:local folder mapping (-1) with an
optional INBOX exception (inbox/-I). the remote folder is specified with
the folder keyword (or -F switch) and takes precedence over the
namespace setting. the local directory with the mailboxes can now be
specified on the command line, too (-M).
another patch:
- made the -1 switch settable permanently (OneToOne). after all, you
usually define your mailbox layout once forever. removed -A, as it is
semantically -a modified by -1.
- cleaned up message output a bit. still, the quiet variable should be
used throughout the program. at best, create some generic output
function, which obeys a global verbosity level variable.
- optimized + cleaned up configuration parser slightly
- minor cleanups
add an (almost) unique id to every uploaded message and search for it
right after. i thought about using the message-id, but a) it is not
guaranteed to be unique in a mailbox (imagine you edit a mail and store
the dupe in the same box) and b) some mails (e.g., postponed) don't even
have one. a downside of the current implementation is, that this
id-header remains in the mailbox, but given that it wastes only 27 bytes
per mail and removing it would mean several roundtrips more, this seems
acceptable.
i changed the line-counting loop to use a mmapped file instead of
reading it in chunks, as it makes things simpler and is probably even
faster for big mails.
the amount of goto statements in my code may be scary, but c is simply
lacking a multi-level break statement. :)
this is the "shut up" patch. :) it makes the -q option consequent, so to
say.
additionally it adds an -l option which gathers all defined/found
mailboxes and just outputs the list. don't ask what i need it for. ;)
2002-10-30 02:23:05 +00:00
|
|
|
"usage:\n"
|
2004-03-27 16:07:20 +00:00
|
|
|
" " EXE " [flags] {{channel[:box,...]|group} ...|-a}\n"
|
|
|
|
" -a, --all operate on all defined channels\n"
|
|
|
|
" -l, --list list mailboxes instead of syncing them\n"
|
|
|
|
" -n, --new propagate new messages\n"
|
|
|
|
" -d, --delete propagate message deletions\n"
|
|
|
|
" -f, --flags propagate message flag changes\n"
|
|
|
|
" -N, --renew propagate previously not propagated new messages\n"
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
" -L, --pull propagate from far to near side\n"
|
|
|
|
" -H, --push propagate from near to far side\n"
|
2020-07-01 16:25:45 +00:00
|
|
|
" -C, --create propagate creations of mailboxes\n"
|
|
|
|
" -R, --remove propagate deletions of mailboxes\n"
|
2004-03-27 16:07:20 +00:00
|
|
|
" -X, --expunge expunge deleted messages\n"
|
|
|
|
" -c, --config CONFIG read an alternate config file (default: ~/." EXE "rc)\n"
|
2015-03-23 07:42:51 +00:00
|
|
|
" -D, --debug debugging modes (see manual)\n"
|
|
|
|
" -V, --verbose display what is happening\n"
|
|
|
|
" -q, --quiet don't display progress counters\n"
|
Bunch 'o patches from Oswald Buddenhagen:
i implemented some cool stuff (tm).
first, the long missing "create server-side missing mailboxes". -C now
creates both local and remote boxes; -L and -R create only local/remote.
second, i implemented a 1:1 remote:local folder mapping (-1) with an
optional INBOX exception (inbox/-I). the remote folder is specified with
the folder keyword (or -F switch) and takes precedence over the
namespace setting. the local directory with the mailboxes can now be
specified on the command line, too (-M).
another patch:
- made the -1 switch settable permanently (OneToOne). after all, you
usually define your mailbox layout once forever. removed -A, as it is
semantically -a modified by -1.
- cleaned up message output a bit. still, the quiet variable should be
used throughout the program. at best, create some generic output
function, which obeys a global verbosity level variable.
- optimized + cleaned up configuration parser slightly
- minor cleanups
add an (almost) unique id to every uploaded message and search for it
right after. i thought about using the message-id, but a) it is not
guaranteed to be unique in a mailbox (imagine you edit a mail and store
the dupe in the same box) and b) some mails (e.g., postponed) don't even
have one. a downside of the current implementation is, that this
id-header remains in the mailbox, but given that it wastes only 27 bytes
per mail and removing it would mean several roundtrips more, this seems
acceptable.
i changed the line-counting loop to use a mmapped file instead of
reading it in chunks, as it makes things simpler and is probably even
faster for big mails.
the amount of goto statements in my code may be scary, but c is simply
lacking a multi-level break statement. :)
this is the "shut up" patch. :) it makes the -q option consequent, so to
say.
additionally it adds an -l option which gathers all defined/found
mailboxes and just outputs the list. don't ask what i need it for. ;)
2002-10-30 02:23:05 +00:00
|
|
|
" -v, --version display version\n"
|
|
|
|
" -h, --help display this help message\n"
|
2004-03-27 16:07:20 +00:00
|
|
|
"\nIf neither --pull nor --push are specified, both are active.\n"
|
|
|
|
"If neither --new, --delete, --flags nor --renew are specified, all are active.\n"
|
|
|
|
"Direction and operation can be concatenated like --pull-new, etc.\n"
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
"--create, --remove, and --expunge can be suffixed with -far/-near.\n"
|
2020-07-01 16:25:45 +00:00
|
|
|
"See the man page for details.\n"
|
2004-03-27 16:07:20 +00:00
|
|
|
"\nSupported mailbox formats are: IMAP4rev1, Maildir\n"
|
|
|
|
"\nCompile time options:\n"
|
2011-03-27 10:06:41 +00:00
|
|
|
#ifdef HAVE_LIBSSL
|
2017-03-19 17:08:55 +00:00
|
|
|
" +HAVE_LIBSSL"
|
2001-10-03 06:15:01 +00:00
|
|
|
#else
|
2017-03-19 17:08:55 +00:00
|
|
|
" -HAVE_LIBSSL"
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_LIBSASL
|
|
|
|
" +HAVE_LIBSASL"
|
|
|
|
#else
|
|
|
|
" -HAVE_LIBSASL"
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_LIBZ
|
|
|
|
" +HAVE_LIBZ"
|
|
|
|
#else
|
|
|
|
" -HAVE_LIBZ"
|
|
|
|
#endif
|
|
|
|
#ifdef USE_DB
|
|
|
|
" +USE_DB"
|
|
|
|
#else
|
|
|
|
" -USE_DB"
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
" +HAVE_IPV6\n"
|
|
|
|
#else
|
|
|
|
" -HAVE_IPV6\n"
|
2001-10-03 06:15:01 +00:00
|
|
|
#endif
|
2004-03-27 16:07:20 +00:00
|
|
|
, code ? stderr : stdout );
|
|
|
|
exit( code );
|
2000-12-20 21:41:21 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 17:09:25 +00:00
|
|
|
static void ATTR_PRINTFLIKE(1, 2)
|
|
|
|
debug( const char *msg, ... )
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start( va, msg );
|
|
|
|
vdebug( DEBUG_MAIN, msg, va );
|
|
|
|
va_end( va );
|
|
|
|
}
|
|
|
|
|
2007-04-04 16:19:47 +00:00
|
|
|
#ifdef __linux__
|
2019-07-28 17:52:41 +00:00
|
|
|
static void ATTR_NORETURN
|
2006-02-02 13:48:02 +00:00
|
|
|
crashHandler( int n )
|
|
|
|
{
|
|
|
|
int dpid;
|
|
|
|
char pbuf[10], pabuf[20];
|
|
|
|
|
|
|
|
close( 0 );
|
|
|
|
open( "/dev/tty", O_RDWR );
|
|
|
|
dup2( 0, 1 );
|
|
|
|
dup2( 0, 2 );
|
2006-03-19 11:29:12 +00:00
|
|
|
error( "*** " EXE " caught signal %d. Starting debugger ...\n", n );
|
2019-12-03 12:00:19 +00:00
|
|
|
#ifdef PR_SET_PTRACER
|
|
|
|
int pip[2];
|
|
|
|
if (pipe( pip ) < 0) {
|
|
|
|
perror( "pipe()" );
|
|
|
|
exit( 3 );
|
|
|
|
}
|
|
|
|
#endif
|
2007-04-04 16:19:47 +00:00
|
|
|
switch ((dpid = fork())) {
|
2006-02-02 13:48:02 +00:00
|
|
|
case -1:
|
|
|
|
perror( "fork()" );
|
|
|
|
break;
|
|
|
|
case 0:
|
2019-12-03 12:00:19 +00:00
|
|
|
#ifdef PR_SET_PTRACER
|
|
|
|
close( pip[1] );
|
|
|
|
read( pip[0], pbuf, 1 );
|
|
|
|
close( pip[0] );
|
|
|
|
#endif
|
2006-02-02 13:48:02 +00:00
|
|
|
sprintf( pbuf, "%d", Pid );
|
|
|
|
sprintf( pabuf, "/proc/%d/exe", Pid );
|
|
|
|
execlp( "gdb", "gdb", pabuf, pbuf, (char *)0 );
|
|
|
|
perror( "execlp()" );
|
|
|
|
_exit( 1 );
|
|
|
|
default:
|
2019-12-03 12:00:19 +00:00
|
|
|
#ifdef PR_SET_PTRACER
|
|
|
|
prctl( PR_SET_PTRACER, (ulong)dpid );
|
|
|
|
close( pip[1] );
|
|
|
|
close( pip[0] );
|
|
|
|
#endif
|
2019-07-28 18:50:31 +00:00
|
|
|
waitpid( dpid, NULL, 0 );
|
2006-02-02 13:48:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
exit( 3 );
|
|
|
|
}
|
2007-04-04 16:19:47 +00:00
|
|
|
#endif
|
2006-02-02 13:48:02 +00:00
|
|
|
|
2015-03-28 16:26:08 +00:00
|
|
|
void
|
|
|
|
stats( void )
|
|
|
|
{
|
|
|
|
char buf[3][64];
|
|
|
|
char *cs;
|
|
|
|
int t, l, ll, cls;
|
|
|
|
static int cols = -1;
|
|
|
|
|
2015-03-23 07:42:51 +00:00
|
|
|
if (!(DFlags & PROGRESS))
|
2015-03-28 16:26:08 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (cols < 0 && (!(cs = getenv( "COLUMNS" )) || !(cols = atoi( cs ))))
|
|
|
|
cols = 80;
|
|
|
|
ll = sprintf( buf[2], "C: %d/%d B: %d/%d", chans_done, chans_total, boxes_done, boxes_total );
|
|
|
|
cls = (cols - ll - 10) / 2;
|
|
|
|
for (t = 0; t < 2; t++) {
|
|
|
|
l = sprintf( buf[t], "+%d/%d *%d/%d #%d/%d",
|
|
|
|
new_done[t], new_total[t],
|
|
|
|
flags_done[t], flags_total[t],
|
|
|
|
trash_done[t], trash_total[t] );
|
|
|
|
if (l > cls)
|
|
|
|
buf[t][cls - 1] = '~';
|
|
|
|
}
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
progress( "\r%s F: %.*s N: %.*s", buf[2], cls, buf[0], cls, buf[1] );
|
2015-03-28 16:26:08 +00:00
|
|
|
}
|
|
|
|
|
2004-03-27 16:07:20 +00:00
|
|
|
static int
|
|
|
|
matches( const char *t, const char *p )
|
2000-12-20 21:41:21 +00:00
|
|
|
{
|
2004-03-27 16:07:20 +00:00
|
|
|
for (;;) {
|
|
|
|
if (!*p)
|
|
|
|
return !*t;
|
|
|
|
if (*p == '*') {
|
|
|
|
p++;
|
|
|
|
do {
|
|
|
|
if (matches( t, p ))
|
|
|
|
return 1;
|
|
|
|
} while (*t++);
|
|
|
|
return 0;
|
|
|
|
} else if (*p == '%') {
|
|
|
|
p++;
|
|
|
|
do {
|
2012-08-11 16:34:46 +00:00
|
|
|
if (*t == '/')
|
2004-03-27 16:07:20 +00:00
|
|
|
return 0;
|
|
|
|
if (matches( t, p ))
|
|
|
|
return 1;
|
|
|
|
} while (*t++);
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
if (*p != *t)
|
|
|
|
return 0;
|
|
|
|
p++, t++;
|
|
|
|
}
|
|
|
|
}
|
2000-12-20 21:41:21 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 16:27:41 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
is_inbox( const char *name )
|
|
|
|
{
|
|
|
|
return starts_with( name, -1, "INBOX", 5 ) && (!name[5] || name[5] == '/');
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
cmp_box_names( const void *a, const void *b )
|
|
|
|
{
|
2019-07-28 19:13:28 +00:00
|
|
|
const char *as = *(const char * const *)a;
|
|
|
|
const char *bs = *(const char * const *)b;
|
2015-03-26 16:27:41 +00:00
|
|
|
int ai = is_inbox( as );
|
|
|
|
int bi = is_inbox( bs );
|
|
|
|
int di = bi - ai;
|
|
|
|
if (di)
|
|
|
|
return di;
|
|
|
|
return strcmp( as, bs );
|
|
|
|
}
|
|
|
|
|
|
|
|
static char **
|
2013-12-08 08:49:39 +00:00
|
|
|
filter_boxes( string_list_t *boxes, const char *prefix, string_list_t *patterns )
|
2000-12-20 21:41:21 +00:00
|
|
|
{
|
2015-03-26 16:27:41 +00:00
|
|
|
string_list_t *cpat;
|
2019-07-28 18:50:31 +00:00
|
|
|
char **boxarr = NULL;
|
2004-03-27 16:07:20 +00:00
|
|
|
const char *ps;
|
2020-07-08 15:27:37 +00:00
|
|
|
uint not, fnot, pfxl, num = 0, rnum = 0;
|
2004-03-27 16:07:20 +00:00
|
|
|
|
2013-12-08 08:49:39 +00:00
|
|
|
pfxl = prefix ? strlen( prefix ) : 0;
|
2004-03-27 16:07:20 +00:00
|
|
|
for (; boxes; boxes = boxes->next) {
|
2014-10-04 15:07:17 +00:00
|
|
|
if (!starts_with( boxes->string, -1, prefix, pfxl ))
|
2013-12-08 08:49:39 +00:00
|
|
|
continue;
|
2004-03-27 16:07:20 +00:00
|
|
|
fnot = 1;
|
|
|
|
for (cpat = patterns; cpat; cpat = cpat->next) {
|
|
|
|
ps = cpat->string;
|
|
|
|
if (*ps == '!') {
|
|
|
|
ps++;
|
|
|
|
not = 1;
|
|
|
|
} else
|
|
|
|
not = 0;
|
2013-12-08 08:49:39 +00:00
|
|
|
if (matches( boxes->string + pfxl, ps )) {
|
2004-03-27 16:07:20 +00:00
|
|
|
fnot = not;
|
|
|
|
break;
|
|
|
|
}
|
2001-06-22 23:30:41 +00:00
|
|
|
}
|
2015-03-26 16:27:41 +00:00
|
|
|
if (!fnot) {
|
|
|
|
if (num + 1 >= rnum)
|
|
|
|
boxarr = nfrealloc( boxarr, (rnum = (rnum + 10) * 2) * sizeof(*boxarr) );
|
|
|
|
boxarr[num++] = nfstrdup( boxes->string + pfxl );
|
2019-07-28 18:50:31 +00:00
|
|
|
boxarr[num] = NULL;
|
2015-03-26 16:27:41 +00:00
|
|
|
}
|
Bunch 'o patches from Oswald Buddenhagen:
i implemented some cool stuff (tm).
first, the long missing "create server-side missing mailboxes". -C now
creates both local and remote boxes; -L and -R create only local/remote.
second, i implemented a 1:1 remote:local folder mapping (-1) with an
optional INBOX exception (inbox/-I). the remote folder is specified with
the folder keyword (or -F switch) and takes precedence over the
namespace setting. the local directory with the mailboxes can now be
specified on the command line, too (-M).
another patch:
- made the -1 switch settable permanently (OneToOne). after all, you
usually define your mailbox layout once forever. removed -A, as it is
semantically -a modified by -1.
- cleaned up message output a bit. still, the quiet variable should be
used throughout the program. at best, create some generic output
function, which obeys a global verbosity level variable.
- optimized + cleaned up configuration parser slightly
- minor cleanups
add an (almost) unique id to every uploaded message and search for it
right after. i thought about using the message-id, but a) it is not
guaranteed to be unique in a mailbox (imagine you edit a mail and store
the dupe in the same box) and b) some mails (e.g., postponed) don't even
have one. a downside of the current implementation is, that this
id-header remains in the mailbox, but given that it wastes only 27 bytes
per mail and removing it would mean several roundtrips more, this seems
acceptable.
i changed the line-counting loop to use a mmapped file instead of
reading it in chunks, as it makes things simpler and is probably even
faster for big mails.
the amount of goto statements in my code may be scary, but c is simply
lacking a multi-level break statement. :)
this is the "shut up" patch. :) it makes the -q option consequent, so to
say.
additionally it adds an -l option which gathers all defined/found
mailboxes and just outputs the list. don't ask what i need it for. ;)
2002-10-30 02:23:05 +00:00
|
|
|
}
|
2015-03-26 16:27:41 +00:00
|
|
|
qsort( boxarr, num, sizeof(*boxarr), cmp_box_names );
|
|
|
|
return boxarr;
|
2004-03-27 16:07:20 +00:00
|
|
|
}
|
Bunch 'o patches from Oswald Buddenhagen:
i implemented some cool stuff (tm).
first, the long missing "create server-side missing mailboxes". -C now
creates both local and remote boxes; -L and -R create only local/remote.
second, i implemented a 1:1 remote:local folder mapping (-1) with an
optional INBOX exception (inbox/-I). the remote folder is specified with
the folder keyword (or -F switch) and takes precedence over the
namespace setting. the local directory with the mailboxes can now be
specified on the command line, too (-M).
another patch:
- made the -1 switch settable permanently (OneToOne). after all, you
usually define your mailbox layout once forever. removed -A, as it is
semantically -a modified by -1.
- cleaned up message output a bit. still, the quiet variable should be
used throughout the program. at best, create some generic output
function, which obeys a global verbosity level variable.
- optimized + cleaned up configuration parser slightly
- minor cleanups
add an (almost) unique id to every uploaded message and search for it
right after. i thought about using the message-id, but a) it is not
guaranteed to be unique in a mailbox (imagine you edit a mail and store
the dupe in the same box) and b) some mails (e.g., postponed) don't even
have one. a downside of the current implementation is, that this
id-header remains in the mailbox, but given that it wastes only 27 bytes
per mail and removing it would mean several roundtrips more, this seems
acceptable.
i changed the line-counting loop to use a mmapped file instead of
reading it in chunks, as it makes things simpler and is probably even
faster for big mails.
the amount of goto statements in my code may be scary, but c is simply
lacking a multi-level break statement. :)
this is the "shut up" patch. :) it makes the -q option consequent, so to
say.
additionally it adds an -l option which gathers all defined/found
mailboxes and just outputs the list. don't ask what i need it for. ;)
2002-10-30 02:23:05 +00:00
|
|
|
|
2004-03-27 16:07:20 +00:00
|
|
|
static void
|
2005-12-28 10:02:22 +00:00
|
|
|
merge_actions( channel_conf_t *chan, int ops[], int have, int mask, int def )
|
2004-03-27 16:07:20 +00:00
|
|
|
{
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
if (ops[F] & have) {
|
|
|
|
chan->ops[F] &= ~mask;
|
|
|
|
chan->ops[F] |= ops[F] & mask;
|
|
|
|
chan->ops[N] &= ~mask;
|
|
|
|
chan->ops[N] |= ops[N] & mask;
|
|
|
|
} else if (!(chan->ops[F] & have)) {
|
|
|
|
if (global_conf.ops[F] & have) {
|
|
|
|
chan->ops[F] |= global_conf.ops[F] & mask;
|
|
|
|
chan->ops[N] |= global_conf.ops[N] & mask;
|
2004-03-27 16:07:20 +00:00
|
|
|
} else {
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
chan->ops[F] |= def;
|
|
|
|
chan->ops[N] |= def;
|
2004-03-27 16:07:20 +00:00
|
|
|
}
|
Bunch 'o patches from Oswald Buddenhagen:
i implemented some cool stuff (tm).
first, the long missing "create server-side missing mailboxes". -C now
creates both local and remote boxes; -L and -R create only local/remote.
second, i implemented a 1:1 remote:local folder mapping (-1) with an
optional INBOX exception (inbox/-I). the remote folder is specified with
the folder keyword (or -F switch) and takes precedence over the
namespace setting. the local directory with the mailboxes can now be
specified on the command line, too (-M).
another patch:
- made the -1 switch settable permanently (OneToOne). after all, you
usually define your mailbox layout once forever. removed -A, as it is
semantically -a modified by -1.
- cleaned up message output a bit. still, the quiet variable should be
used throughout the program. at best, create some generic output
function, which obeys a global verbosity level variable.
- optimized + cleaned up configuration parser slightly
- minor cleanups
add an (almost) unique id to every uploaded message and search for it
right after. i thought about using the message-id, but a) it is not
guaranteed to be unique in a mailbox (imagine you edit a mail and store
the dupe in the same box) and b) some mails (e.g., postponed) don't even
have one. a downside of the current implementation is, that this
id-header remains in the mailbox, but given that it wastes only 27 bytes
per mail and removing it would mean several roundtrips more, this seems
acceptable.
i changed the line-counting loop to use a mmapped file instead of
reading it in chunks, as it makes things simpler and is probably even
faster for big mails.
the amount of goto statements in my code may be scary, but c is simply
lacking a multi-level break statement. :)
this is the "shut up" patch. :) it makes the -q option consequent, so to
say.
additionally it adds an -l option which gathers all defined/found
mailboxes and just outputs the list. don't ask what i need it for. ;)
2002-10-30 02:23:05 +00:00
|
|
|
}
|
2004-03-27 16:07:20 +00:00
|
|
|
}
|
2004-01-09 20:43:36 +00:00
|
|
|
|
2015-03-26 16:27:41 +00:00
|
|
|
typedef struct box_ent {
|
|
|
|
struct box_ent *next;
|
|
|
|
char *name;
|
|
|
|
int present[2];
|
|
|
|
} box_ent_t;
|
|
|
|
|
2015-03-28 16:51:27 +00:00
|
|
|
typedef struct chan_ent {
|
|
|
|
struct chan_ent *next;
|
|
|
|
channel_conf_t *conf;
|
|
|
|
box_ent_t *boxes;
|
|
|
|
char boxlist;
|
|
|
|
} chan_ent_t;
|
|
|
|
|
|
|
|
static chan_ent_t *
|
|
|
|
add_channel( chan_ent_t ***chanapp, channel_conf_t *chan, int ops[] )
|
|
|
|
{
|
|
|
|
chan_ent_t *ce = nfcalloc( sizeof(*ce) );
|
|
|
|
ce->conf = chan;
|
|
|
|
|
|
|
|
merge_actions( chan, ops, XOP_HAVE_TYPE, OP_MASK_TYPE, OP_MASK_TYPE );
|
|
|
|
merge_actions( chan, ops, XOP_HAVE_CREATE, OP_CREATE, 0 );
|
|
|
|
merge_actions( chan, ops, XOP_HAVE_REMOVE, OP_REMOVE, 0 );
|
|
|
|
merge_actions( chan, ops, XOP_HAVE_EXPUNGE, OP_EXPUNGE, 0 );
|
|
|
|
|
|
|
|
**chanapp = ce;
|
|
|
|
*chanapp = &ce->next;
|
2015-03-28 16:26:08 +00:00
|
|
|
chans_total++;
|
2015-03-28 16:51:27 +00:00
|
|
|
return ce;
|
|
|
|
}
|
|
|
|
|
|
|
|
static chan_ent_t *
|
|
|
|
add_named_channel( chan_ent_t ***chanapp, char *channame, int ops[] )
|
|
|
|
{
|
|
|
|
channel_conf_t *chan;
|
|
|
|
chan_ent_t *ce;
|
2019-07-28 18:50:31 +00:00
|
|
|
box_ent_t *boxes = NULL, **mboxapp = &boxes, *mbox;
|
2015-03-28 16:51:27 +00:00
|
|
|
char *boxp, *nboxp;
|
2020-07-08 15:27:37 +00:00
|
|
|
size_t boxl;
|
|
|
|
char boxlist = 0;
|
2015-03-28 16:51:27 +00:00
|
|
|
|
|
|
|
if ((boxp = strchr( channame, ':' )))
|
|
|
|
*boxp++ = 0;
|
|
|
|
for (chan = channels; chan; chan = chan->next)
|
|
|
|
if (!strcmp( chan->name, channame ))
|
|
|
|
goto gotchan;
|
|
|
|
error( "No channel or group named '%s' defined.\n", channame );
|
2019-07-28 18:50:31 +00:00
|
|
|
return NULL;
|
2015-03-28 16:51:27 +00:00
|
|
|
gotchan:
|
|
|
|
if (boxp) {
|
|
|
|
if (!chan->patterns) {
|
|
|
|
error( "Cannot override mailbox in channel '%s' - no Patterns.\n", channame );
|
2019-07-28 18:50:31 +00:00
|
|
|
return NULL;
|
2015-03-28 16:51:27 +00:00
|
|
|
}
|
|
|
|
boxlist = 1;
|
|
|
|
do {
|
|
|
|
nboxp = strpbrk( boxp, ",\n" );
|
|
|
|
if (nboxp) {
|
2020-07-08 15:27:37 +00:00
|
|
|
boxl = (size_t)(nboxp - boxp);
|
2015-03-28 16:51:27 +00:00
|
|
|
*nboxp++ = 0;
|
|
|
|
} else {
|
|
|
|
boxl = strlen( boxp );
|
|
|
|
}
|
|
|
|
mbox = nfmalloc( sizeof(*mbox) );
|
|
|
|
if (boxl)
|
|
|
|
mbox->name = nfstrndup( boxp, boxl );
|
|
|
|
else
|
|
|
|
mbox->name = nfstrndup( "INBOX", 5 );
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
mbox->present[F] = mbox->present[N] = BOX_POSSIBLE;
|
2019-07-28 18:50:31 +00:00
|
|
|
mbox->next = NULL;
|
2015-03-28 16:51:27 +00:00
|
|
|
*mboxapp = mbox;
|
|
|
|
mboxapp = &mbox->next;
|
2015-03-28 16:26:08 +00:00
|
|
|
boxes_total++;
|
2015-03-28 16:51:27 +00:00
|
|
|
boxp = nboxp;
|
|
|
|
} while (boxp);
|
2015-03-28 16:26:08 +00:00
|
|
|
} else {
|
|
|
|
if (!chan->patterns)
|
|
|
|
boxes_total++;
|
2015-03-28 16:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ce = add_channel( chanapp, chan, ops );
|
|
|
|
ce->boxes = boxes;
|
|
|
|
ce->boxlist = boxlist;
|
|
|
|
return ce;
|
|
|
|
}
|
|
|
|
|
2006-03-21 15:53:43 +00:00
|
|
|
typedef struct {
|
|
|
|
int t[2];
|
|
|
|
channel_conf_t *chan;
|
|
|
|
driver_t *drv[2];
|
|
|
|
store_t *ctx[2];
|
2015-03-28 16:51:27 +00:00
|
|
|
chan_ent_t *chanptr;
|
|
|
|
box_ent_t *boxptr;
|
2017-03-24 14:29:06 +00:00
|
|
|
string_list_t *boxes[2];
|
2013-12-08 08:49:39 +00:00
|
|
|
char *names[2];
|
2015-03-28 16:26:08 +00:00
|
|
|
int ret, all, list, state[2];
|
2015-03-28 16:51:27 +00:00
|
|
|
char done, skip, cben;
|
2006-03-21 15:53:43 +00:00
|
|
|
} main_vars_t;
|
|
|
|
|
2006-03-21 20:03:21 +00:00
|
|
|
#define AUX &mvars->t[t]
|
|
|
|
#define MVARS(aux) \
|
|
|
|
int t = *(int *)aux; \
|
|
|
|
main_vars_t *mvars = (main_vars_t *)(((char *)(&((int *)aux)[-t])) - offsetof(main_vars_t, t));
|
|
|
|
|
|
|
|
#define E_START 0
|
|
|
|
#define E_OPEN 1
|
|
|
|
#define E_SYNC 2
|
|
|
|
|
|
|
|
static void sync_chans( main_vars_t *mvars, int ent );
|
2006-03-21 15:53:43 +00:00
|
|
|
|
2004-03-27 16:07:20 +00:00
|
|
|
int
|
|
|
|
main( int argc, char **argv )
|
|
|
|
{
|
2006-03-21 15:53:43 +00:00
|
|
|
main_vars_t mvars[1];
|
2019-07-28 18:50:31 +00:00
|
|
|
chan_ent_t *chans = NULL, **chanapp = &chans;
|
2004-03-27 16:07:20 +00:00
|
|
|
group_conf_t *group;
|
2015-03-28 16:51:27 +00:00
|
|
|
channel_conf_t *chan;
|
|
|
|
string_list_t *channame;
|
2019-07-28 18:50:31 +00:00
|
|
|
char *config = NULL, *opt, *ochar;
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
int oind, cops = 0, op, ops[2] = { 0, 0 }, pseudo = 0, ms_warn = 0;
|
2004-03-27 16:07:20 +00:00
|
|
|
|
2013-11-09 13:35:07 +00:00
|
|
|
tzset();
|
2004-03-27 16:07:20 +00:00
|
|
|
gethostname( Hostname, sizeof(Hostname) );
|
|
|
|
if ((ochar = strchr( Hostname, '.' )))
|
|
|
|
*ochar = 0;
|
|
|
|
Pid = getpid();
|
|
|
|
if (!(Home = getenv("HOME"))) {
|
|
|
|
fputs( "Fatal: $HOME not set\n", stderr );
|
|
|
|
return 1;
|
Bunch 'o patches from Oswald Buddenhagen:
i implemented some cool stuff (tm).
first, the long missing "create server-side missing mailboxes". -C now
creates both local and remote boxes; -L and -R create only local/remote.
second, i implemented a 1:1 remote:local folder mapping (-1) with an
optional INBOX exception (inbox/-I). the remote folder is specified with
the folder keyword (or -F switch) and takes precedence over the
namespace setting. the local directory with the mailboxes can now be
specified on the command line, too (-M).
another patch:
- made the -1 switch settable permanently (OneToOne). after all, you
usually define your mailbox layout once forever. removed -A, as it is
semantically -a modified by -1.
- cleaned up message output a bit. still, the quiet variable should be
used throughout the program. at best, create some generic output
function, which obeys a global verbosity level variable.
- optimized + cleaned up configuration parser slightly
- minor cleanups
add an (almost) unique id to every uploaded message and search for it
right after. i thought about using the message-id, but a) it is not
guaranteed to be unique in a mailbox (imagine you edit a mail and store
the dupe in the same box) and b) some mails (e.g., postponed) don't even
have one. a downside of the current implementation is, that this
id-header remains in the mailbox, but given that it wastes only 27 bytes
per mail and removing it would mean several roundtrips more, this seems
acceptable.
i changed the line-counting loop to use a mmapped file instead of
reading it in chunks, as it makes things simpler and is probably even
faster for big mails.
the amount of goto statements in my code may be scary, but c is simply
lacking a multi-level break statement. :)
this is the "shut up" patch. :) it makes the -q option consequent, so to
say.
additionally it adds an -l option which gathers all defined/found
mailboxes and just outputs the list. don't ask what i need it for. ;)
2002-10-30 02:23:05 +00:00
|
|
|
}
|
2004-03-27 16:07:20 +00:00
|
|
|
arc4_init();
|
|
|
|
|
2006-03-21 15:53:43 +00:00
|
|
|
memset( mvars, 0, sizeof(*mvars) );
|
2006-12-04 17:47:55 +00:00
|
|
|
mvars->t[1] = 1;
|
2006-03-21 15:53:43 +00:00
|
|
|
|
2019-07-28 18:50:31 +00:00
|
|
|
for (oind = 1, ochar = NULL; ; ) {
|
2004-03-27 16:07:20 +00:00
|
|
|
if (!ochar || !*ochar) {
|
2015-03-28 16:51:27 +00:00
|
|
|
if (oind >= argc)
|
2008-02-23 09:18:42 +00:00
|
|
|
break;
|
2015-03-28 16:51:27 +00:00
|
|
|
if (argv[oind][0] != '-')
|
2004-03-27 16:07:20 +00:00
|
|
|
break;
|
2015-03-28 16:51:27 +00:00
|
|
|
if (argv[oind][1] == '-') {
|
|
|
|
opt = argv[oind++] + 2;
|
2004-03-27 16:07:20 +00:00
|
|
|
if (!*opt)
|
|
|
|
break;
|
|
|
|
if (!strcmp( opt, "config" )) {
|
2015-03-28 16:51:27 +00:00
|
|
|
if (oind >= argc) {
|
2006-03-19 11:29:12 +00:00
|
|
|
error( "--config requires an argument.\n" );
|
2004-03-27 16:07:20 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2015-03-28 16:51:27 +00:00
|
|
|
config = argv[oind++];
|
2014-10-04 15:07:17 +00:00
|
|
|
} else if (starts_with( opt, -1, "config=", 7 ))
|
2004-03-27 16:07:20 +00:00
|
|
|
config = opt + 7;
|
|
|
|
else if (!strcmp( opt, "all" ))
|
2006-03-21 15:53:43 +00:00
|
|
|
mvars->all = 1;
|
2004-03-27 16:07:20 +00:00
|
|
|
else if (!strcmp( opt, "list" ))
|
2006-03-21 15:53:43 +00:00
|
|
|
mvars->list = 1;
|
2004-03-27 16:07:20 +00:00
|
|
|
else if (!strcmp( opt, "help" ))
|
|
|
|
usage( 0 );
|
|
|
|
else if (!strcmp( opt, "version" ))
|
|
|
|
version();
|
2006-01-29 14:46:16 +00:00
|
|
|
else if (!strcmp( opt, "quiet" )) {
|
|
|
|
if (DFlags & QUIET)
|
|
|
|
DFlags |= VERYQUIET;
|
|
|
|
else
|
|
|
|
DFlags |= QUIET;
|
2010-02-06 09:40:36 +00:00
|
|
|
} else if (!strcmp( opt, "verbose" )) {
|
2015-03-23 07:42:51 +00:00
|
|
|
DFlags |= VERBOSE;
|
|
|
|
} else if (starts_with( opt, -1, "debug", 5 )) {
|
|
|
|
opt += 5;
|
|
|
|
if (!*opt)
|
|
|
|
op = VERBOSE | DEBUG_ALL;
|
|
|
|
else if (!strcmp( opt, "-crash" ))
|
|
|
|
op = DEBUG_CRASH;
|
2017-04-02 12:57:17 +00:00
|
|
|
else if (!strcmp( opt, "-driver" ))
|
|
|
|
op = VERBOSE | DEBUG_DRV;
|
|
|
|
else if (!strcmp( opt, "-driver-all" ))
|
|
|
|
op = VERBOSE | DEBUG_DRV | DEBUG_DRV_ALL;
|
2015-03-23 07:42:51 +00:00
|
|
|
else if (!strcmp( opt, "-maildir" ))
|
|
|
|
op = VERBOSE | DEBUG_MAILDIR;
|
2015-03-26 17:09:25 +00:00
|
|
|
else if (!strcmp( opt, "-main" ))
|
|
|
|
op = VERBOSE | DEBUG_MAIN;
|
2015-03-23 07:42:51 +00:00
|
|
|
else if (!strcmp( opt, "-net" ))
|
|
|
|
op = VERBOSE | DEBUG_NET;
|
|
|
|
else if (!strcmp( opt, "-net-all" ))
|
2015-04-26 10:07:31 +00:00
|
|
|
op = VERBOSE | DEBUG_NET | DEBUG_NET_ALL;
|
2015-03-23 07:42:51 +00:00
|
|
|
else if (!strcmp( opt, "-sync" ))
|
|
|
|
op = VERBOSE | DEBUG_SYNC;
|
2010-02-06 09:40:36 +00:00
|
|
|
else
|
2015-03-23 07:42:51 +00:00
|
|
|
goto badopt;
|
|
|
|
DFlags |= op;
|
|
|
|
} else if (!strcmp( opt, "pull" ))
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
cops |= XOP_PULL, ops[F] |= XOP_HAVE_TYPE;
|
2004-03-27 16:07:20 +00:00
|
|
|
else if (!strcmp( opt, "push" ))
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
cops |= XOP_PUSH, ops[F] |= XOP_HAVE_TYPE;
|
2014-10-04 15:07:17 +00:00
|
|
|
else if (starts_with( opt, -1, "create", 6 )) {
|
2004-03-27 16:07:20 +00:00
|
|
|
opt += 6;
|
|
|
|
op = OP_CREATE|XOP_HAVE_CREATE;
|
|
|
|
lcop:
|
|
|
|
if (!*opt)
|
|
|
|
cops |= op;
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
else if (!strcmp( opt, "-far" ))
|
|
|
|
ops[F] |= op;
|
|
|
|
else if (!strcmp( opt, "-master" )) // Pre-1.4 legacy
|
|
|
|
ops[F] |= op, ms_warn = 1;
|
|
|
|
else if (!strcmp( opt, "-near" ))
|
|
|
|
ops[N] |= op;
|
|
|
|
else if (!strcmp( opt, "-slave" )) // Pre-1.4 legacy
|
|
|
|
ops[N] |= op, ms_warn = 1;
|
2004-03-27 16:07:20 +00:00
|
|
|
else
|
|
|
|
goto badopt;
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
ops[F] |= op & (XOP_HAVE_CREATE|XOP_HAVE_REMOVE|XOP_HAVE_EXPUNGE);
|
2014-12-29 01:08:48 +00:00
|
|
|
} else if (starts_with( opt, -1, "remove", 6 )) {
|
|
|
|
opt += 6;
|
|
|
|
op = OP_REMOVE|XOP_HAVE_REMOVE;
|
|
|
|
goto lcop;
|
2014-10-04 15:07:17 +00:00
|
|
|
} else if (starts_with( opt, -1, "expunge", 7 )) {
|
2004-03-27 16:07:20 +00:00
|
|
|
opt += 7;
|
|
|
|
op = OP_EXPUNGE|XOP_HAVE_EXPUNGE;
|
|
|
|
goto lcop;
|
|
|
|
} else if (!strcmp( opt, "no-expunge" ))
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
ops[F] |= XOP_HAVE_EXPUNGE;
|
2004-03-27 16:07:20 +00:00
|
|
|
else if (!strcmp( opt, "no-create" ))
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
ops[F] |= XOP_HAVE_CREATE;
|
2014-12-29 01:08:48 +00:00
|
|
|
else if (!strcmp( opt, "no-remove" ))
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
ops[F] |= XOP_HAVE_REMOVE;
|
2004-03-27 16:07:20 +00:00
|
|
|
else if (!strcmp( opt, "full" ))
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
ops[F] |= XOP_HAVE_TYPE|XOP_PULL|XOP_PUSH;
|
2004-03-27 16:07:20 +00:00
|
|
|
else if (!strcmp( opt, "noop" ))
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
ops[F] |= XOP_HAVE_TYPE;
|
2014-10-04 15:07:17 +00:00
|
|
|
else if (starts_with( opt, -1, "pull", 4 )) {
|
2004-03-27 16:07:20 +00:00
|
|
|
op = XOP_PULL;
|
|
|
|
lcac:
|
|
|
|
opt += 4;
|
|
|
|
if (!*opt)
|
|
|
|
cops |= op;
|
|
|
|
else if (*opt == '-') {
|
|
|
|
opt++;
|
|
|
|
goto rlcac;
|
|
|
|
} else
|
|
|
|
goto badopt;
|
2014-10-04 15:07:17 +00:00
|
|
|
} else if (starts_with( opt, -1, "push", 4 )) {
|
2004-03-27 16:07:20 +00:00
|
|
|
op = XOP_PUSH;
|
|
|
|
goto lcac;
|
|
|
|
} else {
|
|
|
|
op = 0;
|
|
|
|
rlcac:
|
|
|
|
if (!strcmp( opt, "new" ))
|
|
|
|
op |= OP_NEW;
|
|
|
|
else if (!strcmp( opt, "renew" ))
|
|
|
|
op |= OP_RENEW;
|
|
|
|
else if (!strcmp( opt, "delete" ))
|
|
|
|
op |= OP_DELETE;
|
|
|
|
else if (!strcmp( opt, "flags" ))
|
|
|
|
op |= OP_FLAGS;
|
|
|
|
else {
|
|
|
|
badopt:
|
2015-03-28 16:51:27 +00:00
|
|
|
error( "Unknown option '%s'\n", argv[oind - 1] );
|
2004-03-27 16:07:20 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
switch (op & XOP_MASK_DIR) {
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
case XOP_PULL: ops[N] |= op & OP_MASK_TYPE; break;
|
|
|
|
case XOP_PUSH: ops[F] |= op & OP_MASK_TYPE; break;
|
2004-03-27 16:07:20 +00:00
|
|
|
default: cops |= op; break;
|
|
|
|
}
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
ops[F] |= XOP_HAVE_TYPE;
|
2004-03-27 16:07:20 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2015-03-28 16:51:27 +00:00
|
|
|
ochar = argv[oind++] + 1;
|
2004-03-27 16:07:20 +00:00
|
|
|
if (!*ochar) {
|
2006-03-19 11:29:12 +00:00
|
|
|
error( "Invalid option '-'\n" );
|
2004-03-27 16:07:20 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (*ochar++) {
|
|
|
|
case 'a':
|
2006-03-21 15:53:43 +00:00
|
|
|
mvars->all = 1;
|
2004-03-27 16:07:20 +00:00
|
|
|
break;
|
|
|
|
case 'l':
|
2006-03-21 15:53:43 +00:00
|
|
|
mvars->list = 1;
|
2004-03-27 16:07:20 +00:00
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
if (*ochar == 'T') {
|
|
|
|
ochar++;
|
|
|
|
pseudo = 1;
|
|
|
|
}
|
2015-03-28 16:51:27 +00:00
|
|
|
if (oind >= argc) {
|
2006-03-19 11:29:12 +00:00
|
|
|
error( "-c requires an argument.\n" );
|
2004-03-27 16:07:20 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2015-03-28 16:51:27 +00:00
|
|
|
config = argv[oind++];
|
2004-03-27 16:07:20 +00:00
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
op = OP_CREATE|XOP_HAVE_CREATE;
|
|
|
|
cop:
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
if (*ochar == 'f')
|
|
|
|
ops[F] |= op, ochar++;
|
|
|
|
else if (*ochar == 'm') // Pre-1.4 legacy
|
|
|
|
ops[F] |= op, ms_warn = 1, ochar++;
|
|
|
|
else if (*ochar == 'n')
|
|
|
|
ops[N] |= op, ochar++;
|
|
|
|
else if (*ochar == 's') // Pre-1.4 legacy
|
|
|
|
ops[N] |= op, ms_warn = 1, ochar++;
|
2004-03-27 16:07:20 +00:00
|
|
|
else if (*ochar == '-')
|
|
|
|
ochar++;
|
|
|
|
else
|
|
|
|
cops |= op;
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
ops[F] |= op & (XOP_HAVE_CREATE|XOP_HAVE_REMOVE|XOP_HAVE_EXPUNGE);
|
2004-03-27 16:07:20 +00:00
|
|
|
break;
|
2014-12-29 01:08:48 +00:00
|
|
|
case 'R':
|
|
|
|
op = OP_REMOVE|XOP_HAVE_REMOVE;
|
|
|
|
goto cop;
|
2004-03-27 16:07:20 +00:00
|
|
|
case 'X':
|
|
|
|
op = OP_EXPUNGE|XOP_HAVE_EXPUNGE;
|
|
|
|
goto cop;
|
|
|
|
case 'F':
|
|
|
|
cops |= XOP_PULL|XOP_PUSH;
|
2017-10-01 08:04:00 +00:00
|
|
|
FALLTHROUGH
|
2004-03-27 16:07:20 +00:00
|
|
|
case '0':
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
ops[F] |= XOP_HAVE_TYPE;
|
2004-03-27 16:07:20 +00:00
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
case 'd':
|
|
|
|
case 'f':
|
|
|
|
case 'N':
|
|
|
|
--ochar;
|
|
|
|
op = 0;
|
|
|
|
cac:
|
|
|
|
for (;; ochar++) {
|
|
|
|
if (*ochar == 'n')
|
|
|
|
op |= OP_NEW;
|
|
|
|
else if (*ochar == 'd')
|
|
|
|
op |= OP_DELETE;
|
|
|
|
else if (*ochar == 'f')
|
|
|
|
op |= OP_FLAGS;
|
|
|
|
else if (*ochar == 'N')
|
|
|
|
op |= OP_RENEW;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (op & OP_MASK_TYPE)
|
|
|
|
switch (op & XOP_MASK_DIR) {
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
case XOP_PULL: ops[N] |= op & OP_MASK_TYPE; break;
|
|
|
|
case XOP_PUSH: ops[F] |= op & OP_MASK_TYPE; break;
|
2004-03-27 16:07:20 +00:00
|
|
|
default: cops |= op; break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cops |= op;
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
ops[F] |= XOP_HAVE_TYPE;
|
2004-03-27 16:07:20 +00:00
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
op = XOP_PULL;
|
|
|
|
goto cac;
|
|
|
|
case 'H':
|
|
|
|
op = XOP_PUSH;
|
|
|
|
goto cac;
|
|
|
|
case 'q':
|
2006-01-29 14:46:16 +00:00
|
|
|
if (DFlags & QUIET)
|
|
|
|
DFlags |= VERYQUIET;
|
|
|
|
else
|
|
|
|
DFlags |= QUIET;
|
2004-03-27 16:07:20 +00:00
|
|
|
break;
|
|
|
|
case 'V':
|
2015-03-23 07:42:51 +00:00
|
|
|
DFlags |= VERBOSE;
|
2004-03-27 16:07:20 +00:00
|
|
|
break;
|
|
|
|
case 'D':
|
2015-03-23 07:42:51 +00:00
|
|
|
for (op = 0; *ochar; ochar++) {
|
|
|
|
switch (*ochar) {
|
|
|
|
case 'C':
|
|
|
|
op |= DEBUG_CRASH;
|
|
|
|
break;
|
2017-04-02 12:57:17 +00:00
|
|
|
case 'd':
|
|
|
|
op |= DEBUG_DRV | VERBOSE;
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
op |= DEBUG_DRV | DEBUG_DRV_ALL | VERBOSE;
|
|
|
|
break;
|
2015-03-23 07:42:51 +00:00
|
|
|
case 'm':
|
|
|
|
op |= DEBUG_MAILDIR | VERBOSE;
|
|
|
|
break;
|
2015-03-26 17:09:25 +00:00
|
|
|
case 'M':
|
|
|
|
op |= DEBUG_MAIN | VERBOSE;
|
|
|
|
break;
|
2015-03-23 07:42:51 +00:00
|
|
|
case 'n':
|
|
|
|
op |= DEBUG_NET | VERBOSE;
|
|
|
|
break;
|
|
|
|
case 'N':
|
2015-04-26 10:07:31 +00:00
|
|
|
op |= DEBUG_NET | DEBUG_NET_ALL | VERBOSE;
|
2015-03-23 07:42:51 +00:00
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
op |= DEBUG_SYNC | VERBOSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error( "Unknown -D flag '%c'\n", *ochar );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!op)
|
|
|
|
op = DEBUG_ALL | VERBOSE;
|
|
|
|
DFlags |= op;
|
2004-03-27 16:07:20 +00:00
|
|
|
break;
|
2006-01-29 15:46:09 +00:00
|
|
|
case 'J':
|
|
|
|
DFlags |= KEEPJOURNAL;
|
2017-03-19 10:53:16 +00:00
|
|
|
JLimit = strtol( ochar, &ochar, 10 );
|
2006-01-29 15:46:09 +00:00
|
|
|
break;
|
2012-08-25 13:29:16 +00:00
|
|
|
case 'Z':
|
|
|
|
DFlags |= ZERODELAY;
|
|
|
|
break;
|
2004-03-27 16:07:20 +00:00
|
|
|
case 'v':
|
|
|
|
version();
|
|
|
|
case 'h':
|
|
|
|
usage( 0 );
|
|
|
|
default:
|
2006-03-19 11:29:12 +00:00
|
|
|
error( "Unknown option '-%c'\n", *(ochar - 1) );
|
2004-03-27 16:07:20 +00:00
|
|
|
return 1;
|
2001-06-18 17:49:08 +00:00
|
|
|
}
|
2000-12-20 21:41:21 +00:00
|
|
|
}
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
if (ms_warn)
|
|
|
|
warn( "Notice: -master/-slave/m/s suffixes are deprecated; use -far/-near/f/n instead.\n" );
|
2000-12-20 21:41:21 +00:00
|
|
|
|
2015-03-23 07:42:51 +00:00
|
|
|
if (!(DFlags & (QUIET | DEBUG_ALL)) && isatty( 1 ))
|
|
|
|
DFlags |= PROGRESS;
|
|
|
|
|
2007-04-04 16:19:47 +00:00
|
|
|
#ifdef __linux__
|
2015-03-23 07:42:51 +00:00
|
|
|
if (DFlags & DEBUG_CRASH) {
|
2006-02-02 13:48:02 +00:00
|
|
|
signal( SIGSEGV, crashHandler );
|
|
|
|
signal( SIGBUS, crashHandler );
|
|
|
|
signal( SIGILL, crashHandler );
|
|
|
|
}
|
2007-04-04 16:19:47 +00:00
|
|
|
#endif
|
2006-02-02 13:48:02 +00:00
|
|
|
|
2015-03-28 16:51:27 +00:00
|
|
|
if (merge_ops( cops, ops ))
|
2004-03-27 16:07:20 +00:00
|
|
|
return 1;
|
2000-12-20 21:41:21 +00:00
|
|
|
|
2004-03-27 16:07:20 +00:00
|
|
|
if (load_config( config, pseudo ))
|
|
|
|
return 1;
|
2000-12-20 21:41:21 +00:00
|
|
|
|
2004-03-27 16:07:20 +00:00
|
|
|
if (!channels) {
|
|
|
|
fputs( "No channels defined. Try 'man " EXE "'\n", stderr );
|
|
|
|
return 1;
|
|
|
|
}
|
2000-12-20 21:41:21 +00:00
|
|
|
|
2015-03-28 16:51:27 +00:00
|
|
|
if (mvars->all) {
|
2015-03-28 16:26:08 +00:00
|
|
|
for (chan = channels; chan; chan = chan->next) {
|
2015-03-28 16:51:27 +00:00
|
|
|
add_channel( &chanapp, chan, ops );
|
2015-03-28 16:26:08 +00:00
|
|
|
if (!chan->patterns)
|
|
|
|
boxes_total++;
|
|
|
|
}
|
2015-03-28 16:51:27 +00:00
|
|
|
} else {
|
|
|
|
for (; argv[oind]; oind++) {
|
|
|
|
for (group = groups; group; group = group->next) {
|
|
|
|
if (!strcmp( group->name, argv[oind] )) {
|
|
|
|
for (channame = group->channels; channame; channame = channame->next)
|
|
|
|
if (!add_named_channel( &chanapp, channame->string, ops ))
|
|
|
|
mvars->ret = 1;
|
|
|
|
goto gotgrp;
|
|
|
|
}
|
2004-03-27 16:07:20 +00:00
|
|
|
}
|
2015-03-28 16:51:27 +00:00
|
|
|
if (!add_named_channel( &chanapp, argv[oind], ops ))
|
|
|
|
mvars->ret = 1;
|
|
|
|
gotgrp: ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!chans) {
|
|
|
|
fputs( "No channel specified. Try '" EXE " -h'\n", stderr );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
mvars->chanptr = chans;
|
|
|
|
|
2015-03-28 16:26:08 +00:00
|
|
|
if (!mvars->list)
|
|
|
|
stats();
|
2006-03-21 20:03:21 +00:00
|
|
|
mvars->cben = 1;
|
|
|
|
sync_chans( mvars, E_START );
|
2011-03-13 13:29:12 +00:00
|
|
|
main_loop();
|
2015-03-28 16:26:08 +00:00
|
|
|
if (!mvars->list)
|
|
|
|
flushn();
|
2006-03-21 15:53:43 +00:00
|
|
|
return mvars->ret;
|
|
|
|
}
|
|
|
|
|
2006-03-21 20:03:21 +00:00
|
|
|
#define ST_FRESH 0
|
2015-05-24 09:37:15 +00:00
|
|
|
#define ST_CONNECTED 1
|
|
|
|
#define ST_OPEN 2
|
|
|
|
#define ST_CANCELING 3
|
|
|
|
#define ST_CLOSED 4
|
2006-03-21 20:03:21 +00:00
|
|
|
|
2015-05-24 09:37:15 +00:00
|
|
|
static void
|
|
|
|
cancel_prep_done( void *aux )
|
|
|
|
{
|
|
|
|
MVARS(aux)
|
|
|
|
|
|
|
|
mvars->drv[t]->free_store( mvars->ctx[t] );
|
|
|
|
mvars->state[t] = ST_CLOSED;
|
|
|
|
sync_chans( mvars, E_OPEN );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
store_bad( void *aux )
|
|
|
|
{
|
|
|
|
MVARS(aux)
|
|
|
|
|
|
|
|
mvars->drv[t]->cancel_store( mvars->ctx[t] );
|
|
|
|
mvars->state[t] = ST_CLOSED;
|
|
|
|
mvars->ret = mvars->skip = 1;
|
|
|
|
sync_chans( mvars, E_OPEN );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void store_connected( int sts, void *aux );
|
2017-03-24 16:44:11 +00:00
|
|
|
static void store_listed( int sts, string_list_t *boxes, void *aux );
|
2015-03-26 16:27:41 +00:00
|
|
|
static int sync_listed_boxes( main_vars_t *mvars, box_ent_t *mbox );
|
2013-12-08 08:49:39 +00:00
|
|
|
static void done_sync_2_dyn( int sts, void *aux );
|
2006-03-21 20:03:21 +00:00
|
|
|
static void done_sync( int sts, void *aux );
|
|
|
|
|
2006-03-21 20:05:48 +00:00
|
|
|
#define nz(a,b) ((a)?(a):(b))
|
|
|
|
|
2006-03-21 15:53:43 +00:00
|
|
|
static void
|
2006-03-21 20:03:21 +00:00
|
|
|
sync_chans( main_vars_t *mvars, int ent )
|
2006-03-21 15:53:43 +00:00
|
|
|
{
|
2015-03-26 16:27:41 +00:00
|
|
|
box_ent_t *mbox, *nmbox, **mboxapp;
|
2015-03-28 16:51:27 +00:00
|
|
|
char **boxes[2];
|
2013-12-08 15:37:20 +00:00
|
|
|
const char *labels[2];
|
2015-03-26 16:27:41 +00:00
|
|
|
int t, mb, sb, cmp;
|
2006-03-21 15:53:43 +00:00
|
|
|
|
2006-03-21 20:03:21 +00:00
|
|
|
if (!mvars->cben)
|
|
|
|
return;
|
|
|
|
switch (ent) {
|
|
|
|
case E_OPEN: goto opened;
|
|
|
|
case E_SYNC: goto syncone;
|
|
|
|
}
|
2015-03-28 16:51:27 +00:00
|
|
|
do {
|
|
|
|
mvars->chan = mvars->chanptr->conf;
|
2006-03-21 15:53:43 +00:00
|
|
|
info( "Channel %s\n", mvars->chan->name );
|
2006-03-21 20:03:21 +00:00
|
|
|
mvars->skip = mvars->cben = 0;
|
2015-01-03 23:39:06 +00:00
|
|
|
for (t = 0; t < 2; t++) {
|
2017-03-19 12:46:03 +00:00
|
|
|
int st = mvars->chan->stores[t]->driver->get_fail_state( mvars->chan->stores[t] );
|
2015-04-26 18:54:05 +00:00
|
|
|
if (st != FAIL_TEMP) {
|
|
|
|
info( "Skipping due to %sfailed %s store %s.\n",
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
(st == FAIL_WAIT) ? "temporarily " : "", str_fn[t], mvars->chan->stores[t]->name );
|
2015-01-03 23:39:06 +00:00
|
|
|
mvars->skip = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mvars->skip)
|
|
|
|
goto next2;
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
mvars->state[F] = mvars->state[N] = ST_FRESH;
|
|
|
|
if ((DFlags & DEBUG_DRV) || (mvars->chan->stores[F]->driver->get_caps( NULL ) & mvars->chan->stores[N]->driver->get_caps( NULL ) & DRV_VERBOSE))
|
|
|
|
labels[F] = "F: ", labels[N] = "N: ";
|
2013-12-08 15:37:20 +00:00
|
|
|
else
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
labels[F] = labels[N] = "";
|
2015-05-24 09:37:15 +00:00
|
|
|
for (t = 0; t < 2; t++) {
|
2017-04-02 12:57:17 +00:00
|
|
|
driver_t *drv = mvars->chan->stores[t]->driver;
|
|
|
|
store_t *ctx = drv->alloc_store( mvars->chan->stores[t], labels[t] );
|
|
|
|
if (DFlags & DEBUG_DRV) {
|
|
|
|
drv = &proxy_driver;
|
|
|
|
ctx = proxy_alloc_store( ctx, labels[t] );
|
|
|
|
}
|
|
|
|
mvars->drv[t] = drv;
|
|
|
|
mvars->ctx[t] = ctx;
|
|
|
|
drv->set_bad_callback( ctx, store_bad, AUX );
|
2015-05-24 09:37:15 +00:00
|
|
|
}
|
2015-01-02 10:29:51 +00:00
|
|
|
for (t = 0; ; t++) {
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
info( "Opening %s store %s...\n", str_fn[t], mvars->chan->stores[t]->name );
|
2015-05-24 09:37:15 +00:00
|
|
|
mvars->drv[t]->connect_store( mvars->ctx[t], store_connected, AUX );
|
|
|
|
if (t || mvars->skip)
|
2013-12-08 14:49:03 +00:00
|
|
|
break;
|
2006-03-20 19:38:20 +00:00
|
|
|
}
|
2015-05-24 09:37:15 +00:00
|
|
|
|
2006-03-21 20:03:21 +00:00
|
|
|
mvars->cben = 1;
|
|
|
|
opened:
|
|
|
|
if (mvars->skip)
|
|
|
|
goto next;
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
if (mvars->state[F] != ST_OPEN || mvars->state[N] != ST_OPEN)
|
2006-03-21 20:03:21 +00:00
|
|
|
return;
|
|
|
|
|
2015-03-28 16:51:27 +00:00
|
|
|
if (!mvars->chanptr->boxlist && mvars->chan->patterns) {
|
|
|
|
mvars->chanptr->boxlist = 2;
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
boxes[F] = filter_boxes( mvars->boxes[F], mvars->chan->boxes[F], mvars->chan->patterns );
|
|
|
|
boxes[N] = filter_boxes( mvars->boxes[N], mvars->chan->boxes[N], mvars->chan->patterns );
|
2015-03-28 16:51:27 +00:00
|
|
|
mboxapp = &mvars->chanptr->boxes;
|
2015-03-30 12:27:23 +00:00
|
|
|
for (mb = sb = 0; ; ) {
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
char *mname = boxes[F] ? boxes[F][mb] : NULL;
|
|
|
|
char *sname = boxes[N] ? boxes[N][sb] : NULL;
|
2015-03-30 12:27:23 +00:00
|
|
|
if (!mname && !sname)
|
|
|
|
break;
|
2015-03-26 16:27:41 +00:00
|
|
|
mbox = nfmalloc( sizeof(*mbox) );
|
2015-03-30 12:27:23 +00:00
|
|
|
if (!(cmp = !mname - !sname) && !(cmp = cmp_box_names( &mname, &sname ))) {
|
|
|
|
mbox->name = mname;
|
|
|
|
free( sname );
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
mbox->present[F] = mbox->present[N] = BOX_PRESENT;
|
2015-03-26 16:27:41 +00:00
|
|
|
mb++;
|
|
|
|
sb++;
|
|
|
|
} else if (cmp < 0) {
|
2015-03-30 12:27:23 +00:00
|
|
|
mbox->name = mname;
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
mbox->present[F] = BOX_PRESENT;
|
|
|
|
mbox->present[N] = (!mb && !strcmp( mbox->name, "INBOX" )) ? BOX_PRESENT : BOX_ABSENT;
|
2015-03-26 16:27:41 +00:00
|
|
|
mb++;
|
|
|
|
} else {
|
2015-03-30 12:27:23 +00:00
|
|
|
mbox->name = sname;
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
mbox->present[F] = (!sb && !strcmp( mbox->name, "INBOX" )) ? BOX_PRESENT : BOX_ABSENT;
|
|
|
|
mbox->present[N] = BOX_PRESENT;
|
2015-03-26 16:27:41 +00:00
|
|
|
sb++;
|
|
|
|
}
|
2019-07-28 18:50:31 +00:00
|
|
|
mbox->next = NULL;
|
2015-03-26 16:27:41 +00:00
|
|
|
*mboxapp = mbox;
|
|
|
|
mboxapp = &mbox->next;
|
2015-03-28 16:26:08 +00:00
|
|
|
boxes_total++;
|
2004-03-27 16:07:20 +00:00
|
|
|
}
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
free( boxes[F] );
|
|
|
|
free( boxes[N] );
|
2015-03-28 16:26:08 +00:00
|
|
|
if (!mvars->list)
|
|
|
|
stats();
|
2006-03-21 10:38:30 +00:00
|
|
|
}
|
2015-03-28 16:51:27 +00:00
|
|
|
mvars->boxptr = mvars->chanptr->boxes;
|
2006-03-21 10:38:30 +00:00
|
|
|
|
2015-03-28 16:26:08 +00:00
|
|
|
if (mvars->list && chans_total > 1)
|
2006-03-21 15:53:43 +00:00
|
|
|
printf( "%s:\n", mvars->chan->name );
|
2006-03-21 20:03:21 +00:00
|
|
|
syncml:
|
|
|
|
mvars->done = mvars->cben = 0;
|
2015-03-28 16:51:27 +00:00
|
|
|
if (mvars->chanptr->boxlist) {
|
|
|
|
while ((mbox = mvars->boxptr)) {
|
|
|
|
mvars->boxptr = mbox->next;
|
2015-03-26 16:27:41 +00:00
|
|
|
if (sync_listed_boxes( mvars, mbox ))
|
2006-03-21 20:03:21 +00:00
|
|
|
goto syncw;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!mvars->list) {
|
2014-12-30 14:16:38 +00:00
|
|
|
int present[] = { BOX_POSSIBLE, BOX_POSSIBLE };
|
|
|
|
sync_boxes( mvars->ctx, mvars->chan->boxes, present, mvars->chan, done_sync, mvars );
|
2006-03-21 20:03:21 +00:00
|
|
|
mvars->skip = 1;
|
|
|
|
syncw:
|
|
|
|
mvars->cben = 1;
|
|
|
|
if (!mvars->done)
|
|
|
|
return;
|
|
|
|
syncone:
|
|
|
|
if (!mvars->skip)
|
|
|
|
goto syncml;
|
|
|
|
} else
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
printf( "%s <=> %s\n", nz( mvars->chan->boxes[F], "INBOX" ), nz( mvars->chan->boxes[N], "INBOX" ) );
|
2006-03-21 20:03:21 +00:00
|
|
|
}
|
2004-03-27 16:07:20 +00:00
|
|
|
|
|
|
|
next:
|
2015-05-24 09:37:15 +00:00
|
|
|
mvars->cben = 0;
|
2017-03-24 14:29:06 +00:00
|
|
|
for (t = 0; t < 2; t++) {
|
|
|
|
free_string_list( mvars->boxes[t] );
|
2019-07-28 18:50:31 +00:00
|
|
|
mvars->boxes[t] = NULL;
|
2015-05-24 09:37:15 +00:00
|
|
|
if (mvars->state[t] == ST_FRESH) {
|
|
|
|
/* An unconnected store may be only cancelled. */
|
2006-03-21 20:03:21 +00:00
|
|
|
mvars->state[t] = ST_CLOSED;
|
2015-05-24 09:37:15 +00:00
|
|
|
mvars->drv[t]->cancel_store( mvars->ctx[t] );
|
|
|
|
} else if (mvars->state[t] == ST_CONNECTED || mvars->state[t] == ST_OPEN) {
|
|
|
|
mvars->state[t] = ST_CANCELING;
|
|
|
|
mvars->drv[t]->cancel_cmds( mvars->ctx[t], cancel_prep_done, AUX );
|
2006-03-21 20:03:21 +00:00
|
|
|
}
|
2017-03-24 14:29:06 +00:00
|
|
|
}
|
2015-05-24 09:37:15 +00:00
|
|
|
mvars->cben = 1;
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
if (mvars->state[F] != ST_CLOSED || mvars->state[N] != ST_CLOSED) {
|
2015-05-24 09:37:15 +00:00
|
|
|
mvars->skip = 1;
|
2006-03-21 20:03:21 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-11-11 21:32:21 +00:00
|
|
|
if (mvars->chanptr->boxlist) {
|
2015-03-28 16:51:27 +00:00
|
|
|
for (nmbox = mvars->chanptr->boxes; (mbox = nmbox); ) {
|
|
|
|
nmbox = mbox->next;
|
|
|
|
free( mbox->name );
|
|
|
|
free( mbox );
|
|
|
|
}
|
2019-07-28 18:50:31 +00:00
|
|
|
mvars->chanptr->boxes = NULL;
|
2015-03-28 16:51:27 +00:00
|
|
|
mvars->chanptr->boxlist = 0;
|
2015-03-26 16:27:41 +00:00
|
|
|
}
|
2015-01-03 23:39:06 +00:00
|
|
|
next2:
|
2015-03-28 16:26:08 +00:00
|
|
|
if (!mvars->list) {
|
|
|
|
chans_done++;
|
|
|
|
stats();
|
|
|
|
}
|
2019-11-11 21:42:42 +00:00
|
|
|
chan_ent_t *nchan = mvars->chanptr->next;
|
|
|
|
free( mvars->chanptr );
|
|
|
|
mvars->chanptr = nchan;
|
|
|
|
} while (mvars->chanptr);
|
2006-03-20 19:38:20 +00:00
|
|
|
for (t = 0; t < N_DRIVERS; t++)
|
|
|
|
drivers[t]->cleanup();
|
2000-12-20 21:41:21 +00:00
|
|
|
}
|
2006-03-21 20:03:21 +00:00
|
|
|
|
2012-07-15 10:55:04 +00:00
|
|
|
static void
|
2015-05-24 09:37:15 +00:00
|
|
|
store_connected( int sts, void *aux )
|
2006-03-21 20:03:21 +00:00
|
|
|
{
|
|
|
|
MVARS(aux)
|
2012-08-11 16:34:46 +00:00
|
|
|
string_list_t *cpat;
|
2015-05-01 18:19:58 +00:00
|
|
|
int cflags;
|
2006-03-21 20:03:21 +00:00
|
|
|
|
2015-05-24 09:37:15 +00:00
|
|
|
switch (sts) {
|
|
|
|
case DRV_CANCELED:
|
2006-03-21 20:03:21 +00:00
|
|
|
return;
|
2015-05-24 09:37:15 +00:00
|
|
|
case DRV_OK:
|
2017-03-21 17:46:30 +00:00
|
|
|
if (!mvars->skip && !mvars->chanptr->boxlist && mvars->chan->patterns) {
|
2015-05-24 09:37:15 +00:00
|
|
|
for (cflags = 0, cpat = mvars->chan->patterns; cpat; cpat = cpat->next) {
|
|
|
|
const char *pat = cpat->string;
|
|
|
|
if (*pat != '!') {
|
|
|
|
char buf[8];
|
|
|
|
int bufl = snprintf( buf, sizeof(buf), "%s%s", nz( mvars->chan->boxes[t], "" ), pat );
|
|
|
|
int flags = 0;
|
|
|
|
/* Partial matches like "INB*" or even "*" are not considered,
|
|
|
|
* except implicity when the INBOX lives under Path. */
|
|
|
|
if (starts_with( buf, bufl, "INBOX", 5 )) {
|
|
|
|
char c = buf[5];
|
|
|
|
if (!c) {
|
|
|
|
/* User really wants the INBOX. */
|
2013-04-13 17:05:27 +00:00
|
|
|
flags |= LIST_INBOX;
|
2015-05-24 09:37:15 +00:00
|
|
|
} else if (c == '/') {
|
|
|
|
/* Flattened sub-folders of INBOX actually end up in Path. */
|
2017-10-15 14:14:20 +00:00
|
|
|
if (mvars->ctx[t]->conf->flat_delim[0])
|
2015-05-24 09:37:15 +00:00
|
|
|
flags |= LIST_PATH;
|
|
|
|
else
|
|
|
|
flags |= LIST_INBOX;
|
2015-05-23 09:06:17 +00:00
|
|
|
} else if (c == '*' || c == '%') {
|
|
|
|
/* It can be both INBOX and Path, but don't require Path to be configured. */
|
|
|
|
flags |= LIST_INBOX | LIST_PATH_MAYBE;
|
2015-05-24 09:37:15 +00:00
|
|
|
} else {
|
2015-05-23 09:06:17 +00:00
|
|
|
/* It's definitely not the INBOX. */
|
2015-05-24 09:37:15 +00:00
|
|
|
flags |= LIST_PATH;
|
|
|
|
}
|
2013-04-13 17:05:27 +00:00
|
|
|
} else {
|
|
|
|
flags |= LIST_PATH;
|
|
|
|
}
|
2015-05-24 09:37:15 +00:00
|
|
|
debug( "pattern '%s' (effective '%s'): %sPath, %sINBOX\n",
|
|
|
|
pat, buf, (flags & LIST_PATH) ? "" : "no ", (flags & LIST_INBOX) ? "" : "no ");
|
|
|
|
cflags |= flags;
|
2012-09-16 10:34:07 +00:00
|
|
|
}
|
|
|
|
}
|
2015-05-24 09:37:15 +00:00
|
|
|
mvars->state[t] = ST_CONNECTED;
|
|
|
|
mvars->drv[t]->list_store( mvars->ctx[t], cflags, store_listed, AUX );
|
|
|
|
return;
|
2012-08-11 16:34:46 +00:00
|
|
|
}
|
2006-03-21 20:03:21 +00:00
|
|
|
mvars->state[t] = ST_OPEN;
|
2015-05-24 09:37:15 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mvars->ret = mvars->skip = 1;
|
|
|
|
mvars->state[t] = ST_OPEN;
|
|
|
|
break;
|
2006-03-21 20:03:21 +00:00
|
|
|
}
|
2015-05-24 09:37:15 +00:00
|
|
|
sync_chans( mvars, E_OPEN );
|
2006-03-21 20:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-03-24 16:44:11 +00:00
|
|
|
store_listed( int sts, string_list_t *boxes, void *aux )
|
2006-03-21 20:03:21 +00:00
|
|
|
{
|
|
|
|
MVARS(aux)
|
2017-03-24 14:29:06 +00:00
|
|
|
string_list_t *box;
|
2006-03-21 20:03:21 +00:00
|
|
|
|
|
|
|
switch (sts) {
|
2012-07-15 10:55:04 +00:00
|
|
|
case DRV_CANCELED:
|
|
|
|
return;
|
2006-03-21 20:03:21 +00:00
|
|
|
case DRV_OK:
|
2017-03-24 14:29:06 +00:00
|
|
|
for (box = boxes; box; box = box->next) {
|
2017-10-15 14:14:20 +00:00
|
|
|
if (mvars->ctx[t]->conf->flat_delim[0]) {
|
2013-08-03 13:10:57 +00:00
|
|
|
string_list_t *nbox;
|
2017-03-24 14:29:06 +00:00
|
|
|
if (map_name( box->string, (char **)&nbox, offsetof(string_list_t, string), mvars->ctx[t]->conf->flat_delim, "/" ) < 0) {
|
|
|
|
error( "Error: flattened mailbox name '%s' contains canonical hierarchy delimiter\n", box->string );
|
2012-08-18 11:58:14 +00:00
|
|
|
mvars->ret = mvars->skip = 1;
|
2013-08-03 13:10:57 +00:00
|
|
|
} else {
|
2017-03-24 14:29:06 +00:00
|
|
|
nbox->next = mvars->boxes[t];
|
|
|
|
mvars->boxes[t] = nbox;
|
2012-08-18 11:58:14 +00:00
|
|
|
}
|
2017-03-24 14:29:06 +00:00
|
|
|
} else {
|
|
|
|
add_string_list( &mvars->boxes[t], box->string );
|
2012-08-18 11:58:14 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-26 17:09:25 +00:00
|
|
|
if (mvars->ctx[t]->conf->map_inbox) {
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
debug( "adding mapped inbox to %s store: %s\n", str_fn[t], mvars->ctx[t]->conf->map_inbox );
|
2017-03-24 14:29:06 +00:00
|
|
|
add_string_list( &mvars->boxes[t], mvars->ctx[t]->conf->map_inbox );
|
2015-03-26 17:09:25 +00:00
|
|
|
}
|
2006-03-21 20:03:21 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mvars->ret = mvars->skip = 1;
|
|
|
|
break;
|
|
|
|
}
|
2012-07-15 10:55:04 +00:00
|
|
|
mvars->state[t] = ST_OPEN;
|
2006-03-21 20:03:21 +00:00
|
|
|
sync_chans( mvars, E_OPEN );
|
|
|
|
}
|
|
|
|
|
2013-12-07 16:24:08 +00:00
|
|
|
static int
|
2015-03-26 16:27:41 +00:00
|
|
|
sync_listed_boxes( main_vars_t *mvars, box_ent_t *mbox )
|
2013-12-07 16:24:08 +00:00
|
|
|
{
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
if (mvars->chan->boxes[F] || mvars->chan->boxes[N]) {
|
|
|
|
const char *mpfx = nz( mvars->chan->boxes[F], "" );
|
|
|
|
const char *spfx = nz( mvars->chan->boxes[N], "" );
|
2013-12-08 08:49:39 +00:00
|
|
|
if (!mvars->list) {
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
nfasprintf( &mvars->names[F], "%s%s", mpfx, mbox->name );
|
|
|
|
nfasprintf( &mvars->names[N], "%s%s", spfx, mbox->name );
|
2019-07-28 19:13:28 +00:00
|
|
|
sync_boxes( mvars->ctx, (const char * const *)mvars->names, mbox->present, mvars->chan, done_sync_2_dyn, mvars );
|
2013-12-08 08:49:39 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2015-03-26 16:27:41 +00:00
|
|
|
printf( "%s%s <=> %s%s\n", mpfx, mbox->name, spfx, mbox->name );
|
2013-12-08 08:49:39 +00:00
|
|
|
} else {
|
|
|
|
if (!mvars->list) {
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
mvars->names[F] = mvars->names[N] = mbox->name;
|
2019-07-28 19:13:28 +00:00
|
|
|
sync_boxes( mvars->ctx, (const char * const *)mvars->names, mbox->present, mvars->chan, done_sync, mvars );
|
2013-12-08 08:49:39 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2015-03-26 16:27:41 +00:00
|
|
|
puts( mbox->name );
|
2013-12-07 16:24:08 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-08 08:49:39 +00:00
|
|
|
static void
|
|
|
|
done_sync_2_dyn( int sts, void *aux )
|
|
|
|
{
|
|
|
|
main_vars_t *mvars = (main_vars_t *)aux;
|
|
|
|
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
free( mvars->names[F] );
|
|
|
|
free( mvars->names[N] );
|
2013-12-08 08:49:39 +00:00
|
|
|
done_sync( sts, aux );
|
|
|
|
}
|
|
|
|
|
2006-03-21 20:03:21 +00:00
|
|
|
static void
|
|
|
|
done_sync( int sts, void *aux )
|
|
|
|
{
|
|
|
|
main_vars_t *mvars = (main_vars_t *)aux;
|
|
|
|
|
|
|
|
mvars->done = 1;
|
2015-03-28 16:26:08 +00:00
|
|
|
boxes_done++;
|
|
|
|
stats();
|
2006-03-21 20:03:21 +00:00
|
|
|
if (sts) {
|
|
|
|
mvars->ret = 1;
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
if (sts & (SYNC_BAD(F) | SYNC_BAD(N))) {
|
|
|
|
if (sts & SYNC_BAD(F))
|
|
|
|
mvars->state[F] = ST_CLOSED;
|
|
|
|
if (sts & SYNC_BAD(N))
|
|
|
|
mvars->state[N] = ST_CLOSED;
|
2012-08-18 10:48:08 +00:00
|
|
|
mvars->skip = 1;
|
2006-03-21 20:03:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
sync_chans( mvars, E_SYNC );
|
|
|
|
}
|