windows compatibility++
This commit is contained in:
parent
670281ba9a
commit
479749024a
24
Makefile
24
Makefile
|
@ -1,7 +1,11 @@
|
|||
PREFIX=/usr/local
|
||||
BUILDDIR=build
|
||||
TARGET=posix
|
||||
INCLUDE=
|
||||
LIBDIRS=
|
||||
LIBS=
|
||||
LDFLAGS=
|
||||
PLATFORM=posix
|
||||
BUILDDIR=build-$(TARGET)
|
||||
OBJ=\
|
||||
$(BUILDDIR)/audioextract.o \
|
||||
$(BUILDDIR)/audioextract_$(PLATFORM).o \
|
||||
|
@ -19,24 +23,26 @@ OBJ=\
|
|||
$(BUILDDIR)/asf.o \
|
||||
$(BUILDDIR)/bink.o
|
||||
CC=gcc
|
||||
COMMON_CFLAGS=-Wall -pedantic -Wextra -Werror -std=gnu99 -O2 -fmessage-length=0 -g
|
||||
LD=gcc
|
||||
COMMON_CFLAGS=-Wall -Werror -pedantic -Wextra -std=gnu99 -O2 -fmessage-length=0 -g $(INCLUDE) $(LIBDIRS)
|
||||
CFLAGS=$(COMMON_CFLAGS)
|
||||
APPNAME=audioextract
|
||||
BIN=$(BUILDDIR)/$(APPNAME)
|
||||
LIBS=
|
||||
|
||||
ifeq ($(TARGET),win32)
|
||||
PLATFORM=windows
|
||||
CC=i686-pc-mingw32-gcc
|
||||
CFLAGS=$(COMMON_CFLAGS) -m32 -liberty
|
||||
LIBS=-lws2_32
|
||||
LD=i686-pc-mingw32-gcc
|
||||
CFLAGS=$(COMMON_CFLAGS) -m32
|
||||
LIBS=-lws2_32 -liberty
|
||||
APPNAME=audioextract.exe
|
||||
else
|
||||
ifeq ($(TARGET),win64)
|
||||
PLATFORM=windows
|
||||
CC=x86_64-pc-mingw32-gcc
|
||||
CFLAGS=$(COMMON_CFLAGS) -m64 -liberty
|
||||
LIBS=-lws2_64
|
||||
CC=x86_64-w64-mingw32-gcc
|
||||
LD=x86_64-w64-mingw32-gcc
|
||||
CFLAGS=$(COMMON_CFLAGS) -m64
|
||||
LIBS=-lws2_32 -liberty
|
||||
APPNAME=audioextract64.exe
|
||||
endif
|
||||
endif
|
||||
|
@ -46,7 +52,7 @@ endif
|
|||
all: $(BIN)
|
||||
|
||||
$(BIN): $(OBJ)
|
||||
$(CC) $(CFLAGS) $(OBJ) -o $@ $(LIBS)
|
||||
$(LD) $(LIBDIRS) $(LDFLAGS) $(OBJ) -o $@ $(LIBS)
|
||||
|
||||
$(BUILDDIR)/audioextract.o: src/audioextract.c \
|
||||
src/audioextract.h \
|
||||
|
|
|
@ -27,8 +27,15 @@
|
|||
#include "bink.h"
|
||||
|
||||
#if defined(__WINDOWS__) && !defined(__CYGWIN__)
|
||||
# define ZU_FMT "%u"
|
||||
# define EXTRACTED_FILE_FMT "%s%c%s_%08x.%s"
|
||||
# ifdef _WIN64
|
||||
# define ZU_FMT "%l64u"
|
||||
# define EXTRACTED_FILE_FMT "%s%c%s_%08l64x.%s"
|
||||
# pragma GCC diagnostic ignored "-Wformat"
|
||||
# pragma GCC diagnostic ignored "-Wformat-extra-args"
|
||||
# else
|
||||
# define ZU_FMT "%u"
|
||||
# define EXTRACTED_FILE_FMT "%s%c%s_%08x.%s"
|
||||
# endif
|
||||
#else
|
||||
# define ZU_FMT "%zu"
|
||||
# define EXTRACTED_FILE_FMT "%s%c%s_%08zx.%s"
|
||||
|
|
|
@ -54,25 +54,49 @@
|
|||
|
||||
#elif defined(__WINDOWS__)
|
||||
|
||||
/* assume little-endian for Windows
|
||||
* currently only Windows on the XBox 360 uses big-endian */
|
||||
|
||||
# include <winsock2.h>
|
||||
# include <sys/param.h>
|
||||
|
||||
# define htobe16 htons
|
||||
# define htole16(x) (x)
|
||||
# define be16toh ntohs
|
||||
# define le16toh(x) (x)
|
||||
# if BYTE_ORDER == LITTLE_ENDIAN
|
||||
|
||||
# define htobe16 htons
|
||||
# define htole16(x) (x)
|
||||
# define be16toh ntohs
|
||||
# define le16toh(x) (x)
|
||||
|
||||
# define htobe32 htonl
|
||||
# define htole32(x) (x)
|
||||
# define be32toh ntohl
|
||||
# define le32toh(x) (x)
|
||||
# define htobe32 htonl
|
||||
# define htole32(x) (x)
|
||||
# define be32toh ntohl
|
||||
# define le32toh(x) (x)
|
||||
|
||||
# define htobe64 htonll
|
||||
# define htole64(x) (x)
|
||||
# define be64toh ntohll
|
||||
# define le64toh(x) (x)
|
||||
# define htobe64 htonll
|
||||
# define htole64(x) (x)
|
||||
# define be64toh ntohll
|
||||
# define le64toh(x) (x)
|
||||
|
||||
# elif BYTE_ORDER == BIG_ENDIAN
|
||||
|
||||
/* that would be xbox 360 */
|
||||
# define htobe16(x) (x)
|
||||
# define htole16(x) __builtin_bswap16(x)
|
||||
# define be16toh(x) (x)
|
||||
# define le16toh(x) __builtin_bswap16(x)
|
||||
|
||||
# define htobe32(x) (x)
|
||||
# define htole32(x) __builtin_bswap32(x)
|
||||
# define be32toh(x) (x)
|
||||
# define le32toh(x) __builtin_bswap32(x)
|
||||
|
||||
# define htobe64(x) (x)
|
||||
# define htole64(x) __builtin_bswap64(x)
|
||||
# define be64toh(x) (x)
|
||||
# define le64toh(x) __builtin_bswap64(x)
|
||||
|
||||
# else
|
||||
|
||||
# error "byte order not supported"
|
||||
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ int extract(const struct extract_options *options, size_t *numfilesptr)
|
|||
|
||||
if (filesize.QuadPart == 0)
|
||||
goto cleanup;
|
||||
else if (filesize.QuadPart > (size_t)-1)
|
||||
else if ((ULONGLONG)filesize.QuadPart > (size_t)-1)
|
||||
{
|
||||
fprintf(stderr, "error: cannot map file of this size\n");
|
||||
goto error;
|
||||
|
|
Loading…
Reference in New Issue