+extern int allowed_lull;
+extern int am_server;
+extern int am_daemon;
+extern int am_sender;
+extern int am_generator;
+extern int incremental;
+extern int io_error;
+extern int eol_nulls;
+extern int flist_eof;
+extern int read_batch;
+extern int csum_length;
+extern int checksum_seed;
+extern int protocol_version;
+extern int remove_source_files;
+extern int preserve_hard_links;
+extern char *filesfrom_host;
+extern struct stats stats;
+extern struct file_list *cur_flist, *first_flist;
+
+const char phase_unknown[] = "unknown";
+int ignore_timeout = 0;
+int batch_fd = -1;
+int done_cnt = 0;
+
+/* Ignore an EOF error if non-zero. See whine_about_eof(). */
+int kluge_around_eof = 0;
+
+int msg_fd_in = -1;
+int msg_fd_out = -1;
+int sock_f_in = -1;
+int sock_f_out = -1;
+
+static int iobuf_f_in = -1;
+static char *iobuf_in;
+static size_t iobuf_in_siz;
+static size_t iobuf_in_ndx;
+static size_t iobuf_in_remaining;
+
+static int iobuf_f_out = -1;
+static char *iobuf_out;
+static int iobuf_out_cnt;
+
+int flist_forward_from = -1;
+
+static int io_multiplexing_out;
+static int io_multiplexing_in;
+static time_t last_io_in;
+static time_t last_io_out;
+static int no_flush;
+
+static int write_batch_monitor_in = -1;
+static int write_batch_monitor_out = -1;
+
+static int io_filesfrom_f_in = -1;
+static int io_filesfrom_f_out = -1;
+static char io_filesfrom_buf[2048];
+static char *io_filesfrom_bp;
+static char io_filesfrom_lastchar;
+static int io_filesfrom_buflen;
+static int defer_forwarding_messages = 0;
+static int select_timeout = SELECT_TIMEOUT;
+static int active_filecnt = 0;
+static OFF_T active_bytecnt = 0;
+
+static char int_byte_cnt[64] = {
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* (00 - 3F)/4 */
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* (40 - 7F)/4 */
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, /* (80 - BF)/4 */
+ 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 9, /* (C0 - FF)/4 */
+};
+
+static void readfd(int fd, char *buffer, size_t N);
+static void writefd(int fd, const char *buf, size_t len);
+static void writefd_unbuffered(int fd, const char *buf, size_t len);
+static void decrement_active_files(int ndx);
+static void decrement_flist_in_progress(int ndx, int redo);
+
+struct flist_ndx_item {
+ struct flist_ndx_item *next;
+ int ndx;
+};
+
+struct flist_ndx_list {
+ struct flist_ndx_item *head, *tail;
+};
+
+static struct flist_ndx_list redo_list, hlink_list;
+
+struct msg_list_item {
+ struct msg_list_item *next;
+ int len;
+ char buf[1];
+};
+
+struct msg_list {
+ struct msg_list_item *head, *tail;
+};