⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rsync.h

📁 Rsync 3.0.5 source code
💻 H
📖 第 1 页 / 共 3 页
字号:
#ifdef MAKEDEV_TAKES_3_ARGS#define MAKEDEV(devmajor,devminor) makedev(0,devmajor,devminor)#else#define MAKEDEV(devmajor,devminor) makedev(devmajor,devminor)#endif#ifdef HAVE_COMPAT_H#include <compat.h>#endif#ifdef HAVE_LIMITS_H# include <limits.h>#endif#if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H#include <iconv.h>#ifndef ICONV_CONST#define ICONV_CONST#endif#else#ifdef ICONV_CONST#undef ICONV_CONST#endif#ifdef ICONV_OPTION#undef ICONV_OPTION#endif#ifdef iconv_t#undef iconv_t#endif#define iconv_t int#endif#include <assert.h>#include "lib/pool_alloc.h"#ifndef HAVE_ID_Ttypedef unsigned int id_t;#endif#ifndef HAVE_PID_Ttypedef int pid_t;#endif#ifndef HAVE_MODE_Ttypedef unsigned int mode_t;#endif#ifndef HAVE_OFF_Ttypedef long off_t;#endif#ifndef HAVE_SIZE_Ttypedef unsigned int size_t;#endif#define BOOL int#ifndef uchar#define uchar unsigned char#endif#ifdef SIGNED_CHAR_OK#define schar signed char#else#define schar char#endif#ifndef int16#if SIZEOF_INT16_T == 2# define int16 int16_t#else# define int16 short#endif#endif#ifndef uint16#if SIZEOF_UINT16_T == 2# define uint16 uint16_t#else# define uint16 unsigned int16#endif#endif/* Find a variable that is either exactly 32-bits or longer. * If some code depends on 32-bit truncation, it will need to * take special action in a "#if SIZEOF_INT32 > 4" section. */#ifndef int32#if SIZEOF_INT32_T == 4# define int32 int32_t# define SIZEOF_INT32 4#elif SIZEOF_INT == 4# define int32 int# define SIZEOF_INT32 4#elif SIZEOF_LONG == 4# define int32 long# define SIZEOF_INT32 4#elif SIZEOF_SHORT == 4# define int32 short# define SIZEOF_INT32 4#elif SIZEOF_INT > 4# define int32 int# define SIZEOF_INT32 SIZEOF_INT#elif SIZEOF_LONG > 4# define int32 long# define SIZEOF_INT32 SIZEOF_LONG#else# error Could not find a 32-bit integer variable#endif#else# define SIZEOF_INT32 4#endif#ifndef uint32#if SIZEOF_UINT32_T == 4# define uint32 uint32_t#else# define uint32 unsigned int32#endif#endif#if SIZEOF_OFF_T == 8 || !SIZEOF_OFF64_T || !defined HAVE_STRUCT_STAT64#define OFF_T off_t#define STRUCT_STAT struct stat#define SIZEOF_CAPITAL_OFF_T SIZEOF_OFF_T#else#define OFF_T off64_t#define STRUCT_STAT struct stat64#define USE_STAT64_FUNCS 1#define SIZEOF_CAPITAL_OFF_T SIZEOF_OFF64_T#endif/* CAVEAT: on some systems, int64 will really be a 32-bit integer IFF * that's the maximum size the file system can handle and there is no * 64-bit type available.  The rsync source must therefore take steps * to ensure that any code that really requires a 64-bit integer has * it (e.g. the checksum code uses two 32-bit integers for its 64-bit * counter). */#if SIZEOF_INT64_T == 8# define int64 int64_t# define SIZEOF_INT64 8#elif SIZEOF_LONG == 8# define int64 long# define SIZEOF_INT64 8#elif SIZEOF_INT == 8# define int64 int# define SIZEOF_INT64 8#elif SIZEOF_LONG_LONG == 8# define int64 long long# define SIZEOF_INT64 8#elif SIZEOF_OFF64_T == 8# define int64 off64_t# define SIZEOF_INT64 8#elif SIZEOF_OFF_T == 8# define int64 off_t# define SIZEOF_INT64 8#elif SIZEOF_INT > 8# define int64 int# define SIZEOF_INT64 SIZEOF_INT#elif SIZEOF_LONG > 8# define int64 long# define SIZEOF_INT64 SIZEOF_LONG#elif SIZEOF_LONG_LONG > 8# define int64 long long# define SIZEOF_INT64 SIZEOF_LONG_LONG#else/* As long as it gets... */# define int64 off_t# define SIZEOF_INT64 SIZEOF_OFF_T#endifstruct hashtable {	void *nodes;	int32 size, entries;	uint32 node_size;	int key64;};struct ht_int32_node {	void *data;	int32 key;};struct ht_int64_node {	void *data;	int64 key;};#define HT_NODE(tbl, bkts, i) ((void*)((char*)(bkts) + (i)*(tbl)->node_size))#define HT_KEY(node, k64) ((k64)? ((struct ht_int64_node*)(node))->key \			 : (int64)((struct ht_int32_node*)(node))->key)#ifndef MIN#define MIN(a,b) ((a)<(b)?(a):(b))#endif#ifndef MAX#define MAX(a,b) ((a)>(b)?(a):(b))#endif#ifndef MAXHOSTNAMELEN#define MAXHOSTNAMELEN 256#endif#define SUM_LENGTH 16#define SHORT_SUM_LENGTH 2#define BLOCKSUM_BIAS 10#ifndef MAXPATHLEN#define MAXPATHLEN 1024#endif/* We want a roomy line buffer that can hold more than MAXPATHLEN, * and significantly more than an overly short MAXPATHLEN. */#if MAXPATHLEN < 4096#define BIGPATHBUFLEN (4096+1024)#else#define BIGPATHBUFLEN (MAXPATHLEN+1024)#endif#ifndef NAME_MAX#define NAME_MAX 255#endif#ifndef INADDR_NONE#define INADDR_NONE 0xffffffff#endif#ifndef IN_LOOPBACKNET#define IN_LOOPBACKNET 127#endif#if HAVE_UNIXWARE_ACLS|HAVE_SOLARIS_ACLS|HAVE_HPUX_ACLS#define ACLS_NEED_MASK 1#endifunion file_extras {	int32 num;	uint32 unum;};struct file_struct {	const char *dirname;	/* The dir info inside the transfer */	time_t modtime;		/* When the item was last modified */	uint32 len32;		/* Lowest 32 bits of the file's length */	uint16 mode;		/* The item's type and permissions */	uint16 flags;		/* The FLAG_* bits for this item */	const char basename[1];	/* The basename (AKA filename) follows */};extern int file_extra_cnt;extern int inc_recurse;extern int uid_ndx;extern int gid_ndx;extern int acls_ndx;extern int xattrs_ndx;#define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))#define EXTRA_LEN (sizeof (union file_extras))#define PTR_EXTRA_CNT ((sizeof (char *) + EXTRA_LEN - 1) / EXTRA_LEN)#define DEV_EXTRA_CNT 2#define DIRNODE_EXTRA_CNT 3#define SUM_EXTRA_CNT ((MAX_DIGEST_LEN + EXTRA_LEN - 1) / EXTRA_LEN)#define REQ_EXTRA(f,ndx) ((union file_extras*)(f) - (ndx))#define OPT_EXTRA(f,bump) ((union file_extras*)(f) - file_extra_cnt - 1 - (bump))#define LEN64_BUMP(f) ((f)->flags & FLAG_LENGTH64 ? 1 : 0)#define HLINK_BUMP(f) ((f)->flags & (FLAG_HLINKED|FLAG_HLINK_DONE) ? inc_recurse+1 : 0)#define ACL_BUMP(f) (acls_ndx ? 1 : 0)/* The length applies to all items. */#if SIZEOF_INT64 < 8#define F_LENGTH(f) ((int64)(f)->len32)#else#define F_LENGTH(f) ((int64)(f)->len32 + ((f)->flags & FLAG_LENGTH64 \		   ? (int64)OPT_EXTRA(f, 0)->unum << 32 : 0))#endif/* If there is a symlink string, it is always right after the basename */#define F_SYMLINK(f) ((f)->basename + strlen((f)->basename) + 1)/* The sending side always has this available: */#define F_PATHNAME(f) (*(const char**)REQ_EXTRA(f, PTR_EXTRA_CNT))/* The receiving side always has this available: */#define F_DEPTH(f) REQ_EXTRA(f, 1)->num/* When the associated option is on, all entries will have these present: */#define F_OWNER(f) REQ_EXTRA(f, uid_ndx)->unum#define F_GROUP(f) REQ_EXTRA(f, gid_ndx)->unum#define F_ACL(f) REQ_EXTRA(f, acls_ndx)->num#define F_XATTR(f) REQ_EXTRA(f, xattrs_ndx)->num#define F_NDX(f) REQ_EXTRA(f, unsort_ndx)->num/* These items are per-entry optional: */#define F_HL_GNUM(f) OPT_EXTRA(f, LEN64_BUMP(f))->num /* non-dirs */#define F_HL_PREV(f) OPT_EXTRA(f, LEN64_BUMP(f)+inc_recurse)->num /* non-dirs */#define F_DIR_NODE_P(f) (&OPT_EXTRA(f, LEN64_BUMP(f) \				+ DIRNODE_EXTRA_CNT - 1)->num) /* sender dirs */#define F_DIR_RELNAMES_P(f) (&OPT_EXTRA(f, LEN64_BUMP(f) + DIRNODE_EXTRA_CNT \				+ PTR_EXTRA_CNT - 1)->num) /* sender dirs */#define F_DIR_DEFACL(f) OPT_EXTRA(f, LEN64_BUMP(f))->unum /* receiver dirs */#define F_DIR_DEV_P(f) (&OPT_EXTRA(f, LEN64_BUMP(f) + ACL_BUMP(f) \				+ DEV_EXTRA_CNT - 1)->unum) /* receiver dirs *//* This optional item might follow an F_HL_*() item. * (Note: a device doesn't need to check LEN64_BUMP(f).) */#define F_RDEV_P(f) (&OPT_EXTRA(f, HLINK_BUMP(f) + DEV_EXTRA_CNT - 1)->unum)/* The sum is only present on regular files. */#define F_SUM(f) ((char*)OPT_EXTRA(f, LEN64_BUMP(f) + HLINK_BUMP(f) \				    + SUM_EXTRA_CNT - 1))/* Some utility defines: */#define F_IS_ACTIVE(f) (f)->basename[0]#define F_IS_HLINKED(f) ((f)->flags & FLAG_HLINKED)#define F_HLINK_NOT_FIRST(f) BITS_SETnUNSET((f)->flags, FLAG_HLINKED, FLAG_HLINK_FIRST)#define F_HLINK_NOT_LAST(f) BITS_SETnUNSET((f)->flags, FLAG_HLINKED, FLAG_HLINK_LAST)/* These access the F_DIR_DEV_P() and F_RDEV_P() values: */#define DEV_MAJOR(a) (a)[0]#define DEV_MINOR(a) (a)[1]/* These access the F_DIRS_NODE_P() values: */#define DIR_PARENT(a) (a)[0]#define DIR_FIRST_CHILD(a) (a)[1]#define DIR_NEXT_SIBLING(a) (a)[2]/* * Start the flist array at FLIST_START entries and grow it * by doubling until FLIST_LINEAR then grow by FLIST_LINEAR */#define FLIST_START	(32 * 1024)#define FLIST_LINEAR	(FLIST_START * 512)/* * Extent size for allocation pools: A minimum size of 128KB * is needed to mmap them so that freeing will release the * space to the OS. * * Larger sizes reduce leftover fragments and speed free calls * (when they happen). Smaller sizes increase the chance of * freed allocations freeing whole extents. */#define NORMAL_EXTENT	(256 * 1024)#define SMALL_EXTENT	(128 * 1024)#define FLIST_TEMP	(1<<1)struct file_list {	struct file_list *next, *prev;	struct file_struct **files, **sorted;	alloc_pool_t file_pool;	void *pool_boundary;	int used, malloced;	int low, high;  /* 0-relative index values excluding empties */	int ndx_start;  /* the start offset for inc_recurse mode */	int flist_num;  /* 1-relative file_list number or 0 */	int parent_ndx; /* dir_flist index of parent directory */	int in_progress, to_redo;};#define SUMFLG_SAME_OFFSET	(1<<0)struct sum_buf {	OFF_T offset;		/**< offset in file of this chunk */	int32 len;		/**< length of chunk of file */	uint32 sum1;	        /**< simple checksum */	int32 chain;		/**< next hash-table collision */	short flags;		/**< flag bits */	char sum2[SUM_LENGTH];	/**< checksum  */};struct sum_struct {	OFF_T flength;		/**< total file length */	struct sum_buf *sums;	/**< points to info for each chunk */	int32 count;		/**< how many chunks */	int32 blength;		/**< block_length */	int32 remainder;	/**< flength % block_length */	int s2length;		/**< sum2_length */};struct map_struct {	OFF_T file_size;	/* File size (from stat)		*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -