diff -r -c -N efsl-0.2/Makefile-OSX modified-efsl-0.2/Makefile-OSX
*** efsl-0.2/Makefile-OSX	Wed Dec 31 18:00:00 1969
--- modified-efsl-0.2/Makefile-OSX	Thu Oct  5 13:41:38 2006
***************
*** 0 ****
--- 1,51 ----
+ COPT=-g3 -ansi -Wall -pedantic -O0
+ #COPT=-O3 -march=pentium3 -g3 
+ INCLUDEDIRS=-Iinc -Iconf
+ CFLAGS=$(COPT) $(INCLUDEDIRS)
+ CC=gcc
+ AR=ar
+ OBJ=src/efs.o
+ 	OBJ+=src/plibc.o
+ 	OBJ+=src/disc.o 
+ 	OBJ+=src/partition.o 
+ 	OBJ+=src/fs.o 
+ 	OBJ+=src/fat.o 
+ 	OBJ+=src/time.o 
+ 	OBJ+=src/file.o 
+ 	OBJ+=src/dir.o 
+ 	OBJ+=src/mkfs.o 
+ 	OBJ+=src/debug.o 
+ 	OBJ+=src/ioman.o 
+ 	OBJ+=src/ui.o 
+ 	OBJ+=src/ls.o
+ 	OBJ+=src/extract.o 
+ 	OBJ+=src/interfaces/helper.o 
+ 	OBJ+=src/interfaces/linuxfile.o
+ 
+ all: lib
+ 
+ lib: $(OBJ)
+ 	$(AR) rcs libefsl.a $(OBJ)
+ 
+ len: src/len.o lib
+ 	$(CC) $(CFLAGS) -o test src/len.o -L. -lefsl
+ 	
+ regtest: clean src/regressiontest.o $(OBJ) 
+ 	$(CC) $(CFLAGS) -o regtest src/regressiontest.o $(OBJ)
+ 	mv regtest testfiles
+ 	
+ clean:
+ 	rm -f $(OBJ) src/len.o src/flex.o src/regressiontest.o test libefsl.a
+ 	@cd linuxutils ; make clean
+ 
+ clearscreen:
+ 	clear
+ 
+ utils: lib
+ 	@cd linuxutils ; make all
+ 
+ purge: clean clearscreen len
+ 
+ image: clearscreen
+ 	dd if=/dev/zero of=./image32 bs=1M count=50
+ 	/sbin/mkfs.vfat -F32 -v ./image32
diff -r -c -N efsl-0.2/conf/config-sample-osx.h modified-efsl-0.2/conf/config-sample-osx.h
*** efsl-0.2/conf/config-sample-osx.h	Wed Dec 31 18:00:00 1969
--- modified-efsl-0.2/conf/config-sample-osx.h	Thu Oct  5 15:12:44 2006
***************
*** 0 ****
--- 1,137 ----
+ #ifndef __EFSL_CONFIG_H__
+ #define __EFSL_CONFIG_H__
+ 
+ /* Hardware target
+    ---------------
+ 
+  * Here you will define for what hardware-endpoint EFSL should be compiled.
+  * Look in interfaces.h to see what systems are supported, and add your own
+  * there if you need to write your own driver. Then, define the name you 
+  * selected for your hardware there here. Make sure that you only select one
+  * device!
+ */
+ 
+         /* #define HW_ENDPOINT_LINUX */
+ 	/*#define HW_ENDPOINT_ATMEGA128_SD*/
+ 	/*#define HW_ENDPOINT_DSP_TI6713_SD*/
+ 
+ #define HW_ENDPOINT_OSX
+ 
+ /* Memory configuration
+    --------------------
+  
+  * Here you must configure wheter your processor can access memory byte
+  * oriented. All x86 processors can do it, AVR's can do it to. Some DSP
+  * or other microcontrollers can't. If you have an 8 bit system you're safe.
+  * If you are really unsure, leave the setting commented out, it will be slower
+  * but it will work for sure.
+ */
+ 
+ 	/*#define BYTE_ALIGNMENT*/
+ 	
+ /* Cache configuration
+    -------------------
+    
+  * Here you must configure how much memory of cache you can/want to use.
+  * The number you put at IOMAN_NUMBUFFER is multiplied by 512. So 1 means 
+  * 512 bytes cache, 4 means 2048 bytes cache. More is better.
+  * The number after IOMAN_NUMITERATIONS should be untouched.
+  * The last field (IOMAN_DO_MEMALLOC) is to tell ioman to allocate it's
+  * own memory in it's structure, or not. If you choose to do it yourself
+  * you will have to pass a pointer to the memory as the last argument of
+  * ioman_init.
+ */
+ 	#define IOMAN_NUMBUFFER 100
+ 	#define IOMAN_NUMITERATIONS 3
+ 	#define IOMAN_DO_MEMALLOC
+ 
+ /* Cluster pre-allocation 
+    ----------------------
+    
+  * When writing files, the function that performs the actual write has to
+  * calculate how many clusters it will need for that request. It then allocates
+  * that number of new clusters to the file. Since this involves some 
+  * calculations and writing of the FAT, you might find it beneficial to limit 
+  * the number of allocations, and allow fwrite to pre-allocate a number of 
+  * clusters extra. This setting determines how many clusters will be extra 
+  * allocated whenever this is required.
+  * Take in carefull consideration how large your clustersize is, putting 10 here
+  * with a clustersize of 32kb means you might waste 320 kb.
+  * The first option is for preallocating files, the other is used when enlarging
+  * a directory to accomodate more files
+ */
+       #define CLUSTER_PREALLOC_FILE 50
+       #define CLUSTER_PREALLOC_DIRECTORY 5
+ 
+ /* Endianess configuration
+    -----------------------
+    
+  * Here you can configure wheter your architecture is little or big endian. This
+  * is important since all FAT structures are stored in intel little endian 
+  * order. So if you have a big endian system the library has to convert all 
+  * figures to big endian in order to work.
+  */
+ 
+ /* OS X by default defines the BYTE_ORDER token.  For more details, see 
+    /usr/include/machine/endian.h */
+ 
+ #if BYTE_ORDER==BIG_ENDIAN
+ #define EFSL_BIG_ENDIAN
+ #endif
+ 	
+ /* Date and Time support
+    ---------------------
+    
+  * Here you can enable or disable date and time support. If you enable
+  * it you will have to create 6 functions, that are described in the
+  * EFSL manual. If the functions are not present when linking your
+  * program with the library you will get unresolved dependencies.
+  */ 
+  	/* #define DATE_TIME_SUPPORT */
+ 
+ /* Error reporting support
+    -----------------------
+    
+  * When you receive an error in userland, it usually only gives limited
+  * information (most likely, fail or success). If error detection and
+  * reporting is important for you, you can enable more detailed error
+  * reporting here. This is optional, the costs are 1 byte per object,
+  * and a small increase in code size.
+  * You can enable error recording for all object, or you can select the
+  * object manually.
+  * For full error reporting use FULL_ERROR_SUPPORT
+  * For only the base-core of the library use BASE_ERROR_SUPPORT
+  * For IO/Man use ERRSUP_IOMAN
+  * For Disc   use ERRSUP_IOMAN
+  * For Part   use ERRSUP_PARTITION
+  * For Fs     use ERRSUP_FILESYSTEM
+  * For File   use ERRSUP_FILE
+ */
+ 
+ 	#define FULL_ERROR_SUPPORT
+ 	/*#define BASE_ERROR_SUPPORT*/
+  
+ 
+ /* Debugging configuration
+    -----------------------
+    
+  * Here you can configure the debugging behaviour. Debugging is different
+  * on every platform (see debug.h for more information). 
+  * If your hardware has no means of output (printf) dont define any anything, 
+  * and nothing will happen. For real world use debugging should be turned off.
+ */
+ 
+ 	#define DEBUG
+ 	/*#define DO_FUNC_DEBUG*/
+ 
+ /* List options 
+    ------------
+    
+  * In this section you can configure what kind of data you will get from
+  * directory listing requests. Please refer to the documentation for
+  * more information
+ */
+ 
+ 	#define LIST_MAXLENFILENAME 12
+ 
+ #endif
diff -r -c -N efsl-0.2/examples/osx/Makefile modified-efsl-0.2/examples/osx/Makefile
*** efsl-0.2/examples/osx/Makefile	Wed Dec 31 18:00:00 1969
--- modified-efsl-0.2/examples/osx/Makefile	Thu Oct  5 14:40:28 2006
***************
*** 0 ****
--- 1,3 ----
+ osxtest: osxtest.c
+ 	cc -o $@ $^ -I../../inc -I../../conf -L../.. -lefsl
+ 
diff -r -c -N efsl-0.2/examples/osx/README modified-efsl-0.2/examples/osx/README
*** efsl-0.2/examples/osx/README	Wed Dec 31 18:00:00 1969
--- modified-efsl-0.2/examples/osx/README	Thu Oct  5 14:38:43 2006
***************
*** 0 ****
--- 1,18 ----
+ 
+ 
+ Here are a few examples of how to create empty FAT filesystem images
+ from the OS X command line.  This have been tested under 10.4.7; no
+ guarantees about other versions.
+ 
+  hdiutil create -verbose -size  1m -fs MS-DOS -volname FATIMG fat12
+  hdiutil create -verbose -size 16m -fs MS-DOS -volname FATIMG fat16
+ 
+ These commands create files fat12.dmg and fat16.dmg, which are each
+ just a plain filesystem in a file with no partition table.
+ 
+ hdiutil uses newfs_msdos, which chooses the file system type based on
+ the image size.  FAT32 is also possible.
+ 
+ 
+ 
+ 
diff -r -c -N efsl-0.2/examples/osx/osxtest.c modified-efsl-0.2/examples/osx/osxtest.c
*** efsl-0.2/examples/osx/osxtest.c	Wed Dec 31 18:00:00 1969
--- modified-efsl-0.2/examples/osx/osxtest.c	Thu Oct  5 14:40:46 2006
***************
*** 0 ****
--- 1,28 ----
+ #include <stdio.h>
+ #include <efs.h>
+ 
+ int main(void)
+ {
+ 	EmbeddedFileSystem efs;
+ 	EmbeddedFile file;	
+ 	unsigned short i,e;
+ 	unsigned char buf[512];
+ 	
+ 	if(efs_init(&efs,"fat16.dmg")!=0){
+ 		printf("Could not open filesystem.\n");
+ 		return(-1);
+ 	}
+ 	
+ 	if(file_fopen(&file,&efs.myFs,"group",'r')!=0){
+ 		printf("Could not open file.\n");
+ 		return(-2);
+ 	}
+ 	
+ 	while(e=file_read(&file,512,buf)){
+ 		for(i=0;i<e;i++){
+ 			printf("%c",buf[i]);
+ 		}
+ 	}
+ 
+ 	return(0);
+ }
diff -r -c -N efsl-0.2/inc/debug.h modified-efsl-0.2/inc/debug.h
*** efsl-0.2/inc/debug.h	Wed Jan 18 11:47:39 2006
--- modified-efsl-0.2/inc/debug.h	Thu Oct  5 14:06:20 2006
***************
*** 50,56 ****
  #endif
  
  #ifdef DEBUG
