diff --git a/appledouble.cpp b/appledouble.cpp index f0af4fe..5beb925 100644 --- a/appledouble.cpp +++ b/appledouble.cpp @@ -6,15 +6,21 @@ #include #include - #include +#include #include -#include #include -#include #include #include #include +#include + +#ifdef _WIN32 +#include "win.h" +#else +#include +#include +#endif #include "mapped_file.h" #include "xattr.h" @@ -42,7 +48,7 @@ void usage() { - fputs("Usage: applesingle [-hv] [-o outfile] file ...\n", stderr); + fputs("Usage: appledouble [-hv] [-o outfile] file ...\n", stderr); exit(EX_USAGE); } @@ -107,7 +113,7 @@ std::vector read_resource_fork(const std::string &path, std::error_code rv.resize(ok); break; } - close fd; + close(fd); return rv; #else diff --git a/applesingle.cpp b/applesingle.cpp index ce80ecc..e91c14b 100644 --- a/applesingle.cpp +++ b/applesingle.cpp @@ -6,15 +6,21 @@ #include #include - #include +#include #include -#include #include -#include #include #include #include +#include + +#ifdef _WIN32 +#include "win.h" +#else +#include +#include +#endif #include "mapped_file.h" #include "xattr.h" @@ -107,7 +113,7 @@ std::vector read_resource_fork(const std::string &path, std::error_code rv.resize(ok); break; } - close fd; + close(fd); return rv; #else diff --git a/win.h b/win.h index 91dba3f..fbbb3da 100644 --- a/win.h +++ b/win.h @@ -1,10 +1,14 @@ #ifdef __GNUC__ #define ntohl __builtin_bswap32 #define ntohs __builtin_bswap16 +#define htonl __builtin_bswap32 +#define htons __builtin_bswap16 #else #define ntohl _byteswap_ulong #define ntohs _byteswap_ushort +#define htonl _byteswap_ulong +#define htons _byteswap_ushort #endif #define EX_OK 0 /* successful termination */ @@ -30,9 +34,20 @@ #define EX__MAX 78 /* maximum listed value */ #define warn(...) do { \ + char *cp = strerror(errno); \ fputs("dot_clean: ", stderr); \ fprintf(stderr, __VA_ARGS__); \ - perror(NULL); \ + fprintf(stderr,": %s", cp); \ } while(0) +#define warnx(...) do { \ + fputs("dot_clean: ", stderr); \ + fprintf(stderr, __VA_ARGS__); \ +} while(0) +#define warnc(ec, ...) do { \ + char *cp = strerror(ec); \ + fputs("dot_clean: ", stderr); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr,": %s", cp); \ +} while(0)