/*
 * rcopy-repeatedly
 *
 *   You say  rcopy-repeatedly local-file user@host:remote-file
 *   and it polls for changes to local-file and copies them to
 *   remote-file.  rcopy-repeatedly must be installed at the far end.
 *   You can copy in either direction but not between two remote
 *   locations.
 *
 *   Limitations:
 *    * Cannot cope with files which are modified between us opening
 *      and statting them for the first time; if the file shrinks
 *      we may bomb out.  Workaround: use rename-in-place.
 *    * When transferring large files, bandwidth limiter will
 *      be `lumpy' as the whole file is transferred and then we
 *      sleep.
 *    * Cannot copy between two local files.  Workaround: a symlink
 *      (but presumably there was some reason you weren't doing that)
 *    * No ability to synchronise more than just exactly one file
 *    * Polls.  It would be nice to use inotify or something.
 *
 *   Inherent limitations:
 *    * Can only copy plain files.
 *
 *   See the --help for options.
 */     
/*
 * rcopy-repeatedly is
 *  Copyright (C) 2008 Ian Jackson <ian@davenant.greenend.org.uk>
 * and the option parser we use is
 *  Copyright (C) 1994,1995 Ian Jackson <ian@davenant.greenend.org.uk>
 *
 * This 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 3,
 * or (at your option) any later version.
 *
 * This 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 along with this file; if not, consult the Free Software
 * Foundation's website at www.fsf.org, or the GNU Project website at
 * www.gnu.org.
 */
/*
 * protocol is:
 *   server sends banner
 *    - "#rcopy-repeatedly#\n"
 *    - length of declaration, as 4 hex digits, zero prefixed,
 *      and a newline [5 bytes].  In this protocol version this
 *      will be "0002" but client _must_ parse it.
 *   server sends declaration
 *    - one of "u " or "d" [1 byte]
 *    - optionally, some more ascii text, reserved for future use
 *      must be ignored by declaree (but not sent by declarer)
 *    - a newline [1 byte]
 *   client sends
 *    - 0x02   START
 *        n    2 bytes big endian declaration length
 *        ...  client's declaration (ascii text, including newline)
 8             see above
 * then for each update
 *   sender sends one of
 *    - 0x03   destination file should be deleted
 *             but note that contents must be retained by receiver
 *             as it may be used for rle updates
 *    - 0x04   complete new destination file follows, 64-bit length
 *        l    8 bytes big endian length
 *        ...  l bytes data
 *             receiver must then reply with 0x01 ACK
 */