! 	#if defined(HW_ENDPOINT_LINUX) || defined(HW_ENDPOINT_LINUX64)
  	    #define HW_ENDPOINT_LINUX_ALL	
  	#endif
  
--- 50,56 ----
  #endif
  
  #ifdef DEBUG
! 	#if defined(HW_ENDPOINT_LINUX) || defined(HW_ENDPOINT_LINUX64) || defined(HW_ENDPOINT_OSX)
  	    #define HW_ENDPOINT_LINUX_ALL	
  	#endif
  
diff -r -c -N efsl-0.2/inc/extract.h modified-efsl-0.2/inc/extract.h
*** efsl-0.2/inc/extract.h	Wed Jan 18 11:47:39 2006
--- modified-efsl-0.2/inc/extract.h	Thu Oct  5 15:13:01 2006
***************
*** 39,45 ****
  #include "types.h"
  /*****************************************************************************/
  
! #ifdef BIG_ENDIAN
  
  #define ltb_end16(x)  ((((uint16)(x) & 0xff00) >> 8) | \
                        (((uint16)(x) & 0x00ff) << 8))
--- 39,45 ----
  #include "types.h"
  /*****************************************************************************/
  
! #ifdef EFSL_BIG_ENDIAN
  
  #define ltb_end16(x)  ((((uint16)(x) & 0xff00) >> 8) | \
                        (((uint16)(x) & 0x00ff) << 8))
