diff -Nur mtd/include/mtd/jffs2-user.h mtd.osx/include/mtd/jffs2-user.h --- mtd/include/mtd/jffs2-user.h Wed May 5 07:57:54 2004 +++ mtd.osx/include/mtd/jffs2-user.h Mon Sep 27 05:05:36 2004 @@ -9,8 +9,18 @@ /* This file is blessed for inclusion by userspace */ #include +#if defined(BSD) || (defined(__APPLE__) && defined(__MACH__)) +#include +#include +#define __BYTE_ORDER BYTE_ORDER +#define __BIG_ENDIAN BIG_ENDIAN +#define __LITTLE_ENDIAN LITTLE_ENDIAN +#define bswap_16 OSSwapInt16 +#define bswap_32 OSSwapInt32 +#else #include #include +#endif #undef cpu_to_je16 #undef cpu_to_je32 diff -Nur mtd/util/compr_zlib.c mtd.osx/util/compr_zlib.c --- mtd/util/compr_zlib.c Wed Jun 23 18:00:14 2004 +++ mtd.osx/util/compr_zlib.c Mon Sep 27 05:42:18 2004 @@ -38,7 +38,11 @@ #include #include #include +#if defined(BSD) || (defined(__APPLE__) && defined(__MACH__)) +#include +#else #include +#endif #include #include "compr.h" diff -Nur mtd/util/jffs2dump.c mtd.osx/util/jffs2dump.c --- mtd/util/jffs2dump.c Sat Jun 19 18:00:57 2004 +++ mtd.osx/util/jffs2dump.c Mon Sep 27 05:07:26 2004 @@ -27,11 +27,25 @@ #include #include #include +#if defined(BSD) || (defined(__APPLE__) && defined(__MACH__)) +#include +#else #include +#endif #include #include +#if defined(BSD) || (defined(__APPLE__) && defined(__MACH__)) +#include +#include +#define __BYTE_ORDER BYTE_ORDER +#define __BIG_ENDIAN BIG_ENDIAN +#define __LITTLE_ENDIAN LITTLE_ENDIAN +#define bswap_16 OSSwapInt16 +#define bswap_32 OSSwapInt32 +#else #include #include +#endif #include #include "crc32.h" diff -Nur mtd/util/mkfs.jffs2.c mtd.osx/util/mkfs.jffs2.c --- mtd/util/mkfs.jffs2.c Fri May 28 06:51:11 2004 +++ mtd.osx/util/mkfs.jffs2.c Mon Sep 27 06:06:27 2004 @@ -62,7 +62,11 @@ #include #include #include +#if !(defined(BSD) || (defined(__APPLE__) && defined(__MACH__))) #include +#else +#define __BYTE_ORDER BYTE_ORDER +#endif #define crc32 __complete_crap #include #undef crc32 @@ -429,7 +433,7 @@ the following macros use it if available or use a hacky workaround... */ -#ifdef __GNUC__ +#if defined(__GNUC__) && !(defined(BSD) || (defined(__APPLE__) && defined(__MACH__))) #define SCANF_PREFIX "a" #define SCANF_STRING(s) (&s) #define GETCWD_SIZE 0 @@ -572,6 +576,52 @@ return 0; } +#if defined(BSD) || (defined(__APPLE__) && defined(__MACH__)) +#include +#include + +static inline int getline(char** line, size_t* size, FILE* fp) +{ + size_t i; + static const size_t grow_rate = 80; + int c; + + if (line == NULL || size == NULL || fp == NULL) { + errno = EINVAL; + return -1; + } + if(feof(fp)) return -1; + if (*line == NULL ) { + *line = malloc(sizeof(char) * grow_rate); + *size = grow_rate; + } + + i = 0; + while (1) { + c = fgetc(fp); + if ((*size - i) <= 1) { + *size += grow_rate; + *line = (char*)realloc(*line, *size); + if (*line == NULL) { + errno = ENOMEM; + return -1; + } + } + if('\n' == c || '\r' == c || EOF == c) { + *(*line + i) = '\0'; + break; + } + *(*line + i++) = (char)c; + } + + if( ferror(fp) != 0 ){ + return -1; + }else{ + return i; + } +} +#endif + static int parse_device_table(struct filesystem_entry *root, FILE * file) { char *line;