diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2010-02-13 09:56:58 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2010-02-13 09:56:58 +0100 |
commit | 68354c7d41085d1f976a5b1d7ee542479a85f621 (patch) | |
tree | aec761c793093e4a2e4ce18d78b3b531bcb12a42 /src/port | |
download | sqlitexx-68354c7d41085d1f976a5b1d7ee542479a85f621.tar.gz sqlitexx-68354c7d41085d1f976a5b1d7ee542479a85f621.tar.bz2 |
imported trunk from sourceforge SVN
Diffstat (limited to 'src/port')
-rw-r--r-- | src/port/sleep.c | 43 | ||||
-rw-r--r-- | src/port/sleep.h | 36 | ||||
-rw-r--r-- | src/port/sqlite.h | 32 | ||||
-rwxr-xr-x | src/port/sqlite3xx.cpp | 42 | ||||
-rw-r--r-- | src/port/string.c | 43 | ||||
-rw-r--r-- | src/port/string.h | 57 | ||||
-rw-r--r-- | src/port/sys_internal.h | 136 | ||||
-rw-r--r-- | src/port/unused.h | 40 |
8 files changed, 429 insertions, 0 deletions
diff --git a/src/port/sleep.c b/src/port/sleep.c new file mode 100644 index 0000000..4ab1966 --- /dev/null +++ b/src/port/sleep.c @@ -0,0 +1,43 @@ +/* + * sqlite3xx - sqlite3 C++ layer, following the ideas of libpqxx + * Copyright (C) 2009 Andreas Baumann + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions of + * the GNU Lesser General Public License, as published by the Free Software + * Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + * + */ + +#include "port/sleep.h" + +/** + * There are different sleep functions on POSIX and WIN32 systems. + */ + +#ifdef _WIN32 +#define WIN32_MEAN_AND_LEAN +#include <windows.h> /* for Sleep */ +#else +#include <unistd.h> /* for sleep */ +#endif + +void sqlitexx_port_sleep( const unsigned int seconds ) { +#ifdef _WIN32 + Sleep( seconds * 1000 ); +#else + sleep( seconds ); +#endif +} + diff --git a/src/port/sleep.h b/src/port/sleep.h new file mode 100644 index 0000000..8320f43 --- /dev/null +++ b/src/port/sleep.h @@ -0,0 +1,36 @@ +/* + * sqlite3xx - sqlite3 C++ layer, following the ideas of libpqxx + * Copyright (C) 2009 Andreas Baumann + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions of + * the GNU Lesser General Public License, as published by the Free Software + * Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + * + */ + +#ifndef __PORT_SLEEP_H +#define __PORT_SLEEP_H + +#ifdef __cplusplus +extern "C" { +#endif + +void sqlitexx_port_sleep( const unsigned int seconds ); + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __PORT_SLEEP_H */ diff --git a/src/port/sqlite.h b/src/port/sqlite.h new file mode 100644 index 0000000..23bdc86 --- /dev/null +++ b/src/port/sqlite.h @@ -0,0 +1,32 @@ +/* + * sqlite3xx - sqlite3 C++ layer, following the ideas of libpqxx + * Copyright (C) 2009 Andreas Baumann + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions of + * the GNU Lesser General Public License, as published by the Free Software + * Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + * + */ + +#ifndef __PORT_SQLITE_H +#define __PORT_SQLITE_H + +/* sqlite3_xxx since 3.5.0 */ +#if SQLITE_VERSION_NUMBER < 3005000 +typedef sqlite_int64 sqlite3_int64; +typedef sqlite_uint64 sqlite3_uint64; +#endif + +#endif /* ifndef __PORT_SQLITE_H */ diff --git a/src/port/sqlite3xx.cpp b/src/port/sqlite3xx.cpp new file mode 100755 index 0000000..384a1d4 --- /dev/null +++ b/src/port/sqlite3xx.cpp @@ -0,0 +1,42 @@ +/* + * sqlite3xx - sqlite3 C++ layer, following the ideas of libpqxx + * Copyright (C) 2009 Andreas Baumann + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions of + * the GNU Lesser General Public License, as published by the Free Software + * Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + * + */ + +#ifdef _WIN32 + +#ifdef BUILD_SHARED + +/* entry point for DLL on Windows */ + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +BOOL APIENTRY DllMain( HANDLE, DWORD, LPVOID ) { + return TRUE; +} + +#else +#error DLL entry poing makesonly sense for a DLL, not for a static library! +#endif /* defined BUILD_SHARED */ + +#else +#error DLL building makes no sence on a non-Windows platform! +#endif /* !defined _WIN32 */ diff --git a/src/port/string.c b/src/port/string.c new file mode 100644 index 0000000..e561ebb --- /dev/null +++ b/src/port/string.c @@ -0,0 +1,43 @@ +/* + * sqlite3xx - sqlite3 C++ layer, following the ideas of libpqxx + * Copyright (C) 2009 Andreas Baumann + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions of + * the GNU Lesser General Public License, as published by the Free Software + * Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + * + */ + +#include "port/string.h" + +/** + * strdup is not always part of the C library or they need insane flags to + * be set which would enable too many non-standard things. + */ + +#if !defined HAVE_STRDUP || defined TEST_STRDUP + +#include <stdlib.h> /* for malloc, NULL */ + +char *sqlitexx_port_strdup( const char *s ) { + char *d; + d = (char *)malloc( strlen( s ) + 1 ); + if( d == NULL ) return NULL; + strcpy( d, s ); + return d; +} + +#endif /* !defined HAVE_STRDUP || defined TEST_STRDUP */ + diff --git a/src/port/string.h b/src/port/string.h new file mode 100644 index 0000000..2b4668b --- /dev/null +++ b/src/port/string.h @@ -0,0 +1,57 @@ +/* + * sqlite3xx - sqlite3 C++ layer, following the ideas of libpqxx + * Copyright (C) 2009 Andreas Baumann + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions of + * the GNU Lesser General Public License, as published by the Free Software + * Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + * + */ + +#ifndef __PORT_STRING_H +#define __PORT_STRING_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "port/sys_internal.h" + +#include <string.h> + +/* on some platforms we must also include the old strings.h to get + * functions like str(n)casecmp */ +#ifdef HAVE_STRINGS_H +#include <strings.h> /* for strcasecmp and strncasecmp */ +#endif + +#include <sys/types.h> /* for size_t */ + +#if defined _WIN32 +#include <memory.h> /* for memcpy */ +#endif + +#if !defined HAVE_STRDUP || defined TEST_STRDUP +char *sqlitexx_port_strdup( const char *s ); +#endif +#if !defined HAVE_STRDUP +#define strdup sqlitexx_port_strdup +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef __PORT_STRING_H */ diff --git a/src/port/sys_internal.h b/src/port/sys_internal.h new file mode 100644 index 0000000..5b6a0b2 --- /dev/null +++ b/src/port/sys_internal.h @@ -0,0 +1,136 @@ +/* + * sqlite3xx - sqlite3 C++ layer, following the ideas of libpqxx + * Copyright (C) 2009 Andreas Baumann + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions of + * the GNU Lesser General Public License, as published by the Free Software + * Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + * + */ + +#ifndef SQLITE3XX_SYS_INTERNAL_H +#define SQLITE3XX_SYS_INTERNAL_H + +#if defined LINUX +#if OS_MAJOR_VERSION == 2 +#if OS_MINOR_VERSION == 6 +#define _XOPEN_SOURCE 600 +#define HAVE_STRDUP +#else + #error unknown platform +#endif /* defined OS_MINOR_VERSION == 6 */ +#else + #error unknown platform +#endif /* defined OS_MAJOR_VERSION == 2 */ +#endif /* defined LINUX */ + +#if defined FREEBSD +#if OS_MAJOR_VERSION == 7 +#if OS_MINOR_VERSION >= 0 && OS_MINOR_VERSION <= 2 +#define _XOPEN_SOURCE 600 +#define HAVE_STRDUP +#else + #error unknown platform +#endif /* defined OS_MINOR_VERSION >= 0 && OS_MINOR_VERSION <= 2 */ +#else +#if OS_MAJOR_VERSION == 6 +#if OS_MINOR_VERSION == 2 +#define _XOPEN_SOURCE 600 +#define HAVE_STRDUP +#else + #error unknown platform +#endif /* defined OS_MINOR_VERSION == 2 */ +#else + #error unknown platform +#endif /* defined OS_MAJOR_VERSION == 6 */ +#endif /* defined OS_MAJOR_VERSION == 7 */ +#endif /* defined FREEBSD */ + +#if defined OPENBSD +#if OS_MAJOR_VERSION == 4 +#if OS_MINOR_VERSION >= 2 && OS_MINOR_VERSION <= 5 +#define _XOPEN_SOURCE 600 +#define HAVE_STRDUP +#else + #error unknown platform +#endif /* defined OS_MINOR_VERSION >= 2 && OS_MINOR_VERSION <= 3 */ +#else + #error unknown platform +#endif /* defined OS_MAJOR_VERSION == 4 */ +#endif /* defined OPENBSD */ + +#if defined NETBSD +#if OS_MAJOR_VERSION == 5 +#if OS_MINOR_VERSION == 0 +/* don't enable XOPEN_SOURCE here, we get compatibility problems + * with libstdc++: vgwscanf undefined + */ +#define HAVE_STRDUP +#else + #error unknown platform +#endif /* defined OS_MINOR_VERSION == 2 */ +#else /* defined OS_MAJOR_VERSION == 4 */ + +#if OS_MAJOR_VERSION == 4 +#if OS_MINOR_VERSION == 0 +#define _XOPEN_SOURCE 600 +#define HAVE_STRDUP +#else + #error unknown platform +#endif /* defined OS_MINOR_VERSION == 2 */ +#else + #error unknown platform +#endif /* defined OS_MAJOR_VERSION == 4 */ +#endif /* defined OS_MAJOR_VERSION == 5 */ +#endif /* defined NETBSD */ + +#if defined SUNOS +#if OS_MAJOR_VERSION == 5 +#if OS_MINOR_VERSION == 8 +#if !defined __cplusplus +#define _XOPEN_SOURCE 600 +#define __EXTENSIONS__ +#endif +#define HAVE_STRDUP +#else +#if OS_MINOR_VERSION == 10 +#if !defined __cplusplus +#define _XOPEN_SOURCE 600 +#define __EXTENSIONS__ +#endif +#define HAVE_STRDUP +#else + #error unknown platform +#endif /* OS_MINOR_VERSION == 10 */ +#endif /* OS_MINOR_VERSION == 8 */ +#else + #error unknown platform +#endif /* OS_MAJOR_VERSION == 5 */ +#endif /* defined SUNOS */ + +#if defined CYGWIN +#if OS_MAJOR_VERSION == 5 +#if OS_MINOR_VERSION >= 0 && OS_MINOR_VERSION <= 1 +#define _XOPEN_SOURCE 600 +#else + #error unknown platform +#endif /* OS_MINOR_VERSION >= 0 && OS_MINOR_VERSION <= 1 */ +#else + #error unknown platform +#endif /* OS_MAJOR_VERSION == 5 */ +#endif /* defined CYGWIN */ + +#endif /* ifndef SQLITE3XX_SYS_INTERNAL_H */ diff --git a/src/port/unused.h b/src/port/unused.h new file mode 100644 index 0000000..241ae2d --- /dev/null +++ b/src/port/unused.h @@ -0,0 +1,40 @@ +/* + * sqlite3xx - sqlite3 C++ layer, following the ideas of libpqxx + * Copyright (C) 2009 Andreas Baumann + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions of + * the GNU Lesser General Public License, as published by the Free Software + * Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + * + */ + +/* mark variables as being unused */ + +#ifndef __PORT_UNUSED_H +#define __PORT_UNUSED_H + +/** + * @brief Macro to avoid unused parameter messages in functions + * + * We could use __attribute__(unused) but I run into some problems + * on OpenBSD 4.5 with it.. + */ +#ifdef __GNUC__ +#define SQLITEXX_UNUSED( x ) if( 0 && (x) ) { } +#else +#define SQLITEXX_UNUSED( x ) { } +#endif + +#endif /* ifndef __PORT_UNUSED_H */ |