diff -r -c -N efsl-0.2/inc/interface.h modified-efsl-0.2/inc/interface.h
*** efsl-0.2/inc/interface.h	Wed Jan 18 11:47:39 2006
--- modified-efsl-0.2/inc/interface.h	Thu Oct  5 13:47:29 2006
***************
*** 38,44 ****
  #include "config.h"
  /*****************************************************************************/
  
! #if defined(HW_ENDPOINT_LINUX) || defined(HW_ENDPOINT_LINUX64)
  	#include "interfaces/linuxfile.h"
  #elif defined(HW_ENDPOINT_ATMEGA128_SD)
  	#include "interfaces/atmega128.h"
--- 38,44 ----
  #include "config.h"
  /*****************************************************************************/
  
! #if defined(HW_ENDPOINT_LINUX) || defined(HW_ENDPOINT_LINUX64) || defined(HW_ENDPOINT_OSX)
  	#include "interfaces/linuxfile.h"
  #elif defined(HW_ENDPOINT_ATMEGA128_SD)
  	#include "interfaces/atmega128.h"
diff -r -c -N efsl-0.2/inc/types.h modified-efsl-0.2/inc/types.h
*** efsl-0.2/inc/types.h	Wed Jan 18 11:47:39 2006
--- modified-efsl-0.2/inc/types.h	Thu Oct  5 13:47:54 2006
***************
*** 91,96 ****
--- 91,108 ----
  	typedef int eint32;
  	typedef signed int esint32;
  	typedef unsigned int euint32; 
