win32 compile fixes

This commit is contained in:
Kelvin Sherlock 2017-03-04 21:39:04 -05:00
parent f1d906d156
commit f51444e31d
3 changed files with 37 additions and 10 deletions

View File

@ -6,15 +6,21 @@
#include <system_error>
#include <string>
#include <vector>
#include <vector>
#include <unistd.h>
#include <sysexits.h>
#include <stdio.h>
#include <err.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>
#ifdef _WIN32
#include "win.h"
#else
#include <err.h>
#include <sysexits.h>
#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<uint8_t> read_resource_fork(const std::string &path, std::error_code
rv.resize(ok);
break;
}
close fd;
close(fd);
return rv;
#else

View File

@ -6,15 +6,21 @@
#include <system_error>
#include <string>
#include <vector>
#include <vector>
#include <unistd.h>
#include <sysexits.h>
#include <stdio.h>
#include <err.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>
#ifdef _WIN32
#include "win.h"
#else
#include <err.h>
#include <sysexits.h>
#endif
#include "mapped_file.h"
#include "xattr.h"
@ -107,7 +113,7 @@ std::vector<uint8_t> read_resource_fork(const std::string &path, std::error_code
rv.resize(ok);
break;
}
close fd;
close(fd);
return rv;
#else

17
win.h
View File

@ -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)