diff --git a/access.c b/access.c index f8dd593fc..9def1b2c4 100644 --- a/access.c +++ b/access.c @@ -67,7 +67,7 @@ static int match_address(char *addr, char *tok) int gai; int ret = 0; int addrlen = 0; -#if HAVE_STRTOL +#ifdef HAVE_STRTOL long int bits; #else int bits; @@ -88,7 +88,7 @@ static int match_address(char *addr, char *tok) /* Fail quietly if tok is a hostname (not an address) */ if (strspn(tok, ".0123456789") != len -#if INET6 +#ifdef INET6 && strchr(tok, ':') == NULL #endif ) { @@ -133,7 +133,7 @@ static int match_address(char *addr, char *tok) break; -#if INET6 +#ifdef INET6 case PF_INET6: { struct sockaddr_in6 *sin6a, *sin6t; @@ -146,7 +146,7 @@ static int match_address(char *addr, char *tok) addrlen = 16; -#if HAVE_SOCKADDR_IN6_SCOPE_ID +#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID if (sin6t->sin6_scope_id && sin6a->sin6_scope_id != sin6t->sin6_scope_id) { ret = 0; @@ -166,13 +166,13 @@ static int match_address(char *addr, char *tok) bits = -1; if (p) { if (inet_pton(resa->ai_addr->sa_family, p, mask) <= 0) { -#if HAVE_STRTOL +#ifdef HAVE_STRTOL char *ep = NULL; #else unsigned char *pp; #endif -#if HAVE_STRTOL +#ifdef HAVE_STRTOL bits = strtol(p, &ep, 10); if (!*p || *ep) { rprintf(FLOG, "malformed mask in %s\n", tok); diff --git a/backup.c b/backup.c index 1db011ce5..a994e1895 100644 --- a/backup.c +++ b/backup.c @@ -208,7 +208,7 @@ static int keep_backup(char *fname) kept = 1; } -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS if (!kept && preserve_links && S_ISLNK(file->mode)) { if (safe_symlinks && unsafe_symlink(file->u.link, buf)) { if (verbose) { diff --git a/clientname.c b/clientname.c index ed8e97fd0..270f09f11 100644 --- a/clientname.c +++ b/clientname.c @@ -132,7 +132,7 @@ char *client_name(int fd) ss_len = sizeof (struct sockaddr_in); memcpy(&ss, answer->ai_addr, ss_len); break; -#if INET6 +#ifdef INET6 case AF_INET6: ss_len = sizeof (struct sockaddr_in6); memcpy(&ss, answer->ai_addr, ss_len); @@ -172,7 +172,7 @@ void client_sockaddr(int fd, exit_cleanup(RERR_SOCKETIO); } -#if INET6 +#ifdef INET6 if (get_sockaddr_family(ss) == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)ss)->sin6_addr)) { /* OK, so ss is in the IPv6 family, but it is really @@ -189,7 +189,7 @@ void client_sockaddr(int fd, memset(sin, 0, sizeof *sin); sin->sin_family = AF_INET; *ss_len = sizeof (struct sockaddr_in); -#if HAVE_SOCKADDR_IN_LEN +#ifdef HAVE_SOCKADDR_IN_LEN sin->sin_len = *ss_len; #endif sin->sin_port = sin6.sin6_port; @@ -261,7 +261,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai, sizeof sin1->sin_addr); } -#if INET6 +#ifdef INET6 if (ss_family == AF_INET6) { const struct sockaddr_in6 *sin1, *sin2; @@ -278,7 +278,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai, sizeof sin1->sin6_addr)) return 1; -#if HAVE_SOCKADDR_IN6_SCOPE_ID +#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID if (sin1->sin6_scope_id != sin2->sin6_scope_id) return 1; #endif diff --git a/clientserver.c b/clientserver.c index 4007bffef..4cfda8085 100644 --- a/clientserver.c +++ b/clientserver.c @@ -398,7 +398,7 @@ static int rsync_module(int f_in, int f_out, int i) io_printf(f_out, "@ERROR: setgid failed\n"); return -1; } -#if HAVE_SETGROUPS +#ifdef HAVE_SETGROUPS /* Get rid of any supplementary groups this process * might have inheristed. */ if (setgroups(1, &gid)) { diff --git a/flist.c b/flist.c index 8f388087e..731ffee97 100644 --- a/flist.c +++ b/flist.c @@ -145,7 +145,7 @@ static void list_file_entry(struct file_struct *f) permstring(perms, f->mode); -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS if (preserve_links && S_ISLNK(f->mode)) { rprintf(FINFO, "%s %11.0f %s %s -> %s\n", perms, @@ -178,7 +178,7 @@ static void list_file_entry(struct file_struct *f) **/ static int readlink_stat(const char *path, STRUCT_STAT *buffer, char *linkbuf) { -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS if (copy_links) return do_stat(path, buffer); if (link_stat(path, buffer, 0) < 0) @@ -204,7 +204,7 @@ static int readlink_stat(const char *path, STRUCT_STAT *buffer, char *linkbuf) int link_stat(const char *path, STRUCT_STAT *buffer, int follow_dirlinks) { -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS if (copy_links) return do_stat(path, buffer); if (do_lstat(path, buffer) < 0) @@ -253,7 +253,7 @@ static int is_excluded(char *fname, int is_dir, int filter_level) static int to_wire_mode(mode_t mode) { -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS if (S_ISLNK(mode) && (_S_IFLNK != 0120000)) return (mode & ~(_S_IFMT)) | 0120000; #endif @@ -385,7 +385,7 @@ void send_file_entry(struct file_struct *file, int f, unsigned short base_flags) else modtime = file->modtime; -#if SUPPORT_HARD_LINKS +#ifdef SUPPORT_HARD_LINKS if (file->link_u.idev) { if (file->F_DEV == dev) { if (protocol_version >= 28) @@ -463,7 +463,7 @@ void send_file_entry(struct file_struct *file, int f, unsigned short base_flags) } } -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS if (preserve_links && S_ISLNK(mode)) { int len = strlen(file->u.link); write_int(f, len); @@ -471,7 +471,7 @@ void send_file_entry(struct file_struct *file, int f, unsigned short base_flags) } #endif -#if SUPPORT_HARD_LINKS +#ifdef SUPPORT_HARD_LINKS if (flags & XMIT_HAS_IDEV_DATA) { if (protocol_version < 26) { /* 32-bit dev_t and ino_t */ @@ -611,7 +611,7 @@ static struct file_struct *receive_file_entry(struct file_list *flist, } } -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS if (preserve_links && S_ISLNK(mode)) { linkname_len = read_int(f) + 1; /* count the '\0' */ if (linkname_len <= 0 || linkname_len > MAXPATHLEN) { @@ -679,7 +679,7 @@ static struct file_struct *receive_file_entry(struct file_list *flist, if (preserve_devices && IS_DEVICE(mode)) file->u.rdev = rdev; -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS if (linkname_len) { file->u.link = bp; read_sbuf(f, bp, linkname_len - 1); @@ -689,7 +689,7 @@ static struct file_struct *receive_file_entry(struct file_list *flist, } #endif -#if SUPPORT_HARD_LINKS +#ifdef SUPPORT_HARD_LINKS if (preserve_hard_links && protocol_version < 28 && S_ISREG(mode)) flags |= XMIT_HAS_IDEV_DATA; if (flags & XMIT_HAS_IDEV_DATA) { @@ -788,7 +788,7 @@ struct file_struct *make_file(char *fname, struct file_list *flist, && is_excluded(thisname, 0, filter_level)) return NULL; if (save_errno == ENOENT) { -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS /* Avoid "vanished" error if symlink points nowhere. */ if (copy_links && do_lstat(thisname, &st) == 0 && S_ISLNK(st.st_mode)) { @@ -832,7 +832,7 @@ struct file_struct *make_file(char *fname, struct file_list *flist, return NULL; if (lp_ignore_nonreadable(module_id)) { -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS if (!S_ISLNK(st.st_mode)) #endif if (access(thisname, R_OK) != 0) @@ -861,7 +861,7 @@ struct file_struct *make_file(char *fname, struct file_list *flist, } basename_len = strlen(basename) + 1; /* count the '\0' */ -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS linkname_len = S_ISLNK(st.st_mode) ? strlen(linkname) + 1 : 0; #else linkname_len = 0; @@ -890,7 +890,7 @@ struct file_struct *make_file(char *fname, struct file_list *flist, file->uid = st.st_uid; file->gid = st.st_gid; -#if SUPPORT_HARD_LINKS +#ifdef SUPPORT_HARD_LINKS if (flist && flist->hlink_pool) { if (protocol_version < 28) { if (S_ISREG(st.st_mode)) @@ -923,12 +923,12 @@ struct file_struct *make_file(char *fname, struct file_list *flist, memcpy(bp, basename, basename_len); bp += basename_len; -#if HAVE_STRUCT_STAT_ST_RDEV +#ifdef HAVE_STRUCT_STAT_ST_RDEV if (preserve_devices && IS_DEVICE(st.st_mode)) file->u.rdev = st.st_rdev; #endif -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS if (linkname_len) { file->u.link = bp; memcpy(bp, linkname, linkname_len); @@ -1415,7 +1415,7 @@ struct file_list *flist_new(int with_hlink, char *msg) out_of_memory, POOL_INTERN))) out_of_memory(msg); -#if SUPPORT_HARD_LINKS +#ifdef SUPPORT_HARD_LINKS if (with_hlink && preserve_hard_links) { if (!(flist->hlink_pool = pool_create(HLINK_EXTENT, sizeof (struct idev), out_of_memory, POOL_INTERN))) diff --git a/generator.c b/generator.c index 52daa7cdd..31ea93978 100644 --- a/generator.c +++ b/generator.c @@ -337,7 +337,7 @@ static void recv_generator(char *fname, struct file_list *flist, } if (preserve_links && S_ISLNK(file->mode)) { -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS if (safe_symlinks && unsafe_symlink(file->u.link, fname)) { if (verbose) { rprintf(FINFO, @@ -455,7 +455,7 @@ static void recv_generator(char *fname, struct file_list *flist, pathjoin(fnamecmpbuf, sizeof fnamecmpbuf, basis_dir[i], fname); } -#if HAVE_LINK +#ifdef HAVE_LINK if (link_dest && match_level == 3 && !dry_run) { if (do_link(fnamecmpbuf, fname) < 0) { if (verbose) { diff --git a/getfsdev.c b/getfsdev.c index 85928a606..3b113bd43 100644 --- a/getfsdev.c +++ b/getfsdev.c @@ -6,7 +6,7 @@ int ret; while (--argc > 0) { -#if USE_STAT64_FUNCS +#ifdef USE_STAT64_FUNCS ret = stat64(*++argv, &st); #else ret = stat(*++argv, &st); diff --git a/getgroups.c b/getgroups.c index 6b4259d7e..6a8fac2e2 100644 --- a/getgroups.c +++ b/getgroups.c @@ -34,7 +34,7 @@ main(UNUSED(int argc), UNUSED(char *argv[])) gid_t gid = MY_GID(); int gid_in_list = 0; -#if HAVE_GETGROUPS +#ifdef HAVE_GETGROUPS if ((n = getgroups(0, NULL)) < 0) { perror("getgroups"); return 1; @@ -49,7 +49,7 @@ main(UNUSED(int argc), UNUSED(char *argv[])) exit(1); } -#if HAVE_GETGROUPS +#ifdef HAVE_GETGROUPS if (n > 0) n = getgroups(n, list); #endif diff --git a/hlink.c b/hlink.c index 84bca502f..350c5dea3 100644 --- a/hlink.c +++ b/hlink.c @@ -24,7 +24,7 @@ extern int dry_run; extern int verbose; extern int make_backups; -#if SUPPORT_HARD_LINKS +#ifdef SUPPORT_HARD_LINKS static int hlink_compare(struct file_struct **file1, struct file_struct **file2) { struct file_struct *f1 = *file1; @@ -104,7 +104,7 @@ static void link_idev_data(struct file_list *flist) void init_hard_links(struct file_list *flist) { -#if SUPPORT_HARD_LINKS +#ifdef SUPPORT_HARD_LINKS int i; if (flist->count < 2) @@ -135,7 +135,7 @@ void init_hard_links(struct file_list *flist) int hard_link_check(struct file_struct *file, int skip) { -#if SUPPORT_HARD_LINKS +#ifdef SUPPORT_HARD_LINKS if (!hlink_list || !file->link_u.links) return 0; if (skip && !(file->flags & FLAG_HLINK_EOL)) @@ -151,7 +151,7 @@ int hard_link_check(struct file_struct *file, int skip) return 0; } -#if SUPPORT_HARD_LINKS +#ifdef SUPPORT_HARD_LINKS static void hard_link_one(char *hlink1, char *hlink2) { if (do_link(hlink1, hlink2)) { @@ -173,7 +173,7 @@ static void hard_link_one(char *hlink1, char *hlink2) **/ void do_hard_links(void) { -#if SUPPORT_HARD_LINKS +#ifdef SUPPORT_HARD_LINKS struct file_struct *file, *first; char hlink1[MAXPATHLEN]; char *hlink2; diff --git a/lib/compat.c b/lib/compat.c index 879f5487c..97b40ffde 100644 --- a/lib/compat.c +++ b/lib/compat.c @@ -155,7 +155,7 @@ { unsigned char *p = (unsigned char *)&ip.s_addr; static char buf[18]; -#if WORDS_BIGENDIAN +#ifdef WORDS_BIGENDIAN snprintf(buf, 18, "%d.%d.%d.%d", (int)p[0], (int)p[1], (int)p[2], (int)p[3]); #else @@ -196,7 +196,7 @@ /* some systems don't take the 2nd argument */ int sys_gettimeofday(struct timeval *tv) { -#if HAVE_GETTIMEOFDAY_TZ +#ifdef HAVE_GETTIMEOFDAY_TZ return gettimeofday(tv, NULL); #else return gettimeofday(tv); diff --git a/main.c b/main.c index fc48c0195..65c0ec575 100644 --- a/main.c +++ b/main.c @@ -222,7 +222,7 @@ static void report(int f) **/ static void show_malloc_stats(void) { -#if HAVE_MALLINFO +#ifdef HAVE_MALLINFO struct mallinfo mi; mi = mallinfo(); @@ -292,7 +292,7 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char *path, dash_l_set = 1; } -#if HAVE_REMSH +#ifdef HAVE_REMSH /* remsh (on HPUX) takes the arguments the other way around */ args[argc++] = machine; if (user && !(daemon_over_rsh && dash_l_set)) { diff --git a/options.c b/options.c index db1317aca..841f4725b 100644 --- a/options.c +++ b/options.c @@ -104,7 +104,7 @@ long block_size = 0; /* "long" because popt can't set an int32. */ /** Network address family. **/ -#if INET6 +#ifdef INET6 int default_af_hint = 0; /* Any protocol */ #else int default_af_hint = AF_INET; /* Must use IPv4 */ @@ -170,23 +170,23 @@ static void print_rsync_version(enum logcode f) char const *ipv6 = "no "; STRUCT_STAT *dumstat; -#if HAVE_SOCKETPAIR +#ifdef HAVE_SOCKETPAIR got_socketpair = ""; #endif -#if HAVE_FTRUNCATE +#ifdef HAVE_FTRUNCATE have_inplace = ""; #endif -#if SUPPORT_HARD_LINKS +#ifdef SUPPORT_HARD_LINKS hardlinks = ""; #endif -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS links = ""; #endif -#if INET6 +#ifdef INET6 ipv6 = ""; #endif @@ -329,7 +329,7 @@ void usage(enum logcode F) rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n"); rprintf(F," --write-batch=FILE write a batched update to FILE\n"); rprintf(F," --read-batch=FILE read a batched update from FILE\n"); -#if INET6 +#ifdef INET6 rprintf(F," -4, --ipv4 prefer IPv4\n"); rprintf(F," -6, --ipv6 prefer IPv6\n"); #endif @@ -435,7 +435,7 @@ static struct poptOption long_options[] = { {"no-implied-dirs", 0, POPT_ARG_VAL, &implied_dirs, 0, 0, 0 }, {"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 }, {"checksum-seed", 0, POPT_ARG_INT, &checksum_seed, 0, 0, 0 }, -#if INET6 +#ifdef INET6 {"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 }, {"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 }, #endif @@ -458,7 +458,7 @@ static void daemon_usage(enum logcode F) rprintf(F," --no-detach do not detach from the parent\n"); rprintf(F," --port=PORT listen on alternate port number\n"); rprintf(F," -v, --verbose increase verbosity\n"); -#if INET6 +#ifdef INET6 rprintf(F," -4, --ipv4 prefer IPv4\n"); rprintf(F," -6, --ipv6 prefer IPv6\n"); #endif @@ -474,7 +474,7 @@ static struct poptOption long_daemon_options[] = { {"bwlimit", 0, POPT_ARG_INT, &daemon_bwlimit, 0, 0, 0 }, {"config", 0, POPT_ARG_STRING, &config_file, 0, 0, 0 }, {"daemon", 0, POPT_ARG_NONE, &daemon_opt, 0, 0, 0 }, -#if INET6 +#ifdef INET6 {"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 }, {"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 }, #endif @@ -799,7 +799,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain) break; case OPT_LINK_DEST: -#if HAVE_LINK +#ifdef HAVE_LINK link_dest = 1; dest_option = "--link-dest"; goto set_dest_dir; @@ -849,7 +849,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain) if (am_sender < 0) am_sender = 0; -#if !SUPPORT_LINKS +#ifndef SUPPORT_LINKS if (preserve_links && !am_sender) { snprintf(err_buf, sizeof err_buf, "symlinks are not supported on this %s\n", @@ -858,7 +858,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain) } #endif -#if !SUPPORT_HARD_LINKS +#ifndef SUPPORT_HARD_LINKS if (preserve_hard_links) { snprintf(err_buf, sizeof err_buf, "hard links are not supported on this %s\n", @@ -921,7 +921,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain) } if (!files_from) recurse = -1; /* infinite recursion */ -#if SUPPORT_LINKS +#ifdef SUPPORT_LINKS preserve_links = 1; #endif preserve_perms = 1; @@ -1064,7 +1064,7 @@ int parse_arguments(int *argc, const char ***argv, int frommain) partial_dir = partialdir_for_delayupdate; if (inplace) { -#if HAVE_FTRUNCATE +#ifdef HAVE_FTRUNCATE if (partial_dir) { snprintf(err_buf, sizeof err_buf, "--inplace cannot be used with --%s\n", diff --git a/progress.c b/progress.c index cda9178b1..22e0955eb 100644 --- a/progress.c +++ b/progress.c @@ -26,7 +26,7 @@ extern int am_server; #define PROGRESS_HISTORY_SECS 5 -#if GETPGRP_VOID +#ifdef GETPGRP_VOID #define GETPGRP_ARG #else #define GETPGRP_ARG 0 @@ -121,7 +121,7 @@ void end_progress(OFF_T size) void show_progress(OFF_T ofs, OFF_T size) { struct timeval now; -#if HAVE_GETPGRP && HAVE_TCGETPGRP +#if defined HAVE_GETPGRP && defined HAVE_TCGETPGRP static pid_t pgrp = -1; pid_t tc_pgrp; #endif @@ -129,7 +129,7 @@ void show_progress(OFF_T ofs, OFF_T size) if (am_server) return; -#if HAVE_GETPGRP && HAVE_TCGETPGRP +#if defined HAVE_GETPGRP && defined HAVE_TCGETPGRP if (pgrp == -1) pgrp = getpgrp(GETPGRP_ARG); #endif @@ -165,7 +165,7 @@ void show_progress(OFF_T ofs, OFF_T size) ph_list[newest_hpos].ofs = ofs; } -#if HAVE_GETPGRP && HAVE_TCGETPGRP +#if defined HAVE_GETPGRP && defined HAVE_TCGETPGRP tc_pgrp = tcgetpgrp(STDOUT_FILENO); if (tc_pgrp != pgrp && tc_pgrp != -1) return; diff --git a/receiver.c b/receiver.c index b674c14e5..2f4bc7aa5 100644 --- a/receiver.c +++ b/receiver.c @@ -228,7 +228,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r, if (flush_write_file(fd) < 0) goto report_write_error; -#if HAVE_FTRUNCATE +#ifdef HAVE_FTRUNCATE if (inplace && fd != -1) ftruncate(fd, offset); #endif diff --git a/rsync.c b/rsync.c index 89fe6f3ee..0245c0b3b 100644 --- a/rsync.c +++ b/rsync.c @@ -185,7 +185,7 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st, change_uid = am_root && preserve_uid && st->st_uid != file->uid; change_gid = preserve_gid && file->gid != GID_NONE && st->st_gid != file->gid; -#if !HAVE_LCHOWN && !CHOWN_MODIFIES_SYMLINK +#if !defined HAVE_LCHOWN && !defined CHOWN_MODIFIES_SYMLINK if (S_ISLNK(st->st_mode)) ; else @@ -225,7 +225,7 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st, updated = 1; } -#if HAVE_CHMOD +#ifdef HAVE_CHMOD if (!S_ISLNK(st->st_mode)) { if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) { updated = 1; diff --git a/rsync.h b/rsync.h index 75e3a26bf..2a7e5bd76 100644 --- a/rsync.h +++ b/rsync.h @@ -155,100 +155,100 @@ enum msgcode { /* The default RSYNC_RSH is always set in config.h. */ #include -#if HAVE_SYS_TYPES_H +#ifdef HAVE_SYS_TYPES_H # include #endif -#if HAVE_SYS_STAT_H +#ifdef HAVE_SYS_STAT_H # include #endif -#if STDC_HEADERS +#ifdef STDC_HEADERS # include # include #else -# if HAVE_STDLIB_H +# ifdef HAVE_STDLIB_H # include # endif #endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif -#if HAVE_STRINGS_H +#ifdef HAVE_STRINGS_H # include #endif -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H # include #endif -#if HAVE_SYS_PARAM_H +#ifdef HAVE_SYS_PARAM_H #include #endif -#if HAVE_MALLOC_H && (HAVE_MALLINFO || !HAVE_STDLIB_H) +#if defined HAVE_MALLOC_H && (defined HAVE_MALLINFO || !defined HAVE_STDLIB_H) #include #endif -#if HAVE_SYS_SOCKET_H +#ifdef HAVE_SYS_SOCKET_H #include #endif -#if TIME_WITH_SYS_TIME +#ifdef TIME_WITH_SYS_TIME #include #include #else -#if HAVE_SYS_TIME_H +#ifdef HAVE_SYS_TIME_H #include #else #include #endif #endif -#if HAVE_FCNTL_H +#ifdef HAVE_FCNTL_H #include #else -#if HAVE_SYS_FCNTL_H +#ifdef HAVE_SYS_FCNTL_H #include #endif #endif -#if HAVE_SYS_IOCTL_H +#ifdef HAVE_SYS_IOCTL_H #include #endif -#if HAVE_SYS_FILIO_H +#ifdef HAVE_SYS_FILIO_H #include #endif #include -#if HAVE_SYS_WAIT_H +#ifdef HAVE_SYS_WAIT_H #include #endif -#if HAVE_CTYPE_H +#ifdef HAVE_CTYPE_H #include #endif -#if HAVE_GRP_H +#ifdef HAVE_GRP_H #include #endif #include -#if HAVE_UTIME_H +#ifdef HAVE_UTIME_H #include #endif -#if HAVE_SYS_SELECT_H +#ifdef HAVE_SYS_SELECT_H #include #endif -#if HAVE_SYS_MODE_H +#ifdef HAVE_SYS_MODE_H /* apparently AIX needs this for S_ISLNK */ #ifndef S_ISLNK #include #endif #endif -#if HAVE_GLOB_H +#ifdef HAVE_GLOB_H #include #endif @@ -263,31 +263,31 @@ enum msgcode { #include #include -#if HAVE_DIRENT_H +#ifdef HAVE_DIRENT_H # include #else # define dirent direct -# if HAVE_SYS_NDIR_H +# ifdef HAVE_SYS_NDIR_H # include # endif -# if HAVE_SYS_DIR_H +# ifdef HAVE_SYS_DIR_H # include # endif -# if HAVE_NDIR_H +# ifdef HAVE_NDIR_H # include # endif #endif -#if MAJOR_IN_MKDEV +#ifdef MAJOR_IN_MKDEV #include -# if !defined(makedev) && defined(mkdev) +# if !defined makedev && defined mkdev # define makedev mkdev # endif -#elif MAJOR_IN_SYSMACROS +#elif defined MAJOR_IN_SYSMACROS #include #endif -#if HAVE_COMPAT_H +#ifdef HAVE_COMPAT_H #include #endif @@ -301,7 +301,7 @@ enum msgcode { #define uchar unsigned char #endif -#if SIGNED_CHAR_OK +#ifdef SIGNED_CHAR_OK #define schar signed char #else #define schar char @@ -337,7 +337,7 @@ enum msgcode { #define uint32 unsigned int32 #endif -#if SIZEOF_OFF_T == 8 || !SIZEOF_OFF64_T || !HAVE_STRUCT_STAT64 +#if SIZEOF_OFF_T == 8 || !defined SIZEOF_OFF64_T || !defined HAVE_STRUCT_STAT64 #define OFF_T off_t #define STRUCT_STAT struct stat #else @@ -613,36 +613,36 @@ struct stats { #include "proto.h" /* We have replacement versions of these if they're missing. */ -#if !HAVE_ASPRINTF +#ifndef HAVE_ASPRINTF int asprintf(char **ptr, const char *format, ...); #endif -#if !HAVE_VASPRINTF +#ifndef HAVE_VASPRINTF int vasprintf(char **ptr, const char *format, va_list ap); #endif -#if !HAVE_VSNPRINTF || !HAVE_C99_VSNPRINTF +#if !defined HAVE_VSNPRINTF || !defined HAVE_C99_VSNPRINTF #define vsnprintf rsync_vsnprintf int vsnprintf(char *str, size_t count, const char *fmt, va_list args); #endif -#if !HAVE_SNPRINTF || !HAVE_C99_VSNPRINTF +#if !defined HAVE_SNPRINTF || !defined HAVE_C99_VSNPRINTF #define snprintf rsync_snprintf int snprintf(char *str,size_t count,const char *fmt,...); #endif -#if !HAVE_STRERROR +#ifndef HAVE_STRERROR extern char *sys_errlist[]; #define strerror(i) sys_errlist[i] #endif -#if !HAVE_STRCHR +#ifndef HAVE_STRCHR # define strchr index # define strrchr rindex #endif -#if !HAVE_ERRNO_DECL +#ifndef HAVE_ERRNO_DECL extern int errno; #endif @@ -732,7 +732,7 @@ extern int errno; /* work out what fcntl flag to use for non-blocking */ #ifdef O_NONBLOCK # define NONBLOCK_FLAG O_NONBLOCK -#elif defined(SYSV) +#elif defined SYSV # define NONBLOCK_FLAG O_NDELAY #else # define NONBLOCK_FLAG FNDELAY @@ -756,7 +756,7 @@ extern int errno; /* handler for null strings in printf format */ #define NS(s) ((s)?safe_fname(s):"") -#if !defined(__GNUC__) || defined(APPLE) +#if !defined __GNUC__ || defined APPLE /* Apparently the OS X port of gcc gags on __attribute__. * * */ @@ -780,7 +780,7 @@ void rsyserr(enum logcode, int, const char *, ...) __attribute__((format (printf, 3, 4))) ; -#if REPLACE_INET_NTOA +#ifdef REPLACE_INET_NTOA #define inet_ntoa rep_inet_ntoa #endif @@ -789,11 +789,11 @@ void rsyserr(enum logcode, int, const char *, ...) #define O_BINARY 0 #endif -#if !HAVE_STRLCPY +#ifndef HAVE_STRLCPY size_t strlcpy(char *d, const char *s, size_t bufsize); #endif -#if !HAVE_STRLCAT +#ifndef HAVE_STRLCAT size_t strlcat(char *d, const char *s, size_t bufsize); #endif @@ -803,13 +803,13 @@ size_t strlcat(char *d, const char *s, size_t bufsize); #define exit_cleanup(code) _exit_cleanup(code, __FILE__, __LINE__) -#if HAVE_GETEUID +#ifdef HAVE_GETEUID #define MY_UID() geteuid() #else #define MY_UID() getuid() #endif -#if HAVE_GETEGID +#ifdef HAVE_GETEGID #define MY_GID() getegid() #else #define MY_GID() getgid() @@ -817,11 +817,11 @@ size_t strlcat(char *d, const char *s, size_t bufsize); extern int verbose; -#if !HAVE_INET_NTOP +#ifndef HAVE_INET_NTOP const char *inet_ntop(int af, const void *src, char *dst, size_t size); -#endif /* !HAVE_INET_NTOP */ +#endif -#if !HAVE_INET_PTON +#ifndef HAVE_INET_PTON int inet_pton(int af, const char *src, void *dst); #endif diff --git a/socket.c b/socket.c index a64aac6ca..7dfb258f8 100644 --- a/socket.c +++ b/socket.c @@ -452,7 +452,7 @@ void start_accept_loop(int port, int (*fn)(int, int)) for (i = 0, maxfd = -1; sp[i] >= 0; i++) { if (listen(sp[i], 5) < 0) { rsyserr(FERROR, errno, "listen() on socket failed"); -#if INET6 +#ifdef INET6 if (errno == EADDRINUSE && i > 0) { rprintf(FINFO, "Try using --ipv4 or --ipv6 to avoid this listen() error.\n"); @@ -648,16 +648,14 @@ void become_daemon(void) } /* detach from the terminal */ -#if HAVE_SETSID +#ifdef HAVE_SETSID setsid(); -#else -#ifdef TIOCNOTTY +#elif defined TIOCNOTTY i = open("/dev/tty", O_RDWR); if (i >= 0) { ioctl(i, (int)TIOCNOTTY, (char *)0); close(i); } -#endif /* TIOCNOTTY */ #endif /* make sure that stdin, stdout an stderr don't stuff things * up (library functions, for example) */ @@ -693,7 +691,7 @@ static int socketpair_tcp(int fd[2]) goto failed; memset(&sock2, 0, sizeof sock2); -#if HAVE_SOCKADDR_IN_LEN +#ifdef HAVE_SOCKADDR_IN_LEN sock2.sin_len = sizeof sock2; #endif sock2.sin_family = PF_INET; diff --git a/syscall.c b/syscall.c index 4a319701b..2607774b7 100644 --- a/syscall.c +++ b/syscall.c @@ -26,7 +26,7 @@ #include "rsync.h" -#if !MKNOD_CREATES_SOCKETS && HAVE_SYS_UN_H +#if !defined MKNOD_CREATES_SOCKETS && defined HAVE_SYS_UN_H #include #endif @@ -59,7 +59,7 @@ int do_symlink(char *fname1, char *fname2) return symlink(fname1, fname2); } -#if HAVE_LINK +#ifdef HAVE_LINK int do_link(char *fname1, char *fname2) { if (dry_run) return 0; @@ -72,7 +72,7 @@ int do_lchown(const char *path, uid_t owner, gid_t group) { if (dry_run) return 0; RETURN_ERROR_IF_RO_OR_LO; -#if !HAVE_LCHOWN +#ifndef HAVE_LCHOWN #define lchown chown #endif return lchown(path, owner, group); @@ -82,11 +82,11 @@ int do_mknod(char *pathname, mode_t mode, dev_t dev) { if (dry_run) return 0; RETURN_ERROR_IF_RO_OR_LO; -#if !MKNOD_CREATES_FIFOS && HAVE_MKFIFO +#if !defined MKNOD_CREATES_FIFOS && defined HAVE_MKFIFO if (S_ISFIFO(mode)) return mkfifo(pathname, mode); #endif -#if !MKNOD_CREATES_SOCKETS && HAVE_SYS_UN_H +#if !defined MKNOD_CREATES_SOCKETS && defined HAVE_SYS_UN_H if (S_ISSOCK(mode)) { int sock; struct sockaddr_un saddr; @@ -94,7 +94,7 @@ int do_mknod(char *pathname, mode_t mode, dev_t dev) saddr.sun_family = AF_UNIX; len = strlcpy(saddr.sun_path, pathname, sizeof saddr.sun_path); -#if HAVE_SOCKADDR_UN_LEN +#ifdef HAVE_SOCKADDR_UN_LEN saddr.sun_len = len >= sizeof saddr.sun_path ? sizeof saddr.sun_path : len + 1; #endif @@ -107,7 +107,7 @@ int do_mknod(char *pathname, mode_t mode, dev_t dev) return do_chmod(pathname, mode); } #endif -#if HAVE_MKNOD +#ifdef HAVE_MKNOD return mknod(pathname, mode, dev); #else return -1; @@ -131,7 +131,7 @@ int do_open(char *pathname, int flags, mode_t mode) return open(pathname, flags | O_BINARY, mode); } -#if HAVE_CHMOD +#ifdef HAVE_CHMOD int do_chmod(const char *path, mode_t mode) { int code; @@ -186,7 +186,7 @@ int do_mkstemp(char *template, mode_t perms) RETURN_ERROR_IF(dry_run, 0); RETURN_ERROR_IF(read_only, EROFS); -#if HAVE_SECURE_MKSTEMP && HAVE_FCHMOD && (!HAVE_OPEN64 || HAVE_MKSTEMP64) +#if defined HAVE_SECURE_MKSTEMP && defined HAVE_FCHMOD && (!defined HAVE_OPEN64 || defined HAVE_MKSTEMP64) { int fd = mkstemp(template); if (fd == -1) @@ -198,7 +198,7 @@ int do_mkstemp(char *template, mode_t perms) errno = errno_save; return -1; } -#if HAVE_SETMODE && O_BINARY +#if defined HAVE_SETMODE && O_BINARY setmode(fd, O_BINARY); #endif return fd; @@ -212,7 +212,7 @@ int do_mkstemp(char *template, mode_t perms) int do_stat(const char *fname, STRUCT_STAT *st) { -#if USE_STAT64_FUNCS +#ifdef USE_STAT64_FUNCS return stat64(fname, st); #else return stat(fname, st); @@ -221,8 +221,8 @@ int do_stat(const char *fname, STRUCT_STAT *st) int do_lstat(const char *fname, STRUCT_STAT *st) { -#if SUPPORT_LINKS -# if USE_STAT64_FUNCS +#ifdef SUPPORT_LINKS +# ifdef USE_STAT64_FUNCS return lstat64(fname, st); # else return lstat(fname, st); @@ -234,7 +234,7 @@ int do_lstat(const char *fname, STRUCT_STAT *st) int do_fstat(int fd, STRUCT_STAT *st) { -#if USE_STAT64_FUNCS +#ifdef USE_STAT64_FUNCS return fstat64(fd, st); #else return fstat(fd, st); @@ -243,7 +243,7 @@ int do_fstat(int fd, STRUCT_STAT *st) OFF_T do_lseek(int fd, OFF_T offset, int whence) { -#if SIZEOF_OFF64_T +#ifdef SIZEOF_OFF64_T off64_t lseek64(); return lseek64(fd, offset, whence); #else @@ -253,7 +253,7 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence) char *d_name(struct dirent *di) { -#if HAVE_BROKEN_READDIR +#ifdef HAVE_BROKEN_READDIR return (di->d_name - 2); #else return di->d_name; diff --git a/uidlist.c b/uidlist.c index 912cca1a7..ab93014af 100644 --- a/uidlist.c +++ b/uidlist.c @@ -25,7 +25,7 @@ #include "rsync.h" -#if HAVE_GETGROUPS +#ifdef HAVE_GETGROUPS # ifndef GETGROUPS_T # define GETGROUPS_T gid_t # endif @@ -96,7 +96,7 @@ static int map_gid(int id, char *name) static int is_in_group(gid_t gid) { -#if HAVE_GETGROUPS +#ifdef HAVE_GETGROUPS static gid_t last_in = GID_NONE, last_out; static int ngroups = -2; static GETGROUPS_T *gidset; diff --git a/util.c b/util.c index 141342cf1..eb5571344 100644 --- a/util.c +++ b/util.c @@ -79,7 +79,7 @@ int fd_pair(int fd[2]) { int ret; -#if HAVE_SOCKETPAIR +#ifdef HAVE_SOCKETPAIR ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd); #else ret = pipe(fd); @@ -140,12 +140,12 @@ int set_modtime(char *fname, time_t modtime) return 0; { -#if HAVE_UTIMBUF +#ifdef HAVE_UTIMBUF struct utimbuf tbuf; tbuf.actime = time(NULL); tbuf.modtime = modtime; return utime(fname,&tbuf); -#elif HAVE_UTIME +#elif defined HAVE_UTIME time_t t[2]; t[0] = time(NULL); t[1] = modtime; @@ -502,7 +502,7 @@ static void glob_expand_one(char *s, char ***argv_ptr, int *argc_ptr, char **argv = *argv_ptr; int argc = *argc_ptr; int maxargs = *maxargs_ptr; -#if !(HAVE_GLOB && HAVE_GLOB_H) +#if !defined HAVE_GLOB || !defined HAVE_GLOB_H if (argc == maxargs) { maxargs += MAX_ARGS; if (!(argv = realloc_array(argv, char *, maxargs))) @@ -1105,7 +1105,7 @@ char *timestring(time_t t) static char TimeBuf[200]; struct tm *tm = localtime(&t); -#if HAVE_STRFTIME +#ifdef HAVE_STRFTIME strftime(TimeBuf, sizeof TimeBuf - 1, "%Y/%m/%d %H:%M:%S", tm); #else strlcpy(TimeBuf, asctime(tm), sizeof TimeBuf);