diff options
author | drh <drh@noemail.net> | 2005-06-07 22:22:50 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2005-06-07 22:22:50 +0000 |
commit | 0ccebe7e2d2ffd312b03f738ce8c36ec9be0fac9 (patch) | |
tree | d1f62735222da980e8b38982c857376c202c9acc /src | |
parent | 80f93bf41f79a0865559783005f0d72a36fbdf53 (diff) | |
download | sqlite-0ccebe7e2d2ffd312b03f738ce8c36ec9be0fac9.tar.gz sqlite-0ccebe7e2d2ffd312b03f738ce8c36ec9be0fac9.zip |
Changes to support linking without a parser and without a disk I/O interface. (CVS 2504)
FossilOrigin-Name: 62a7353d4af4886b1561832e8b36e8e788b38834
Diffstat (limited to 'src')
-rw-r--r-- | src/os.h | 29 | ||||
-rw-r--r-- | src/os_unix.c | 79 | ||||
-rw-r--r-- | src/os_win.c | 84 | ||||
-rw-r--r-- | src/pragma.c | 6 |
4 files changed, 97 insertions, 101 deletions
@@ -23,7 +23,8 @@ ** N.B. MacOS means Mac Classic (or Carbon). Treat Darwin (OS X) as Unix. ** The MacOS build is designed to use CodeWarrior (tested with v8) */ -#if !defined(OS_UNIX) && !defined(OS_TEST) && !defined(OS_MEM) +#if !defined(OS_UNIX) && !defined(OS_TEST) && !defined(OS_OTHER) +# define OS_OTHER 0 # ifndef OS_WIN # if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) # define OS_WIN 1 @@ -40,9 +41,6 @@ # define OS_WIN 0 # endif #endif -#ifndef OS_MEM -# define OS_MEM 0 -#endif /* ** Invoke the appropriate operating-system specific header file. @@ -56,8 +54,13 @@ #if OS_WIN # include "os_win.h" #endif -#if OS_MEM -# include "os_mem.h" + +/* os_other.c and os_other.h are not delivered with SQLite. These files +** are place-holders that can be filled in by third-party developers to +** implement backends to their on proprietary operating systems. +*/ +#if OS_OTHER +# include "os_other.h" #endif /* If the SET_FULLSYNC macro is not defined above, then make it @@ -181,15 +184,19 @@ int sqlite3OsSeek(OsFile*, i64 offset); int sqlite3OsSync(OsFile*); int sqlite3OsTruncate(OsFile*, i64 size); int sqlite3OsFileSize(OsFile*, i64 *pSize); +char *sqlite3OsFullPathname(const char*); +int sqlite3OsLock(OsFile*, int); +int sqlite3OsUnlock(OsFile*, int); +int sqlite3OsCheckReservedLock(OsFile *id); + + +/* The interface for file I/O is above. Other miscellaneous functions +** are below */ + int sqlite3OsRandomSeed(char*); int sqlite3OsSleep(int ms); int sqlite3OsCurrentTime(double*); -int sqlite3OsFileModTime(OsFile*, double*); void sqlite3OsEnterMutex(void); void sqlite3OsLeaveMutex(void); -char *sqlite3OsFullPathname(const char*); -int sqlite3OsLock(OsFile*, int); -int sqlite3OsUnlock(OsFile*, int); -int sqlite3OsCheckReservedLock(OsFile *id); #endif /* _SQLITE_OS_H_ */ diff --git a/src/os_unix.c b/src/os_unix.c index b900331bd..9c361a171 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -20,6 +20,18 @@ #include <time.h> #include <errno.h> #include <unistd.h> + +/* +** Do not include any of the File I/O interface procedures if the +** SQLITE_OMIT_DISKIO macro is defined (indicating that there database +** will be in-memory only) +*/ +#ifndef SQLITE_OMIT_DISKIO + + +/* +** Define various macros that are missing from some systems. +*/ #ifndef O_LARGEFILE # define O_LARGEFILE 0 #endif @@ -34,7 +46,6 @@ # define O_BINARY 0 #endif - /* ** The DJGPP compiler environment looks mostly like Unix, but it ** lacks the fcntl() system call. So redefine fcntl() to be something @@ -1200,6 +1211,33 @@ int sqlite3OsClose(OsFile *id){ } /* +** Turn a relative pathname into a full pathname. Return a pointer +** to the full pathname stored in space obtained from sqliteMalloc(). +** The calling function is responsible for freeing this space once it +** is no longer needed. +*/ +char *sqlite3OsFullPathname(const char *zRelative){ + char *zFull = 0; + if( zRelative[0]=='/' ){ + sqlite3SetString(&zFull, zRelative, (char*)0); + }else{ + char zBuf[5000]; + zBuf[0] = 0; + sqlite3SetString(&zFull, getcwd(zBuf, sizeof(zBuf)), "/", zRelative, + (char*)0); + } + return zFull; +} + + +#endif /* SQLITE_OMIT_DISKIO */ +/*************************************************************************** +** Everything above deals with file I/O. Everything that follows deals +** with other miscellanous aspects of the operating system interface +****************************************************************************/ + + +/* ** Get information to seed the random number generator. The seed ** is written into the buffer zBuf[256]. The calling function must ** supply a sufficiently large buffer. @@ -1280,25 +1318,6 @@ void sqlite3OsLeaveMutex(){ } /* -** Turn a relative pathname into a full pathname. Return a pointer -** to the full pathname stored in space obtained from sqliteMalloc(). -** The calling function is responsible for freeing this space once it -** is no longer needed. -*/ -char *sqlite3OsFullPathname(const char *zRelative){ - char *zFull = 0; - if( zRelative[0]=='/' ){ - sqlite3SetString(&zFull, zRelative, (char*)0); - }else{ - char zBuf[5000]; - zBuf[0] = 0; - sqlite3SetString(&zFull, getcwd(zBuf, sizeof(zBuf)), "/", zRelative, - (char*)0); - } - return zFull; -} - -/* ** The following variable, if set to a non-zero value, becomes the result ** returned from sqlite3OsCurrentTime(). This is used for testing. */ @@ -1323,24 +1342,4 @@ int sqlite3OsCurrentTime(double *prNow){ return 0; } -#if 0 /* NOT USED */ -/* -** Find the time that the file was last modified. Write the -** modification time and date as a Julian Day number into *prNow and -** return SQLITE_OK. Return SQLITE_ERROR if the modification -** time cannot be found. -*/ -int sqlite3OsFileModTime(OsFile *id, double *prNow){ - int rc; - struct stat statbuf; - if( fstat(id->h, &statbuf)==0 ){ - *prNow = statbuf.st_mtime/86400.0 + 2440587.5; - rc = SQLITE_OK; - }else{ - rc = SQLITE_ERROR; - } - return rc; -} -#endif /* NOT USED */ - #endif /* OS_UNIX */ diff --git a/src/os_win.c b/src/os_win.c index 6e51947af..ea2ca2608 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -35,6 +35,13 @@ #include "os_common.h" /* +** Do not include any of the File I/O interface procedures if the +** SQLITE_OMIT_DISKIO macro is defined (indicating that there database +** will be in-memory only) +*/ +#ifndef SQLITE_OMIT_DISKIO + +/* ** Delete the named file */ int sqlite3OsDelete(const char *zFilename){ @@ -626,6 +633,36 @@ int sqlite3OsUnlock(OsFile *id, int locktype){ } /* +** Turn a relative pathname into a full pathname. Return a pointer +** to the full pathname stored in space obtained from sqliteMalloc(). +** The calling function is responsible for freeing this space once it +** is no longer needed. +*/ +char *sqlite3OsFullPathname(const char *zRelative){ + char *zNotUsed; + char *zFull; + int nByte; +#ifdef __CYGWIN__ + nByte = strlen(zRelative) + MAX_PATH + 1001; + zFull = sqliteMalloc( nByte ); + if( zFull==0 ) return 0; + if( cygwin_conv_to_full_win32_path(zRelative, zFull) ) return 0; +#else + nByte = GetFullPathNameA(zRelative, 0, 0, &zNotUsed) + 1; + zFull = sqliteMalloc( nByte ); + if( zFull==0 ) return 0; + GetFullPathNameA(zRelative, nByte, zFull, &zNotUsed); +#endif + return zFull; +} + +#endif /* SQLITE_OMIT_DISKIO */ +/*************************************************************************** +** Everything above deals with file I/O. Everything that follows deals +** with other miscellanous aspects of the operating system interface +****************************************************************************/ + +/* ** Get information to seed the random number generator. The seed ** is written into the buffer zBuf[256]. The calling function must ** supply a sufficiently large buffer. @@ -698,30 +735,6 @@ void sqlite3OsLeaveMutex(){ } /* -** Turn a relative pathname into a full pathname. Return a pointer -** to the full pathname stored in space obtained from sqliteMalloc(). -** The calling function is responsible for freeing this space once it -** is no longer needed. -*/ -char *sqlite3OsFullPathname(const char *zRelative){ - char *zNotUsed; - char *zFull; - int nByte; -#ifdef __CYGWIN__ - nByte = strlen(zRelative) + MAX_PATH + 1001; - zFull = sqliteMalloc( nByte ); - if( zFull==0 ) return 0; - if( cygwin_conv_to_full_win32_path(zRelative, zFull) ) return 0; -#else - nByte = GetFullPathNameA(zRelative, 0, 0, &zNotUsed) + 1; - zFull = sqliteMalloc( nByte ); - if( zFull==0 ) return 0; - GetFullPathNameA(zRelative, nByte, zFull, &zNotUsed); -#endif - return zFull; -} - -/* ** The following variable, if set to a non-zero value, becomes the result ** returned from sqlite3OsCurrentTime(). This is used for testing. */ @@ -751,27 +764,4 @@ int sqlite3OsCurrentTime(double *prNow){ return 0; } -/* -** Find the time that the file was last modified. Write the -** modification time and date as a Julian Day number into *prNow and -** return SQLITE_OK. Return SQLITE_ERROR if the modification -** time cannot be found. -*/ -int sqlite3OsFileModTime(OsFile *id, double *prMTime){ - int rc; - FILETIME ft; - /* FILETIME structure is a 64-bit value representing the number of - ** 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). - */ - if( GetFileTime(id->h, 0, 0, &ft) ){ - double t; - t = ((double)ft.dwHighDateTime) * 4294967296.0; - *prMTime = (t + ft.dwLowDateTime)/864000000000.0 + 2305813.5; - rc = SQLITE_OK; - }else{ - rc = SQLITE_ERROR; - } - return rc; -} - #endif /* OS_WIN */ diff --git a/src/pragma.c b/src/pragma.c index 93f526bad..d2116ddcf 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** -** $Id: pragma.c,v 1.93 2005/05/22 06:49:57 danielk1977 Exp $ +** $Id: pragma.c,v 1.94 2005/06/07 22:22:51 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -19,7 +19,7 @@ /* Ignore this whole file if pragmas are disabled */ -#ifndef SQLITE_OMIT_PRAGMA +#if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER) #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) # include "pager.h" @@ -930,4 +930,4 @@ pragma_out: sqliteFree(zRight); } -#endif /* SQLITE_OMIT_PRAGMA */ +#endif /* SQLITE_OMIT_PRAGMA || SQLITE_OMIT_PARSER */ |