+#define NO_FILTERS 0
+#define SERVER_FILTERS 1
+#define ALL_FILTERS 2
+
+#define XFLG_FATAL_ERRORS (1<<0)
+#define XFLG_OLD_PREFIXES (1<<1)
+#define XFLG_ANCHORED2ABS (1<<2) /* leading slash indicates absolute */
+#define XFLG_ABS_IF_SLASH (1<<3) /* leading or interior slash is absolute */
+#define XFLG_DIR2WILD3 (1<<4) /* dir/ match gets trailing *** added */
+
+#define ATTRS_REPORT (1<<0)
+#define ATTRS_SKIP_MTIME (1<<1)
+
+#define FULL_FLUSH 1
+#define NORMAL_FLUSH 0
+
+#define PDIR_CREATE 1
+#define PDIR_DELETE 0
+
+/* Note: 0x00 - 0x7F are used for basis_dir[] indexes! */
+#define FNAMECMP_BASIS_DIR_LOW 0x00 /* Must remain 0! */
+#define FNAMECMP_BASIS_DIR_HIGH 0x7F
+#define FNAMECMP_FNAME 0x80
+#define FNAMECMP_PARTIAL_DIR 0x81
+#define FNAMECMP_BACKUP 0x82
+#define FNAMECMP_FUZZY 0x83
+
+/* For use by the itemize_changes code */
+#define ITEM_REPORT_ATIME (1<<0)
+#define ITEM_REPORT_CHANGE (1<<1)
+#define ITEM_REPORT_SIZE (1<<2) /* regular files only */
+#define ITEM_REPORT_TIMEFAIL (1<<2) /* symlinks only */
+#define ITEM_REPORT_TIME (1<<3)
+#define ITEM_REPORT_PERMS (1<<4)
+#define ITEM_REPORT_OWNER (1<<5)
+#define ITEM_REPORT_GROUP (1<<6)
+#define ITEM_REPORT_ACL (1<<7)
+#define ITEM_REPORT_XATTR (1<<8)
+#define ITEM_BASIS_TYPE_FOLLOWS (1<<11)
+#define ITEM_XNAME_FOLLOWS (1<<12)
+#define ITEM_IS_NEW (1<<13)
+#define ITEM_LOCAL_CHANGE (1<<14)
+#define ITEM_TRANSFER (1<<15)
+/* These are outside the range of the transmitted flags. */
+#define ITEM_MISSING_DATA (1<<16) /* used by log_formatted() */
+#define ITEM_DELETED (1<<17) /* used by log_formatted() */
+#define ITEM_MATCHED (1<<18) /* used by itemize() */
+
+#define SIGNIFICANT_ITEM_FLAGS (~(\
+ ITEM_BASIS_TYPE_FOLLOWS | ITEM_XNAME_FOLLOWS | ITEM_LOCAL_CHANGE))
+
+#define CFN_KEEP_DOT_DIRS (1<<0)
+#define CFN_KEEP_TRAILING_SLASH (1<<1)
+#define CFN_DROP_TRAILING_DOT_DIR (1<<2)
+#define CFN_COLLAPSE_DOT_DOT_DIRS (1<<3)
+
+#define SP_DEFAULT 0
+#define SP_KEEP_DOT_DIRS (1<<0)
+
+#define CD_NORMAL 0
+#define CD_SKIP_CHDIR 1
+
+/* Log-message categories. FLOG only goes to the log file, not the client;
+ * FCLIENT is the opposite. */
+enum logcode {
+ FNONE=0, /* never sent */
+ FERROR_XFER=1, FINFO=2, /* sent over socket for any protocol */
+ FERROR=3, FWARNING=4, /* sent over socket for protocols >= 30 */
+ FERROR_SOCKET=5, FLOG=6, /* only sent via receiver -> generator pipe */
+ FERROR_UTF8=8, /* only sent via receiver -> generator pipe */
+ FCLIENT=7 /* never transmitted (e.g. server converts to FINFO) */
+};
+
+/* Messages types that are sent over the message channel. The logcode
+ * values must all be present here with identical numbers. */
+enum msgcode {
+ MSG_DATA=0, /* raw data on the multiplexed stream */
+ MSG_ERROR_XFER=FERROR_XFER, MSG_INFO=FINFO, /* remote logging */
+ MSG_ERROR=FERROR, MSG_WARNING=FWARNING, /* protocol-30 remote logging */
+ MSG_ERROR_SOCKET=FERROR_SOCKET, /* sibling logging */
+ MSG_ERROR_UTF8=FERROR_UTF8, /* sibling logging */
+ MSG_LOG=FLOG, MSG_CLIENT=FCLIENT, /* sibling logging */
+ MSG_REDO=9, /* reprocess indicated flist index */
+ MSG_FLIST=20, /* extra file list over sibling socket */
+ MSG_FLIST_EOF=21,/* we've transmitted all the file lists */
+ MSG_IO_ERROR=22,/* the sending side had an I/O error */
+ MSG_NOOP=42, /* a do-nothing message */
+ MSG_SUCCESS=100,/* successfully updated indicated flist index */
+ MSG_DELETED=101,/* successfully deleted a file on receiving side */
+ MSG_NO_SEND=102,/* sender failed to open a file we wanted */
+ MSG_DONE=86 /* current phase is done */
+};
+
+#define NDX_DONE -1
+#define NDX_FLIST_EOF -2
+#define NDX_FLIST_OFFSET -101