From 251687097b60bad7a88de930576b7177f34fa975 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Wed, 22 Apr 2009 22:13:17 +1000 Subject: adapt it to be buildable --- libbb/copy_file.c | 10 ++++++++++ libbb/messages.c | 2 ++ libbb/mode_string.c | 3 +++ libbb/verror_msg.c | 4 ++++ libbb/xfuncs.c | 9 ++++++++- 5 files changed, 27 insertions(+), 1 deletion(-) (limited to 'libbb') diff --git a/libbb/copy_file.c b/libbb/copy_file.c index a6cfe122d..cf1c756d5 100644 --- a/libbb/copy_file.c +++ b/libbb/copy_file.c @@ -83,12 +83,14 @@ int copy_file(const char *source, const char *dest, int flags) return -1; } } else { +#ifndef __MINGW32__ if (source_stat.st_dev == dest_stat.st_dev && source_stat.st_ino == dest_stat.st_ino ) { bb_error_msg("'%s' and '%s' are the same file", source, dest); return -1; } +#endif dest_exists = 1; } @@ -178,6 +180,7 @@ int copy_file(const char *source, const char *dest, int flags) // Hmm... maybe // if (DEREF && MAKE_SOFTLINK) source = realpath(source) ? // (but realpath returns NULL on dangling symlinks...) +#ifndef __MINGW32__ lf = (flags & FILEUTILS_MAKE_SOFTLINK) ? symlink : link; if (lf(source, dest) < 0) { ovr = ask_and_unlink(dest, flags); @@ -188,6 +191,7 @@ int copy_file(const char *source, const char *dest, int flags) return -1; } } +#endif return 0; } else if (S_ISREG(source_stat.st_mode) @@ -196,6 +200,7 @@ int copy_file(const char *source, const char *dest, int flags) ) { int src_fd; int dst_fd; +#ifndef __MINGW32__ if (ENABLE_FEATURE_PRESERVE_HARDLINKS) { char *link_name; @@ -216,6 +221,7 @@ int copy_file(const char *source, const char *dest, int flags) } add_to_ino_dev_hashtable(&source_stat, dest); } +#endif src_fd = open_or_warn(source, O_RDONLY); if (src_fd < 0) { @@ -274,6 +280,7 @@ int copy_file(const char *source, const char *dest, int flags) status = -1; } +#ifndef __MINGW32__ } else if (S_ISBLK(source_stat.st_mode) || S_ISCHR(source_stat.st_mode) || S_ISSOCK(source_stat.st_mode) || S_ISFIFO(source_stat.st_mode) || S_ISLNK(source_stat.st_mode) @@ -312,6 +319,7 @@ int copy_file(const char *source, const char *dest, int flags) return -1; } } +#endif } else { bb_error_msg("internal error: unrecognized file type"); return -1; @@ -319,6 +327,7 @@ int copy_file(const char *source, const char *dest, int flags) preserve_status: +#ifndef __MINGW32__ if (flags & FILEUTILS_PRESERVE_STATUS /* Cannot happen: */ /* && !(flags & (FILEUTILS_MAKE_SOFTLINK|FILEUTILS_MAKE_HARDLINK)) */ @@ -336,6 +345,7 @@ int copy_file(const char *source, const char *dest, int flags) if (chmod(dest, source_stat.st_mode) < 0) bb_perror_msg("cannot preserve %s of '%s'", "permissions", dest); } +#endif return status; } diff --git a/libbb/messages.c b/libbb/messages.c index 3febe7645..c9a9d7387 100644 --- a/libbb/messages.c +++ b/libbb/messages.c @@ -43,6 +43,7 @@ const char bb_dev_null[] = "/dev/null"; const int const_int_0; const int const_int_1 = 1; +#ifndef __MINGW32__ #include /* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */ const char bb_path_wtmp_file[] = @@ -53,6 +54,7 @@ WTMP_FILE; #else # error unknown path to wtmp file #endif +#endif char bb_common_bufsiz1[(BUFSIZ > 256*sizeof(void*) ? BUFSIZ : 256*sizeof(void*)) + 1]; diff --git a/libbb/mode_string.c b/libbb/mode_string.c index d3ff18375..7afcaa61b 100644 --- a/libbb/mode_string.c +++ b/libbb/mode_string.c @@ -13,6 +13,7 @@ #include +#ifndef __MINGW32__ #include #include "libbb.h" @@ -29,6 +30,7 @@ || ( S_IFDIR != 0040000 ) || ( S_IFCHR != 0020000 ) \ || ( S_IFIFO != 0010000 ) #warning mode type bitflag value assumption(s) violated! falling back to larger version +#endif #if (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX) == 07777 #undef mode_t @@ -91,6 +93,7 @@ static const char type_chars[16] = "?pc?d?b?-?l?s???"; /* 0123456789abcdef */ static const char mode_chars[7] = "rwxSTst"; +#define mode_t unsigned short const char *bb_mode_string(mode_t mode) { static char buf[12]; diff --git a/libbb/verror_msg.c b/libbb/verror_msg.c index 082e7bf3c..1c118e861 100644 --- a/libbb/verror_msg.c +++ b/libbb/verror_msg.c @@ -8,7 +8,9 @@ */ #include "libbb.h" +#if ENABLE_FEATURE_SYSLOG #include +#endif smallint logmode = LOGMODE_STDIO; const char *msg_eol = "\n"; @@ -34,6 +36,7 @@ void bb_verror_msg(const char *s, va_list p, const char* strerr) s[0] ? ": " : "", strerr, msg_eol); } +#if ENABLE_FEATURE_SYSLOG if (ENABLE_FEATURE_SYSLOG && (logmode & LOGMODE_SYSLOG)) { if (!strerr) vsyslog(LOG_ERR, s, p2); @@ -47,5 +50,6 @@ void bb_verror_msg(const char *s, va_list p, const char* strerr) free(msg); } } +#endif va_end(p2); } diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index d02ef9c77..7803afcec 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -158,6 +158,7 @@ void xunlink(const char *pathname) bb_perror_msg_and_die("can't remove file '%s'", pathname); } +#ifndef __MINGW32__ // Turn on nonblocking I/O on a fd int ndelay_on(int fd) { @@ -168,6 +169,7 @@ int ndelay_off(int fd) { return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL,0) & ~O_NONBLOCK); } +#endif // "Renumber" opened fd void xmove_fd(int from, int to) @@ -224,6 +226,7 @@ void xfflush_stdout(void) } } +#ifndef __MINGW32__ void sig_block(int sig) { sigset_t ss; @@ -264,6 +267,7 @@ void sig_pause(void) sigemptyset(&ss); sigsuspend(&ss); } +#endif void xsetenv(const char *key, const char *value) @@ -387,6 +391,7 @@ char *bin2hex(char *p, const char *cp, int count) return p; } +#ifndef __MINGW32__ // Die with an error message if we can't set gid. (Because resource limits may // limit this user to a given number of processes, and if that fills up the // setgid() will fail and we'll _still_be_root_, which is bad.) @@ -440,7 +445,7 @@ off_t fdlength(int fd) return pos + 1; } - +#endif // Die with an error message if we can't malloc() enough space and do an // sprintf() into that space. char *xasprintf(const char *format, ...) @@ -612,6 +617,7 @@ void selinux_or_die(void) /* It is perfectly ok to pass in a NULL for either width or for * height, in which case that value will not be set. */ +#ifndef __MINGW32__ int get_terminal_width_height(const int fd, int *width, int *height) { struct winsize win = { 0, 0, 0, 0 }; @@ -639,3 +645,4 @@ int get_terminal_width_height(const int fd, int *width, int *height) return ret; } +#endif -- cgit v1.2.3-55-g6feb