Small. Fast. Reliable.
Choose any three.
*** 46,148 ****
  
  for sqlite 2.8.14: diff attached at http://www.sqlite.org/cvstrac/tktview?tn=822
  
! it will also do no harm to incorporate it in the main sqlite distribution.
! 
! ====
! 
! 
! beneath there is another djgpp listing, the functionality of which has been already applied in mainstream sqlite, in a macro that ignores fnctl calls. in my opinion, it is not needed to apply anymore.
! 
  
! To get it compiling on DJGPP (DOS) you need to patch src/os.c with the following (unified diff):
! 
! 	--- ../temp/sqlite/src/os.c	2002-10-20 20:16:50.000000000 +0000
! 	+++ src/os.c	2002-12-24 18:31:16.000000000 +0000
! 	@@ -27,6 +27,10 @@
! 	 # include <winbase.h>
! 	 #endif
! 	 
! 	+#if (!defined __DJGPP__) && (!defined O_BINARY)
! 	+#define O_BINARY 0
! 	+#endif
! 	+
! 	 /*
! 	 ** Macros for performance tracing.  Normally turned off
! 	 */
! 	@@ -232,9 +236,9 @@
! 	   int *pReadonly
! 	 ){
! 	 #if OS_UNIX
! 	-  id->fd = concat(zFilename, O_RDWR|O_CREAT, 0644);
! 	+  id->fd = concat(zFilename, O_RDWR|O_CREAT|O_BINARY, 0644);
! 	   if( id->fd<0 ){
! 	-    id->fd = concat(zFilename, O_RDONLY);
! 	+    id->fd = concat(zFilename, O_RDONLY|O_BINARY);
! 	     if( id->fd<0 ){
! 	       return SQLITE_CANTOPEN; 
! 	     }
! 	@@ -306,7 +310,7 @@
! 	 #ifndef O_NOFOLLOW
! 	 # define O_NOFOLLOW 0
! 	 #endif
! 	-  id->fd = concat(zFilename, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0600);
! 	+  id->fd = concat(zFilename, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_BINARY, 0600);
! 	   if( id->fd<0 ){
! 	     return SQLITE_CANTOPEN;
! 	   }
! 	@@ -359,7 +363,7 @@
! 	 */
! 	 int sqliteOsOpenReadOnly(const char *zFilename, OsFile *id){
! 	 #if OS_UNIX
! 	-  id->fd = concat(zFilename, O_RDONLY);
! 	+  id->fd = concat(zFilename, O_RDONLY|O_BINARY);
! 	   if( id->fd<0 ){
! 	     return SQLITE_CANTOPEN;
! 	   }
! 	@@ -682,9 +686,13 @@
! 	     lock.l_type = F_RDLCK;
! 	     lock.l_whence = SEEK_SET;
! 	     lock.l_start = lock.l_len = 0L;
! 	+#ifdef __DJGPP__
! 	+    {
! 	+#else
! 	     if( fcntl(id->fd, F_SETLK, &lock)!=0 ){
! 	       rc = SQLITE_BUSY;
! 	     }else{
! 	+#endif
! 	       rc = SQLITE_OK;
! 	       id->pLock->cnt = 1;
! 	       id->locked = 1;
! 	@@ -736,9 +744,13 @@
! 	     lock.l_type = F_WRLCK;
! 	     lock.l_whence = SEEK_SET;
! 	     lock.l_start = lock.l_len = 0L;
! 	+#ifdef __DJGPP__
! 	+    {
! 	+#else
! 	     if( fcntl(id->fd, F_SETLK, &lock)!=0 ){
! 	       rc = SQLITE_BUSY;
! 	     }else{
! 	+#endif
! 	       rc = SQLITE_OK;
! 	       id->pLock->cnt = -1;
! 	       id->locked = 1;
! 	@@ -798,9 +810,13 @@
! 	     lock.l_type = F_UNLCK;
! 	     lock.l_whence = SEEK_SET;
! 	     lock.l_start = lock.l_len = 0L;
! 	+#ifdef __DJGPP__
! 	+    {
! 	+#else
! 	     if( fcntl(id->fd, F_SETLK, &lock)!=0 ){
! 	       rc = SQLITE_BUSY;
! 	     }else{
! 	+#endif
! 	       rc = SQLITE_OK;
! 	       id->pLock->cnt = 0;
! 	     }
! 
! This is needed, because files need to be explicitely opened in binary mode and the check for locking always fails in DJGPP.
  
  DJGPP: http://www.delorie.com/djgpp
  
--- 46,54 ----
  
  for sqlite 2.8.14: diff attached at http://www.sqlite.org/cvstrac/tktview?tn=822
  
! for sqlite 2.8.15: diff attached at http://www.sqlite.org/cvstrac/tktview?tn=833
  
! it will also do no harm to incorporate it in the main sqlite distribution.
  
  DJGPP: http://www.delorie.com/djgpp