fix tar detection
[openwrt-10.03/.git] / target / utils / src / trx.c
index 6f9fa4168752e9d60e8c730b93996b9a9d125709..abc9bc93c4111fe06d9edcd8a82d5d6705851c7e 100644 (file)
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
+#if defined(__APPLE__)
+#include <machine/endian.h>
+#include <machine/byte_order.h>
+#define __BYTE_ORDER BYTE_ORDER
+#define __BIG_ENDIAN BIG_ENDIAN
+#define bswap_16(x) NXSwapShort(x)
+#define bswap_32(x) NXSwapInt(x)
+#define bswap_64(x) NXSwapLongLong(x)
+#else
 #include <endian.h>
 #include <byteswap.h>
+#endif
 
 #if __BYTE_ORDER == __BIG_ENDIAN
 #define STORE32_LE(X)          bswap_32(X)
@@ -79,7 +89,7 @@ void usage(void) __attribute__ (( __noreturn__ ));
 
 void usage(void)
 {
-       fprintf(stderr, "Usage: trx [-o outfile] [-m maxlen] [-a align] [-b offset] file [file [file]]\n");
+       fprintf(stderr, "Usage: trx [-o outfile] [-m maxlen] [-a align] [-b offset] [-f file] [-f file [-f file]]\n");
        exit(EXIT_FAILURE);
 }
 
@@ -112,8 +122,9 @@ int main(int argc, char **argv)
        in = NULL;
        i = 0;
 
-       while ((c = getopt(argc, argv, "-:o:m:a:b:")) != -1) {
+       while ((c = getopt(argc, argv, "-:o:m:a:b:f:")) != -1) {
                switch (c) {
+                       case 'f':
                        case 1:
                                p->offsets[i++] = STORE32_LE(cur_len);