+ #elif defined(HW_ENDPOINT_OSX)
+ 	typedef char eint8;
+ 	typedef signed char esint8;
+ 	typedef unsigned char euint8;
+ 	typedef short eint16;
+ 	typedef signed short esint16;
+ 	typedef unsigned short euint16; 
+ 	typedef long eint32; 
+ 	typedef signed long esint32;
+ 	typedef unsigned long euint32;
+ 	typedef unsigned short uint16;
+ 	typedef unsigned int uint32;
  #else
  	typedef char eint8;
  	typedef signed char esint8;
diff -r -c -N efsl-0.2/linuxutils/mkdir.c modified-efsl-0.2/linuxutils/mkdir.c
*** efsl-0.2/linuxutils/mkdir.c	Wed Jan 18 11:47:40 2006
--- modified-efsl-0.2/linuxutils/mkdir.c	Thu Oct  5 16:51:58 2006
***************
*** 47,53 ****
  	return(-1);
      }
      
!     if(!mkdir(&(efs.myFs),argv[2])){
  	printf("Unable to make directory\n");
  	fs_umount(&(efs.myFs));
  	exit(-1);
--- 47,53 ----
  	return(-1);
      }
      
!     if(mkdir(&(efs.myFs),argv[2])){
  	printf("Unable to make directory\n");
  	fs_umount(&(efs.myFs));
  	exit(-1);
diff -r -c -N efsl-0.2/src/efs.c modified-efsl-0.2/src/efs.c
*** efsl-0.2/src/efs.c	Wed Jan 18 11:47:40 2006
--- modified-efsl-0.2/src/efs.c	Thu Oct  5 14:55:21 2006
***************
*** 49,55 ****
  		disc_initDisc(&efs->myDisc, &efs->myIOman);
  		part_initPartition(&efs->myPart, &efs->myDisc);
  		if(efs->myPart.activePartition==-1){
! 			efs->myDisc.partitions[0].type=0x0B;
  			efs->myDisc.partitions[0].LBA_begin=0;
  			efs->myDisc.partitions[0].numSectors=efs->myCard.sectorCount;	
  			/*efs->myPart.activePartition = 0;*/
--- 49,59 ----
  		disc_initDisc(&efs->myDisc, &efs->myIOman);
  		part_initPartition(&efs->myPart, &efs->myDisc);
  		if(efs->myPart.activePartition==-1){
! 
! 			/* in principle this could examine the FAT name in the bootsector */
!   			/* efs->myDisc.partitions[0].type=0x0B; *//* assume FAT32 by default */
! 			efs->myDisc.partitions[0].type=0x06;  /* assume FAT16 by default */
!  
  			efs->myDisc.partitions[0].LBA_begin=0;
  			efs->myDisc.partitions[0].numSectors=efs->myCard.sectorCount;	
  			/*efs->myPart.activePartition = 0;*/
diff -r -c -N efsl-0.2/src/extract.c modified-efsl-0.2/src/extract.c
*** efsl-0.2/src/extract.c	Wed Jan 18 11:47:40 2006
--- modified-efsl-0.2/src/extract.c	Thu Oct  5 15:17:56 2006
***************
*** 84,109 ****
  /*****************************************************************************/
  /*****************************************************************************/
  
- 
- 
  euint16 ex_getb16(euint8* buf,euint32 offset)
  {
! 	return(ltb_end16(((*(buf+offset+1))<<8) + ((*(buf+offset+0))<<0)));
  }
  /*****************************************************************************/
  
  euint32 ex_getb32(euint8* buf,euint32 offset)
  {
! 	return(ltb_end32(((euint32)buf[offset+3]<<24)+
  	      ((euint32)buf[offset+2]<<16)+
  	      ((euint32)buf[offset+1]<<8)+
! 	      ((euint32)buf[offset+0]<<0)));
  }
  /*****************************************************************************/
  
  void ex_setb16(euint8* buf,euint32 offset,euint16 data)
  {
! #ifdef BIG_ENDIAN
  	*(buf+offset+1) = data>>0;
  	*(buf+offset+0) = data>>8;
  #else
--- 84,107 ----
  /*****************************************************************************/
  /*****************************************************************************/
  
  euint16 ex_getb16(euint8* buf,euint32 offset)
  {
! 	return( ((*(buf+offset+1))<<8) + ((*(buf+offset+0))<<0));
  }
  /*****************************************************************************/
  
  euint32 ex_getb32(euint8* buf,euint32 offset)
  {
! 	return(((euint32)buf[offset+3]<<24)+
  	      ((euint32)buf[offset+2]<<16)+
  	      ((euint32)buf[offset+1]<<8)+
! 	      ((euint32)buf[offset+0]<<0));
  }
  /*****************************************************************************/
  
  void ex_setb16(euint8* buf,euint32 offset,euint16 data)
  {
! #ifdef EFSL_BIG_ENDIAN
  	*(buf+offset+1) = data>>0;
  	*(buf+offset+0) = data>>8;
  #else
***************
*** 115,121 ****
  
  void ex_setb32(euint8* buf,euint32 offset,euint32 data)
  {
! #ifdef BIG_ENDIAN
  	*(buf+offset+3) = data>> 0;
  	*(buf+offset+2) = data>> 8;
  	*(buf+offset+1) = data>>16;
--- 113,119 ----
  
  void ex_setb32(euint8* buf,euint32 offset,euint32 data)
  {
! #ifdef EFSL_BIG_ENDIAN
  	*(buf+offset+3) = data>> 0;
  	*(buf+offset+2) = data>> 8;
  	*(buf+offset+1) = data>>16;
diff -r -c -N efsl-0.2/src/ls.c modified-efsl-0.2/src/ls.c
*** efsl-0.2/src/ls.c	Wed Jan 18 11:47:40 2006
--- modified-efsl-0.2/src/ls.c	Thu Oct  5 16:31:15 2006
***************
*** 133,138 ****
--- 133,142 ----
  	
  	buf+=offset;
  	memCpy(buf+OFFSET_DE_FILENAME,dlist->currentEntry.FileName,LIST_MAXLENFILENAME);
+ 
+ 	/* the DirList FileName field should be a normal zero-terminated C string: */
+ 	dlist->currentEntry.FileName[LIST_MAXLENFILENAME-1] = 0;
+ 
  	dlist->currentEntry.Attribute = *(buf+OFFSET_DE_ATTRIBUTE);
  	dlist->currentEntry.FileSize = ex_getb32(buf,OFFSET_DE_FILESIZE);
  }
